72 lines
4.5 KiB
JavaScript
72 lines
4.5 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, /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('<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(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, /<ModuleSubnav/);
|
|
assert.match(createBranch, /className="scheduling-create-subnav"/);
|
|
assert.doesNotMatch(browseBranch, /scheduling-sidebar|<aside/);
|
|
|
|
assert.match(browseBranch, /<h1>\{I18N\.requests\}<\/h1>/);
|
|
assert.match(browseBranch, /<Plus aria-hidden="true" size=\{16\} \/> \{I18N\.add\}/);
|
|
assert.match(page, /title=\{I18N\.myRequests\}/);
|
|
assert.match(page, /title=\{I18N\.invitedRequests\}/);
|
|
assert.match(createBranch, /<Card title=\{I18N\.basicInformation\}>/);
|
|
assert.match(createBranch, /<Card title=\{I18N\.calendarIntegration\}>/);
|
|
assert.match(page, /<Card title=\{I18N\.candidateSlots\}>/);
|
|
assert.match(page, /<Card title=\{I18N\.participants\}>/);
|
|
assert.match(createBranch, /<ToggleSwitch[\s\S]*checked=\{calendarEnabled\}/);
|
|
assert.match(page, /<ToggleSwitch[\s\S]*checked=\{participantRosterVisible\}/);
|
|
assert.match(page, /participant_visibility: participantRosterVisible \? "names_and_statuses" : "aggregates_only"/);
|
|
assert.match(page, /id="scheduling-create-candidate-slots-grid"/);
|
|
assert.match(page, /id="scheduling-create-participants-grid"/);
|
|
assert.match(page, /id="scheduling-candidate-slots-grid"/);
|
|
assert.match(page, /id="scheduling-participants-grid"/);
|
|
assert.match(page, /<DataGridRowActions/);
|
|
assert.match(page, /<DataGridEmptyAction/);
|
|
assert.doesNotMatch(page, /EmailAddressInput|MailboxAddress|addressSuggestions|addressLookupQuery/);
|
|
assert.match(page, /type="email"[\s\S]*aria-label=\{I18N\.participantEmail\}/);
|
|
assert.doesNotMatch(page, /header: I18N\.required|<table|scheduling-table|scheduling-card(?:\s|"|`)/);
|
|
assert.match(page, /<TableActionGroup[\s\S]*label: i18nMessage\("i18n:govoplan-scheduling\.decide_on_value/);
|
|
assert.match(page, /submitSchedulingAvailability\(settings, selected\.id/);
|
|
assert.match(page, /option_revision: slot\.revision/);
|
|
assert.match(page, /getSchedulingAvailabilityResponse\(settings, selected\.id\)/);
|
|
assert.match(page, /setAvailability\(Object\.fromEntries\(response\.answers\.map/);
|
|
assert.match(page, /selected\.participant_aggregate\.total/);
|
|
assert.match(page, /selected\.effective_participant_visibility === "names_and_statuses"/);
|
|
assert.match(api, /participant_visibility: SchedulingParticipantVisibility/);
|
|
assert.match(api, /participant_aggregate: SchedulingParticipantAggregate/);
|
|
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/);
|
|
assert.match(api, /\/api\/v1\/scheduling\/requests\/\$\{requestId\}\/responses\/me/);
|
|
|
|
console.log("Scheduling page structure satisfies the focused list/create/respond contract.");
|