diff --git a/webui/package.json b/webui/package.json index 7a64c66..694ed89 100644 --- a/webui/package.json +++ b/webui/package.json @@ -13,6 +13,10 @@ }, "./styles/scheduling.css": "./src/styles/scheduling.css" }, + "scripts": { + "test:view-model": "node --experimental-strip-types --test tests/scheduling-view-model.test.ts", + "test:ui-structure": "node scripts/test-scheduling-page-structure.mjs" + }, "peerDependencies": { "@govoplan/core-webui": "^0.1.8", "lucide-react": "^1.23.0", diff --git a/webui/scripts/test-scheduling-page-structure.mjs b/webui/scripts/test-scheduling-page-structure.mjs new file mode 100644 index 0000000..1135ad0 --- /dev/null +++ b/webui/scripts/test-scheduling-page-structure.mjs @@ -0,0 +1,34 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; + +const pagePath = fileURLToPath(new URL("../src/features/scheduling/SchedulingPage.tsx", import.meta.url)); +const apiPath = fileURLToPath(new URL("../src/api/scheduling.ts", import.meta.url)); +const page = readFileSync(pagePath, "utf8"); +const api = readFileSync(apiPath, "utf8"); + +assert.match(page, /usePlatformUiCapability\("calendar\.picker"\)/); +assert.match(page, /hasScope\(auth, "calendar:calendar:read"\)/); +assert.match(page, /Boolean\(calendarPickerCapability\) && canReadCalendars && canReadAvailability && canWriteCalendarEvent/); +assert.doesNotMatch(page, /@govoplan\/calendar-webui|govoplan-calendar\/webui/); +assert.match(page, /className="scheduling-full-editor"/); +assert.match(page, /className="scheduling-page-actions"/); + +const editorActions = page.slice( + page.indexOf('
'), + page.indexOf('
', page.indexOf('
')) +); +assert.ok(editorActions.indexOf("I18N.discard") < editorActions.indexOf("I18N.save")); +assert.match(page, /