Files
govoplan-access/webui/scripts/test-interface-pattern-language.mjs
T

73 lines
3.5 KiB
JavaScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
const root = resolve(import.meta.dirname, "..");
const read = (path) => readFileSync(resolve(root, path), "utf8");
const adminPage = read("src/features/admin/AdminPage.tsx");
const users = read("src/features/admin/UsersPanel.tsx");
const groups = read("src/features/admin/GroupsPanel.tsx");
const roles = read("src/features/admin/RolesPanel.tsx");
const systemUsers = read("src/features/admin/SystemUsersPanel.tsx");
const systemRoles = read("src/features/admin/SystemRolesPanel.tsx");
const apiKeys = read("src/features/admin/ApiKeysPanel.tsx");
const serviceAccounts = read("src/features/admin/ServiceAccountsPanel.tsx");
const mappings = read("src/features/admin/ExternalFunctionRoleMappingsPanel.tsx");
const credentials = read("src/features/admin/CredentialEnvelopesPanel.tsx");
const files = read("src/features/admin/FileConnectorsPanel.tsx");
const mail = read("src/features/admin/MailProfilesPanel.tsx");
const moduleSource = read("src/module.ts");
const sessions = read("src/features/sessions/SessionSettingsPanel.tsx");
const surfaces = [users, groups, roles, systemUsers, systemRoles, apiKeys, mappings];
const allAdminSource = [adminPage, credentials, files, mail, serviceAccounts, ...surfaces].join("\n");
assert.match(adminPage, /TreeSubnav/);
assert.match(adminPage, /ActionBlockerHint/);
assert.match(adminPage, /ACCESS_WORKFLOW_DOCUMENTATION/);
for (const source of surfaces) {
assert.match(source, /AdminPageLayout/);
assert.match(source, /DataGrid/);
assert.match(source, /DocumentationHelpLink/);
assert.match(source, /disabledReason/);
}
for (const source of [users, groups, roles, systemUsers, systemRoles, apiKeys, mappings]) {
assert.match(source, /ConfirmDialog/);
}
assert.match(credentials, /CredentialEnvelopeManager/);
assert.match(credentials, /DocumentationHelpLink/);
assert.match(files, /usePlatformUiCapability<FilesConnectorsUiCapability>/);
assert.match(files, /ActionBlockerHint/);
assert.match(mail, /usePlatformUiCapability<MailProfilesUiCapability>/);
assert.match(mail, /ActionBlockerHint/);
assert.match(serviceAccounts, /Service accounts/);
assert.match(serviceAccounts, /createServiceAccountCredential/);
assert.match(serviceAccounts, /rotateServiceAccountCredential/);
assert.match(serviceAccounts, /revokeServiceAccountCredential/);
assert.match(serviceAccounts, /Secrets are shown once/);
assert.match(serviceAccounts, /<ConfirmDialog[\s\S]*Retire service account/);
assert.match(moduleSource, /access\.admin\.tenant-service-accounts/);
assert.match(moduleSource, /access\.settings\.sessions/);
assert.match(moduleSource, /"settings\.sections": accessSettingsSections/);
assert.match(sessions, /PageActionBar/);
assert.match(sessions, /reloadAction/);
assert.match(sessions, /destructiveActions/);
assert.match(sessions, /DataGrid/);
assert.match(sessions, /ConfirmDialog/);
assert.doesNotMatch(sessions, /window\.(alert|confirm|prompt)\s*\(/);
assert.match(users, /fetchAdminUserSessions/);
assert.match(users, /revokeAdminUserSession/);
assert.match(users, /admin-user-sessions-v1/);
assert.match(users, /PasswordField/);
assert.match(users, /canRevokeSessions/);
assert.match(moduleSource, /translations,/);
assert.match(moduleSource, /version: "0\.1\.11"/);
assert.doesNotMatch(allAdminSource, /window\.(alert|confirm|prompt)\s*\(/);
assert.doesNotMatch(allAdminSource, /@govoplan\/(files|mail|organizations|idm)-webui\//);
console.log("Access interface pattern-language checks passed.");