Files
govoplan-access/webui/scripts/test-interface-pattern-language.mjs
zemion 2d1b1e356e
Module Package Release / publish-packages (push) Successful in 12s
docs(access): add credential lifecycle contextual help
2026-08-21 21:14:31 +02:00

100 lines
4.4 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/);
for (const contextId of [
"access.api-keys.action.create",
"access.api-keys.action.revoke",
"access.api-keys.field.owner",
"access.api-keys.field.expiry",
"access.api-keys.field.scopes",
"access.api-keys.secret",
"access.api-keys.confirm-revoke"
]) {
assert.ok(apiKeys.includes(contextId), `API-key help context ${contextId} is missing`);
}
for (const contextId of [
"access.service-accounts.action.create",
"access.service-accounts.action.activation",
"access.service-accounts.action.retire",
"access.service-accounts.field.scope-ceiling",
"access.service-accounts.action.rotate-credential",
"access.service-accounts.action.revoke-credential",
"access.service-accounts.field.credential-expiry",
"access.service-accounts.field.credential-scopes",
"access.service-accounts.secret",
"access.service-accounts.confirm-retire"
]) {
assert.ok(serviceAccounts.includes(contextId), `Service-account help context ${contextId} is missing`);
}
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.");