Assessor_2.0/tests/fixtures/client-info-design/preview.tsx

64 lines
4.1 KiB
TypeScript

// Isolated visual fixture. The build aliases AppProvider to this module; no
// application provider, saved workspace, backend or customer data is loaded.
import { createRoot } from 'react-dom/client';
import { DashboardPanel } from '../../../src/features/dashboard/DashboardPanel';
import { AssessorApiClient } from '../../../src/api/assessor-api-client';
import { genericProfile } from '../../../src/profiles/generic/generic-profile';
import { makeSheet } from '../../../src/importers/sheet-factory';
import { initialAppState } from '../../../src/app/app-state';
import { defaultReview } from '../../../src/domain/review';
import { appendRiskAcceptanceReview } from '../../../src/domain/risk-acceptance';
import { riskCommand } from '../../domain/risk-acceptance-fixture';
import '@fontsource-variable/inter/wght.css';
import '../../../src/styles/layers.css';
import '../../../src/styles/ui-tokens.css';
import '../../../src/styles/tokens.css';
import '../../../src/styles/base.css';
import '../../../src/styles/layout.css';
import '../../../src/styles/components.css';
import '../../../src/styles/dynamic-filters.css';
import '../../../src/styles/datahub.css';
import '../../../src/styles/datahub-redesign.css';
import '../../../src/styles/policy-analysis.css';
import '../../../src/styles/policy-analysis-actions.css';
import '../../../src/styles/import-workflow.css';
import '../../../src/styles/legacy-views.css';
import '../../../src/styles/obsidian-graph.css';
import '../../../src/styles/functional-icons.css';
import '../../../src/styles/tile-contract.css';
import './preview.css';
const titles = ['Inactive account', 'Privileged administrator', 'MFA disabled', 'Certificate expired',
'Firewall disabled', 'GPO password policy', 'Cloud application exposed', 'Backup unavailable'];
const sources = ['PingCastle', 'Purple Knight', 'Maester', 'CIS-CAT', 'GPOs'];
const rows = Array.from({ length: 120 }, (_, index) => [titles[index % titles.length],
index % 11 === 0 ? 'Not Run' : index % 3 === 0 ? 'Pass' : 'Fail',
index % 5 === 4 ? 'GPOs' : 'Synthetic', index % 13 === 0 ? 'Critical' : 'High', sources[index % sources.length]]);
const sheet = makeSheet('All Records', [['Title', 'Status', 'Category', 'Severity', 'Source: Scan'], ...rows], '', 'Synthetic', { isProjectSheet: true });
const reviews = Object.fromEntries(sheet.analysis.records.slice(0, 2).map(record => [record.id, {
...defaultReview(), riskAcceptance: appendRiskAcceptanceReview(undefined, record.id,
riskCommand('accept'), new Date().toISOString()).riskAcceptance
}]));
const app = { ...initialAppState, dataset: { fileName: 'Synthetic design verification', profileId: 'generic', sheets: [sheet] },
activeSheet: sheet, activeProfile: genericProfile, reviews, facetFilters: {}, targetProjectId: 'synthetic-design',
backendStatus: 'connected', activeAssessmentIds: ['synthetic-slot'], activeScanRunIds: [],
setStatusFilter() {}, setFacetFilter() {}, setPathFindingIds() {}, resetFilters() {}, setView() {}, setActionOnly() {}, setActiveSheet() {}, openProject() {}
};
export function useApp() { return app; }
// No real API request is possible from this fixture, even on an unexpected path.
globalThis.fetch = async () => { throw new Error('Network forbidden in synthetic Client Info fixture'); };
Object.assign(AssessorApiClient.prototype, {
async getEnvironmentSnapshot() {
return { projectId: 'synthetic-design', observations: [
['domain.count', 1], ['domain.fqdn', 'synthetic.example'], ['domain.controller_count', 2], ['entra.tenant_count', 1]
].map(([property, value]) => ({ property, label: property, normalizedValue: value, originalValue: value,
state: 'observed', source: {}, tool: { name: 'Synthetic' } })), sections: [], coverage: {} };
},
async listProjectGpoBackupStatus() { return { records: [] }; },
async listProjectAssessmentHistory() { return { assessments: [], scanRuns: [] }; },
async listProjectImportFiles() { return []; }
});
document.documentElement.dataset.theme = new URLSearchParams(location.search).get('theme') ?? 'light';
createRoot(document.getElementById('root')!).render(<DashboardPanel onOpenWork={() => {}}/>);