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, /Card,[\s\S]*DataGrid,[\s\S]*DataGridEmptyAction,[\s\S]*DataGridRowActions,[\s\S]*ModuleSubnav,[\s\S]*ToggleSwitch,[\s\S]*from "@govoplan\/core-webui"/); assert.doesNotMatch(page, /@govoplan\/core-webui\/src\//); 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(editorActions, /form="scheduling-create-form"/); const createBranchStart = page.indexOf(" if (creating) {"); const createReturnStart = page.indexOf("\n return (", createBranchStart); const browseBranchStart = page.indexOf("\n return (", createReturnStart + 1); const createBranch = page.slice(createBranchStart, browseBranchStart); const browseBranch = page.slice(browseBranchStart); assert.match(createBranch, /\{I18N\.requests\}<\/h1>/); assert.match(browseBranch, /