diff --git a/frontend/vitest.setup.ts b/frontend/vitest.setup.ts index 7a7a6f7b..507ae012 100644 --- a/frontend/vitest.setup.ts +++ b/frontend/vitest.setup.ts @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; function createStorageMock() { const store = new Map(); - return { + const handler = { getItem: (key: string) => (store.has(key) ? store.get(key)! : null), setItem: (key: string, value: string) => { store.set(key, String(value)); @@ -18,6 +18,37 @@ function createStorageMock() { return store.size; }, }; + + return new Proxy(handler, { + get(target, prop) { + if (prop === 'length') { + return store.size; + } + if (typeof prop === 'string' && !isNaN(Number(prop))) { + return Array.from(store.entries())[Number(prop)]?.[1] ?? null; + } + if (prop in target) { + return (target as any)[prop]; + } + return store.get(String(prop)) ?? null; + }, + ownKeys() { + return Array.from(store.keys()); + }, + getOwnPropertyDescriptor(target, prop) { + if (store.has(String(prop))) { + return { + configurable: true, + enumerable: true, + value: store.get(String(prop)), + }; + } + if (prop in target) { + return Object.getOwnPropertyDescriptor(target, prop); + } + return undefined; + }, + }); } if (!window.localStorage || typeof window.localStorage.getItem !== 'function') { diff --git a/testing/backend/test_crawler_plugin.py b/testing/backend/test_crawler_plugin.py index 70419e84..93ef65d9 100644 --- a/testing/backend/test_crawler_plugin.py +++ b/testing/backend/test_crawler_plugin.py @@ -87,11 +87,10 @@ def test_crawler_target_field_requires_http_url(): data = json.loads((PLUGIN_DIR / "metadata.json").read_text(encoding="utf-8")) fields = {f["id"]: f for f in data["fields"]} target_validation = fields["target"].get("validation", {}) - uses_preset = target_validation.get("validation_type") == "url" - uses_pattern = "https?" in target_validation.get("pattern", "") or \ - "http" in target_validation.get("pattern", "") - assert uses_preset or uses_pattern, \ + pattern = target_validation.get("pattern", "") + assert "https?" in pattern or "http" in pattern, ( "target field must validate for HTTP(S) URL format" + ) def test_crawler_has_optional_depth_field_with_default():