Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion frontend/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@testing-library/jest-dom';

function createStorageMock() {
const store = new Map<string, string>();
return {
const handler = {
getItem: (key: string) => (store.has(key) ? store.get(key)! : null),
setItem: (key: string, value: string) => {
store.set(key, String(value));
Expand All @@ -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') {
Expand Down
7 changes: 3 additions & 4 deletions testing/backend/test_crawler_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading