35 lines
2.0 KiB
JavaScript
35 lines
2.0 KiB
JavaScript
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<CalendarPickerUiCapability>\("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('<div className="scheduling-page-actions">'),
|
|
page.indexOf('</div>', page.indexOf('<div className="scheduling-page-actions">'))
|
|
);
|
|
assert.ok(editorActions.indexOf("I18N.discard") < editorActions.indexOf("I18N.save"));
|
|
assert.match(page, /<Plus aria-hidden="true" size=\{16\} \/> \{I18N\.addRequest\}/);
|
|
assert.match(page, /title=\{I18N\.myRequests\}/);
|
|
assert.match(page, /title=\{I18N\.invitedRequests\}/);
|
|
assert.match(page, /className="scheduling-table-actions"/);
|
|
assert.match(page, /aria-label=\{i18nMessage\("i18n:govoplan-scheduling\.decide_on_value/);
|
|
assert.match(page, /submitSchedulingAvailability\(settings, selected\.id/);
|
|
assert.doesNotMatch(page, /<p>\{selected\.calendar_id\}<\/p>/);
|
|
assert.match(page, /className="scheduling-selected-calendar"/);
|
|
assert.match(page, /showPlanningCalendarActions/);
|
|
assert.match(page, /title=\{!canReadAvailability \? I18N\.requiresAvailabilityRead/);
|
|
assert.match(api, /\/api\/v1\/scheduling\/requests\/\$\{requestId\}\/responses/);
|
|
|
|
console.log("Scheduling page structure satisfies the focused list/create/respond contract.");
|