fix: close plugin workspace acceptance gaps

This commit is contained in:
2026-09-03 14:29:21 +08:00
parent 1b1f206dd8
commit c5020ae22c
10 changed files with 885 additions and 53 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
parsePluginWorkspaceSearch,
resolvePluginWorkspaceSearch,
serializePluginWorkspaceSearch,
} from '@/pages/Plugins/plugin-workspace-query';
@@ -22,6 +23,30 @@ describe('plugin workspace URL state', () => {
expect(parsePluginWorkspaceSearch(new URLSearchParams('scope=project'), false).scope).toBe('all');
});
it('reports a project-scope fallback while returning the exact canonical URL state', () => {
const fallback = resolvePluginWorkspaceSearch(
new URLSearchParams('scope=project&source=remote&state=broken'),
false,
);
expect(fallback).toEqual({
filters: {
scope: 'all', source: 'all', state: 'all', search: '', selectedKey: null,
},
canonicalSearch: 'scope=all&source=all&state=all',
scopeFallback: true,
});
const afterProjectAppears = resolvePluginWorkspaceSearch(new URLSearchParams(), true);
expect(afterProjectAppears).toEqual({
filters: {
scope: 'project', source: 'all', state: 'all', search: '', selectedKey: null,
},
canonicalSearch: 'scope=project&source=all&state=all',
scopeFallback: false,
});
});
it('round-trips canonical filters and source-qualified selection', () => {
const serialized = serializePluginWorkspaceSearch({
scope: 'all',