Official marketplace plugins already show the official auto-update badge, but the first-enable confirmation still used community-plugin copy. Skip that confirmation for publisher EdgeEver plugins; community plugins still get the one-time warning.
73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
import { describe, expect, test } from "bun:test";
|
|
import {
|
|
acknowledgePluginTrustWarning,
|
|
hasAcknowledgedPluginTrustWarning,
|
|
PLUGIN_TRUST_ACKNOWLEDGEMENT_STORAGE_KEY,
|
|
PLUGIN_TRUST_WARNING_COPY,
|
|
shouldRequestPluginTrustAcknowledgement,
|
|
} from "./plugin-trust.ts";
|
|
|
|
describe("plugin trust acknowledgement", () => {
|
|
test("uses a versioned key so materially changed copy can be acknowledged again", () => {
|
|
expect(PLUGIN_TRUST_ACKNOWLEDGEMENT_STORAGE_KEY).toEndWith(String(PLUGIN_TRUST_WARNING_COPY.version));
|
|
});
|
|
|
|
test("persists a one-time acknowledgement", () => {
|
|
const values = new Map();
|
|
const storage = {
|
|
getItem: (key) => values.get(key) ?? null,
|
|
setItem: (key, value) => values.set(key, value),
|
|
};
|
|
|
|
expect(hasAcknowledgedPluginTrustWarning(storage)).toBe(false);
|
|
acknowledgePluginTrustWarning(storage);
|
|
expect(hasAcknowledgedPluginTrustWarning(storage)).toBe(true);
|
|
});
|
|
|
|
test("falls back to asking again when browser storage is unavailable", () => {
|
|
const storage = {
|
|
getItem: () => { throw new Error("blocked"); },
|
|
setItem: () => { throw new Error("blocked"); },
|
|
};
|
|
|
|
expect(hasAcknowledgedPluginTrustWarning(storage)).toBe(false);
|
|
expect(() => acknowledgePluginTrustWarning(storage)).not.toThrow();
|
|
});
|
|
|
|
test("asks only before the first community client-plugin enable", () => {
|
|
expect(shouldRequestPluginTrustAcknowledgement({
|
|
acknowledged: false,
|
|
enabled: true,
|
|
extensionType: "plugin",
|
|
isOfficial: false,
|
|
})).toBe(true);
|
|
expect(shouldRequestPluginTrustAcknowledgement({
|
|
acknowledged: true,
|
|
enabled: true,
|
|
extensionType: "plugin",
|
|
isOfficial: false,
|
|
})).toBe(false);
|
|
expect(shouldRequestPluginTrustAcknowledgement({
|
|
acknowledged: false,
|
|
enabled: false,
|
|
extensionType: "plugin",
|
|
isOfficial: false,
|
|
})).toBe(false);
|
|
expect(shouldRequestPluginTrustAcknowledgement({
|
|
acknowledged: false,
|
|
enabled: true,
|
|
extensionType: "theme",
|
|
isOfficial: false,
|
|
})).toBe(false);
|
|
});
|
|
|
|
test("does not treat official plugins as community plugins", () => {
|
|
expect(shouldRequestPluginTrustAcknowledgement({
|
|
acknowledged: false,
|
|
enabled: true,
|
|
extensionType: "plugin",
|
|
isOfficial: true,
|
|
})).toBe(false);
|
|
});
|
|
});
|