Add cross-browser popup status handling
This commit is contained in:
parent
9c65a61ebb
commit
7e17470356
38 changed files with 1242 additions and 199 deletions
30
tests/site-definitions.test.ts
Normal file
30
tests/site-definitions.test.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { BUILTIN_DEFINITIONS, effectiveDefinitions } from "../src/content/definitions";
|
||||
import { validateDefinitionConfiguration } from "../src/shared/site-definitions";
|
||||
|
||||
const customDefinition = {
|
||||
id: "example-social",
|
||||
name: "Example Social",
|
||||
urlPatterns: ["https://*.example.test/*"],
|
||||
requiredSelectors: [".feed"],
|
||||
post: { rootSelectors: ["article"], textSelectors: [".content"], idAttributes: ["data-id"] }
|
||||
};
|
||||
|
||||
describe("site definitions", () => {
|
||||
it("accepts declarative custom definitions and deduplicates disabled IDs", () => {
|
||||
const result = validateDefinitionConfiguration({ customDefinitions: [customDefinition], disabledDefinitionIds: ["mastodon", "mastodon"] });
|
||||
expect(result.valid).toBe(true);
|
||||
if (result.valid) expect(result.value.disabledDefinitionIds).toEqual(["mastodon"]);
|
||||
});
|
||||
|
||||
it("rejects executable or malformed definition fields", () => {
|
||||
const result = validateDefinitionConfiguration({ customDefinitions: [{ ...customDefinition, id: "Bad ID", post: { ...customDefinition.post, rootSelectors: ["["] } }], disabledDefinitionIds: [] });
|
||||
expect(result.valid).toBe(false);
|
||||
});
|
||||
|
||||
it("lets a custom definition replace a bundled definition by ID", () => {
|
||||
const override = { ...BUILTIN_DEFINITIONS[0]!, name: "Custom Mastodon" };
|
||||
const definitions = effectiveDefinitions([override], []);
|
||||
expect(definitions.filter((definition) => definition.id === "mastodon")).toEqual([override]);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue