Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Prefer fallback meshes for analytic faces

Yuechen Li8fd42994ba30
diff --git a/aetheris.client/src/__tests__/displayRenderables.test.ts b/aetheris.client/src/__tests__/displayRenderables.test.ts
index 2863b21a..3b74fcdb 100644
--- a/aetheris.client/src/__tests__/displayRenderables.test.ts
+++ b/aetheris.client/src/__tests__/displayRenderables.test.ts
@@ -66,4 +66,114 @@ describe('DisplayIRMapper', () => {
expect(scene?.displayAuthority).toBe('DisplayIR');
expect(scene?.status).toBe('Partial');
});
+
+ it('PrefersFallbackMeshForAnalyticPlanesWithInnerLoops', () => {
+ const scene = mapDisplayPreparationToDisplayScene({
+ ...prepWithFaces([
+ {
+ faceId: 8,
+ shellId: 1,
+ surfaceKind: 'Plane',
+ status: 'Analytic',
+ patchKind: 'AnalyticPatch',
+ materializationLane: 'AnalyticPatch',
+ diagnostics: [],
+ wirePatch: null,
+ meshPatch: null,
+ analyticPatch: {
+ faceId: 8,
+ shellId: 1,
+ shellRole: 'Outer',
+ surfaceGeometryId: 10,
+ surfaceKind: 'Plane',
+ loopCount: 3,
+ domainHint: null,
+ cylinderGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: null,
+ torusGeometry: null,
+ planeGeometry: {
+ origin: { x: 0, y: 0, z: 0 },
+ normal: { x: 0, y: 0, z: 1 },
+ uAxis: { x: 1, y: 0, z: 0 },
+ vAxis: { x: 0, y: 1, z: 0 },
+ outerBoundary: [{ x: 0, y: 0, z: 0 }, { x: 4, y: 0, z: 0 }, { x: 4, y: 4, z: 0 }, { x: 0, y: 4, z: 0 }],
+ },
+ },
+ },
+ ]),
+ tessellationFallback: {
+ facePatches: [
+ {
+ faceId: 8,
+ positions: [{ x: 0, y: 0, z: 0 }, { x: 4, y: 0, z: 0 }, { x: 4, y: 4, z: 0 }],
+ normals: [{ x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: 1 }],
+ triangleIndices: [0, 1, 2],
+ },
+ ],
+ edgePolylines: [],
+ },
+ });
+
+ expect(scene?.renderables).toHaveLength(1);
+ expect(scene?.renderables[0].kind).toBe('MeshPatch');
+ expect(scene?.renderables[0].patchKind).toBe('MeshPatch');
+ expect(scene?.renderables[0].materializationLane).toBe('BoundedMesh');
+ expect(scene?.renderables[0].status).toBe('Mesh');
+ });
+
+ it('PrefersFallbackMeshForAnalyticCylindersWhenAvailable', () => {
+ const scene = mapDisplayPreparationToDisplayScene({
+ ...prepWithFaces([
+ {
+ faceId: 12,
+ shellId: 1,
+ surfaceKind: 'Cylinder',
+ status: 'Analytic',
+ patchKind: 'AnalyticPatch',
+ materializationLane: 'AnalyticPatch',
+ diagnostics: [],
+ wirePatch: null,
+ meshPatch: null,
+ analyticPatch: {
+ faceId: 12,
+ shellId: 1,
+ shellRole: 'Outer',
+ surfaceGeometryId: 14,
+ surfaceKind: 'Cylinder',
+ loopCount: 1,
+ domainHint: { minV: 0, maxV: 2 },
+ planeGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: null,
+ torusGeometry: null,
+ cylinderGeometry: {
+ origin: { x: 0, y: 0, z: 0 },
+ axis: { x: 0, y: 0, z: 1 },
+ xAxis: { x: 1, y: 0, z: 0 },
+ yAxis: { x: 0, y: 1, z: 0 },
+ radius: 1,
+ },
+ },
+ },
+ ]),
+ tessellationFallback: {
+ facePatches: [
+ {
+ faceId: 12,
+ positions: [{ x: 1, y: 0, z: 0 }, { x: 0, y: 1, z: 0 }, { x: 1, y: 0, z: 2 }],
+ normals: [{ x: 1, y: 0, z: 0 }, { x: 0, y: 1, z: 0 }, { x: 1, y: 0, z: 0 }],
+ triangleIndices: [0, 1, 2],
+ },
+ ],
+ edgePolylines: [],
+ },
+ });
+
+ expect(scene?.renderables).toHaveLength(1);
+ expect(scene?.renderables[0].kind).toBe('MeshPatch');
+ expect(scene?.renderables[0].patchKind).toBe('MeshPatch');
+ expect(scene?.renderables[0].materializationLane).toBe('BoundedMesh');
+ expect(scene?.renderables[0].status).toBe('Mesh');
+ });
});
diff --git a/aetheris.client/src/viewer/displayRenderables.ts b/aetheris.client/src/viewer/displayRenderables.ts
index 347acf67..ecf558e8 100644
--- a/aetheris.client/src/viewer/displayRenderables.ts
+++ b/aetheris.client/src/viewer/displayRenderables.ts
@@ -69,12 +69,44 @@ function wireEdges(face: DisplayFaceDto): RenderEdgePolyline[] {
})) ?? [];
}
-export function mapDisplayFaceToRenderable(face: DisplayFaceDto): DisplayRenderable {
+function analyticPreviewNeedsFallbackMesh(face: DisplayFaceDto): boolean {
+ if (!face.analyticPatch) {
+ return false;
+ }
+
+ if (face.analyticPatch.surfaceKind === 'Plane') {
+ return face.analyticPatch.loopCount > 1;
+ }
+
+ return face.analyticPatch.surfaceKind === 'Cylinder'
+ || face.analyticPatch.surfaceKind === 'Cone';
+}
+
+function analyticFallbackMeshRenderable(face: DisplayFaceDto, fallbackMesh: RenderFacePatch): MeshRenderable {
+ return {
+ ...base(face),
+ kind: 'MeshPatch',
+ status: 'Mesh',
+ patchKind: 'MeshPatch',
+ materializationLane: 'BoundedMesh',
+ mesh: fallbackMesh,
+ };
+}
+
+export function mapDisplayFaceToRenderable(face: DisplayFaceDto, fallbackMesh: RenderFacePatch | null = null): DisplayRenderable {
if (face.patchKind === 'AnalyticPatch' && face.analyticPatch) {
+ if (fallbackMesh && analyticPreviewNeedsFallbackMesh(face)) {
+ return analyticFallbackMeshRenderable(face, fallbackMesh);
+ }
+
const previewMesh = analyticPatchToPreviewMesh(face.analyticPatch);
if (previewMesh) {
return { ...base(face), kind: 'AnalyticPatch', previewMesh };
}
+
+ if (fallbackMesh) {
+ return analyticFallbackMeshRenderable(face, fallbackMesh);
+ }
}
if ((face.patchKind === 'MeshPatch' || face.materializationLane === 'BoundedMesh') && face.meshPatch) {
@@ -90,12 +122,17 @@ export function mapDisplayFaceToRenderable(face: DisplayFaceDto): DisplayRendera
export function mapDisplayPreparationToDisplayScene(preparation: DisplayPreparationResponseDto | null): DisplayScene | null {
if (!preparation) return null;
+ const fallbackMeshByFaceId = new Map(
+ (preparation.tessellationFallback?.facePatches ?? [])
+ .map((patch) => [patch.faceId, mapFacePatchToRenderFacePatch(patch)]),
+ );
+
return {
status: preparation.status ?? null,
sourceAuthority: preparation.sourceAuthority ?? null,
displayAuthority: preparation.displayAuthority ?? null,
lanes: preparation.displayLanes ?? [],
- renderables: (preparation.faces ?? []).map(mapDisplayFaceToRenderable),
+ renderables: (preparation.faces ?? []).map((face) => mapDisplayFaceToRenderable(face, fallbackMeshByFaceId.get(face.faceId) ?? null)),
diagnostics: preparation.diagnostics ?? [],
};
}
diff --git a/docs/display-corruption-x1-ctc01-visual-house-call.md b/docs/display-corruption-x1-ctc01-visual-house-call.md
new file mode 100644
index 00000000..d56b1a34
--- /dev/null
+++ b/docs/display-corruption-x1-ctc01-visual-house-call.md
@@ -0,0 +1,243 @@
+# DISPLAY-CORRUPTION-X1 — CTC-01 visual house call
+
+## 1. Purpose and scope
+
+Diagnose the severe local Aetheris Cadmata display corruption reported for the CTC-01 AP242 fixture, prove the failing layer, and land the smallest safe fix that makes the imported model visually recognizable again without changing STEP import/export semantics, BRep topology, or server authority.
+
+## 2. User-observed symptom
+
+User report for CTC-01:
+
+- Aetheris displayed the model as exploded / fragmented.
+- Many cylindrical strip-like pieces were visible.
+- A large dark incorrect face mass dominated the body.
+- The result was not recognizable as the expected bracket.
+- SolidWorks displayed the same STEP file as a coherent bracket / plate with holes, slots, rounded ends, and a center block.
+
+## 3. Exact CTC-01 file tested
+
+- `testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp`
+
+## 4. Commands run
+
+```powershell
+dotnet restore Aetheris.slnx
+dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1
+
+dotnet run --project Aetheris.CLI -f net10.0 -- analyze testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp --json
+dotnet run --project Aetheris.CLI -f net10.0 -- canon testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp --out artifacts/display-corruption-x1/nist_ctc_01_canonical.step --json
+
+node scripts/display-corruption-x1-playwright.mjs
+
+cd aetheris.client
+npm run build
+npm test -- --run App.test.tsx displayRenderables.test.ts AetherisViewport.test.tsx displaySceneBuilder.test.ts displaySceneBounds.test.ts
+
+dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "DisplayIR|BoundedMesh|WirePatch|DisplayPrepare|ViewMaterialization|Tessellation|CTC01|Ctc01|Ctc" --logger "console;verbosity=minimal"
+dotnet test Aetheris.Server.Tests/Aetheris.Server.Tests.csproj -f net10.0 --no-build --filter "DisplayIR|BoundedMesh|WirePatch|DisplayPrepare|KernelApi|ViewMaterialization|Tessellate|Tessellation|StepIo|CTC01|Ctc01|Ctc" --logger "console;verbosity=minimal"
+
+dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "Step242Ftc06SameSenseRegressionTests|FTC06|Ftc06|same_sense" --logger "console;verbosity=minimal"
+dotnet run --project Aetheris.CLI -f net10.0 -- analyze testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp --json
+```
+
+## 5. Backend import/export result
+
+Artifacts:
+
+- [ctc01-analyze.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-analyze.json)
+- [ctc01-canon.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-canon.json)
+- [nist_ctc_01_canonical.step](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/nist_ctc_01_canonical.step)
+
+Observed:
+
+- `analyze` succeeded.
+- `canon` succeeded.
+- Topology counts were plausible for a single enclosed body:
+ - `bodyCount=1`
+ - `shellCount=1`
+ - `faceCount=117`
+ - `edgeCount=318`
+ - `vertexCount=206`
+ - bounds `[-400,-225,-100]` to `[400,225,50]`
+- Surface family mix was plausible:
+ - `plane=56`
+ - `cylinder=57`
+ - `cone=4`
+
+Conclusion:
+
+- No evidence that the failure originates in STEP/AP242 import.
+- No evidence that canonical export is failing for this house call.
+- The imported body is structurally plausible and bounded.
+
+## 6. DisplayIR server result
+
+Artifacts:
+
+- [ctc01-import.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-import.json)
+- [ctc01-display-prepare.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-display-prepare.json)
+- [ctc01-display-summary.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-display-summary.json)
+
+Observed:
+
+- `/import/step` succeeded.
+- `/display/prepare` succeeded with `status=Complete`.
+- `displayAuthority=DisplayIR`, `sourceAuthority=BRep`.
+- Lane summary:
+ - `AnalyticPatch`: `99` faces, `Complete`
+ - `BoundedMesh`: `18` faces, `Complete`
+- Per-face records were finite and diagnostic-free for this case.
+- The fallback tessellation payload was more complete than the face-level lane summary implied:
+ - `tessellationFallback.facePatches = 117`
+ - `tessellationFallback.edgePolylines = 318`
+
+Important evidence:
+
+- The server already emitted an accurate bounded fallback mesh for every face.
+- Several analytic plane faces had inner loops:
+ - face ids `3, 15, 48, 50, 55, 56, 98`
+- Those are exactly the kinds of faces the existing frontend analytic preview cannot render faithfully because it triangulates only the outer boundary.
+
+Conclusion:
+
+- The server did not fail to prepare a display packet.
+- The server already provided enough fallback geometry for the frontend to avoid visible corruption.
+
+## 7. Frontend DisplayScene result
+
+Relevant files:
+
+- [displayRenderables.ts](/C:/Users/yuech/source/repos/Aetheris/aetheris.client/src/viewer/displayRenderables.ts)
+- [analyticMapper.ts](/C:/Users/yuech/source/repos/Aetheris/aetheris.client/src/viewer/analyticMapper.ts)
+
+Pre-fix problem:
+
+- The client always preferred typed analytic faces when present.
+- For planes, `analyticMapper.ts` triangulated only `planeGeometry.outerBoundary`, so any inner holes were filled.
+- For cylinders and cones, the analytic preview used only axial `domainHint` and a full `0..2π` revolution preview, which is a lossy representation for trimmed surfaces.
+- The client ignored the already-available per-face bounded fallback mesh in `tessellationFallback` for those faces.
+
+Effect:
+
+- CTC-01 displayed large incorrect planar fills and misleading cylindrical strips even though `/display/prepare` had already provided correct fallback meshes for the same faces.
+
+Fix:
+
+- Keep the typed DisplayIR path authoritative.
+- When a face is emitted as `AnalyticPatch` but the frontend analytic preview is known to be lossy and a same-face bounded mesh exists in `tessellationFallback`, render the fallback mesh for that face instead.
+- Current fallback-selection policy:
+ - planar analytic face with `loopCount > 1`
+ - any analytic `Cylinder`
+ - any analytic `Cone`
+ - any analytic face whose preview mesh cannot be built
+
+This is a targeted render-selection fix, not a return to the legacy mesh-scene primary path.
+
+## 8. UI / Playwright screenshots and findings
+
+Artifacts:
+
+- [ctc01-aetheris-default.png](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-aetheris-default.png)
+- [ctc01-aetheris-status.png](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-aetheris-status.png)
+- [ctc01-aetheris-angle-1.png](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-aetheris-angle-1.png)
+- [ctc01-aetheris-angle-2.png](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-aetheris-angle-2.png)
+- [ctc01-playwright-summary.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-playwright-summary.json)
+- [ctc01-playwright-console.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-playwright-console.json)
+- [ctc01-playwright-pageerrors.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-playwright-pageerrors.json)
+- [ctc01-playwright-requestfailures.json](/C:/Users/yuech/source/repos/Aetheris/artifacts/display-corruption-x1/ctc01-playwright-requestfailures.json)
+
+Observed after the fix:
+
+- The imported shape is recognizable as the expected CTC-01 bracket / plate.
+- Two upright rounded ends are visible.
+- Through-holes and slots are visible.
+- The center protruding block is visible.
+- The severe exploded-strip failure is no longer present.
+- No console or network errors were required to explain the original corruption.
+
+Inspector summary from the fixed UI capture:
+
+- display lane: `mixed-fallback`
+- display status: `Complete`
+- render path: `mixed-fallback`
+- analytic faces: `99`
+- fallback faces: `18`
+
+Note:
+
+- The current inspector “Face count” reflects rendered mesh-face count, not total backend face count. In the fixed capture it reads `70` even though backend topology is still `117` faces.
+
+## 9. Root cause
+
+Classification:
+
+- `AnalyticPatchMappingError`
+
+Exact failing layer:
+
+- frontend DisplayScene / analytic preview selection
+
+Why this layer, not import or server:
+
+- import and canonical export both succeeded with plausible topology
+- `/display/prepare` succeeded and returned a complete typed packet
+- the same packet also contained full fallback tessellation for every face
+- the frontend chose lossy analytic previews over accurate same-face fallback meshes for trimmed planes / cylinders / cones
+
+## 10. Fix applied or blocker
+
+Fix applied.
+
+Files changed:
+
+- [displayRenderables.ts](/C:/Users/yuech/source/repos/Aetheris/aetheris.client/src/viewer/displayRenderables.ts)
+- [displayRenderables.test.ts](/C:/Users/yuech/source/repos/Aetheris/aetheris.client/src/__tests__/displayRenderables.test.ts)
+- [display-corruption-x1-playwright.mjs](/C:/Users/yuech/source/repos/Aetheris/scripts/display-corruption-x1-playwright.mjs)
+
+Fix summary:
+
+- Added a targeted client-side compatibility rule to consume per-face bounded fallback meshes only when the analytic preview path is known to be visually lossy for the current DTO contract.
+- Did not change STEP import/export behavior.
+- Did not change BRep topology.
+- Did not change DisplayIR server authority.
+- Did not rewrite tessellator algorithms.
+- Did not remove legacy compatibility fields.
+
+## 11. Tests added
+
+Added focused regression coverage in [displayRenderables.test.ts](/C:/Users/yuech/source/repos/Aetheris/aetheris.client/src/__tests__/displayRenderables.test.ts):
+
+- `PrefersFallbackMeshForAnalyticPlanesWithInnerLoops`
+- `PrefersFallbackMeshForAnalyticCylindersWhenAvailable`
+
+## 12. Remaining issues
+
+- The underlying analytic DTO contract is still lossy for trimmed curved surfaces because it does not carry angular trim information for cylinders / cones.
+- The analytic planar DTO still exposes only `outerBoundary`, not explicit hole loops.
+- The current fix avoids user-visible corruption by selecting bounded fallback meshes where needed, but it does not expand the analytic patch contract itself.
+- Inspector face-count labeling could be clarified in a later polish pass.
+
+## 13. Recommended next milestone
+
+Recommended next milestone:
+
+- Extend the typed analytic patch contract so trimmed analytic surfaces can be represented faithfully without needing per-face fallback mesh substitution.
+
+Suggested bounded follow-up:
+
+- add explicit trimmed-loop data for planar faces
+- add angular trim intervals or edge-loop-derived trim descriptors for cylinder / cone analytic patches
+- keep the current fallback-selection safeguard until the richer analytic contract is proven
+
+## 14. Non-goals
+
+This house call did not:
+
+- change STEP import semantics
+- change STEP canonical export semantics
+- change AP242 importer/exporter behavior
+- change BRep topology construction
+- change DisplayIR server authority
+- rewrite the tessellator
+- weaken FTC-06 / FTC-07 regression coverage
+- change CAD feature behavior
diff --git a/scripts/display-corruption-x1-playwright.mjs b/scripts/display-corruption-x1-playwright.mjs
new file mode 100644
index 00000000..83b790e4
--- /dev/null
+++ b/scripts/display-corruption-x1-playwright.mjs
@@ -0,0 +1,217 @@
+import fs from 'node:fs/promises';
+import path from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+const repoRoot = path.resolve(__dirname, '..');
+const artifactRoot = path.join(repoRoot, 'artifacts', 'display-corruption-x1');
+const playwrightModuleSpecifier = process.env.AETHERIS_PLAYWRIGHT_MODULE ?? 'playwright';
+
+const clientUrl = process.env.AETHERIS_CLIENT_URL ?? 'https://127.0.0.1:4173/';
+const edgeExecutablePath = process.env.AETHERIS_EDGE_PATH
+ ?? 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe';
+const fixturePath = path.join(repoRoot, 'testdata', 'step242', 'nist', 'CTC', 'nist_ctc_01_asme1_ap242-e1.stp');
+
+function responseArtifactName(url) {
+ if (url.includes('/import/step')) {
+ return 'ctc01-import.json';
+ }
+
+ if (url.includes('/display/prepare')) {
+ return 'ctc01-display-prepare.json';
+ }
+
+ return null;
+}
+
+async function ensureEdgeExists() {
+ await fs.access(edgeExecutablePath);
+}
+
+async function writeJson(targetPath, value) {
+ await fs.writeFile(targetPath, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
+}
+
+async function loadChromium() {
+ const specifier = path.isAbsolute(playwrightModuleSpecifier)
+ ? pathToFileURL(playwrightModuleSpecifier).href
+ : playwrightModuleSpecifier;
+ const module = await import(specifier);
+ return module.chromium;
+}
+
+async function waitForReady(page) {
+ await page.goto(clientUrl, { waitUntil: 'load' });
+ await page.getByRole('status').waitFor({ state: 'visible', timeout: 30000 });
+ await page.getByText('Document: Ready', { exact: true }).waitFor({ state: 'visible', timeout: 30000 });
+ await page.getByText('Ready. Select a file to import.', { exact: true }).waitFor({ state: 'visible', timeout: 30000 });
+}
+
+async function waitForImportComplete(page) {
+ const statusBox = page.locator('.import-status-box');
+ await statusBox.waitFor({ state: 'visible', timeout: 30000 });
+ await page.waitForFunction(() => {
+ const element = document.querySelector('.import-status-box');
+ return Boolean(element && !element.textContent?.includes('Importing STEP'));
+ }, null, { timeout: 30000 });
+ return statusBox.innerText();
+}
+
+async function dragViewport(viewportFrame, from, to) {
+ const box = await viewportFrame.boundingBox();
+ if (!box) {
+ return;
+ }
+
+ const start = {
+ x: box.x + (box.width * from.x),
+ y: box.y + (box.height * from.y),
+ };
+ const end = {
+ x: box.x + (box.width * to.x),
+ y: box.y + (box.height * to.y),
+ };
+
+ await viewportFrame.page().mouse.move(start.x, start.y);
+ await viewportFrame.page().mouse.down();
+ await viewportFrame.page().mouse.move(end.x, end.y, { steps: 20 });
+ await viewportFrame.page().mouse.up();
+ await viewportFrame.page().waitForTimeout(500);
+}
+
+async function run() {
+ await ensureEdgeExists();
+ await fs.mkdir(artifactRoot, { recursive: true });
+
+ const chromium = await loadChromium();
+ const browser = await chromium.launch({
+ executablePath: edgeExecutablePath,
+ headless: true,
+ });
+
+ const context = await browser.newContext({
+ ignoreHTTPSErrors: true,
+ viewport: { width: 1440, height: 960 },
+ });
+
+ const page = await context.newPage();
+ const consoleEntries = [];
+ const pageErrors = [];
+ const requestFailures = [];
+ const responseEntries = [];
+
+ page.on('console', (message) => {
+ consoleEntries.push({
+ type: message.type(),
+ text: message.text(),
+ location: message.location(),
+ });
+ });
+
+ page.on('pageerror', (error) => {
+ pageErrors.push({
+ name: error.name,
+ message: error.message,
+ stack: error.stack ?? null,
+ });
+ });
+
+ page.on('requestfailed', (request) => {
+ requestFailures.push({
+ url: request.url(),
+ method: request.method(),
+ failure: request.failure(),
+ });
+ });
+
+ page.on('response', async (response) => {
+ const url = response.url();
+ if (!url.includes('/api/v1/documents/')) {
+ return;
+ }
+
+ const artifactName = responseArtifactName(url);
+ if (!artifactName) {
+ return;
+ }
+
+ let bodyText;
+ try {
+ bodyText = await response.text();
+ } catch (error) {
+ bodyText = `<<failed to read response body: ${error}>>`;
+ }
+
+ responseEntries.push({
+ url,
+ status: response.status(),
+ ok: response.ok(),
+ artifactName,
+ bodyText,
+ });
+ });
+
+ try {
+ await waitForReady(page);
+ await page.getByRole('button', { name: 'New Document' }).click();
+ await page.getByText('Ready. Select a file to import.').waitFor({ state: 'visible', timeout: 30000 });
+
+ const fileInput = page.getByTestId('step-import-file-input');
+ await fileInput.setInputFiles(fixturePath);
+ await page.getByRole('button', { name: 'Import STEP 242' }).click();
+
+ const importStatusText = await waitForImportComplete(page);
+ const viewportFrame = page.locator('.viewport-frame');
+ const inspector = page.locator('.audit-panel');
+
+ await viewportFrame.screenshot({ path: path.join(artifactRoot, 'ctc01-aetheris-default.png') });
+ await inspector.screenshot({ path: path.join(artifactRoot, 'ctc01-aetheris-status.png') });
+
+ await dragViewport(viewportFrame, { x: 0.7, y: 0.55 }, { x: 0.3, y: 0.35 });
+ await viewportFrame.screenshot({ path: path.join(artifactRoot, 'ctc01-aetheris-angle-1.png') });
+
+ await dragViewport(viewportFrame, { x: 0.35, y: 0.35 }, { x: 0.6, y: 0.75 });
+ await viewportFrame.screenshot({ path: path.join(artifactRoot, 'ctc01-aetheris-angle-2.png') });
+
+ const summary = {
+ fixturePath,
+ clientUrl,
+ importStatusText,
+ displayLane: await page.locator('.audit-panel p').filter({ hasText: 'Display lane:' }).innerText(),
+ displayStatus: await page.locator('.audit-panel p').filter({ hasText: 'Display status:' }).innerText(),
+ renderPath: await page.locator('.audit-panel p').filter({ hasText: 'Render path:' }).innerText(),
+ analyticFaces: await page.locator('.audit-panel p').filter({ hasText: 'Analytic faces:' }).innerText(),
+ fallbackFaces: await page.locator('.audit-panel p').filter({ hasText: 'Fallback faces:' }).innerText(),
+ faceCount: await page.locator('.audit-panel p').filter({ hasText: 'Face count:' }).innerText(),
+ edgeCount: await page.locator('.audit-panel p').filter({ hasText: 'Edge count:' }).innerText(),
+ screenshots: {
+ default: path.join(artifactRoot, 'ctc01-aetheris-default.png'),
+ status: path.join(artifactRoot, 'ctc01-aetheris-status.png'),
+ angle1: path.join(artifactRoot, 'ctc01-aetheris-angle-1.png'),
+ angle2: path.join(artifactRoot, 'ctc01-aetheris-angle-2.png'),
+ },
+ responseArtifacts: responseEntries.map((entry) => ({
+ url: entry.url,
+ status: entry.status,
+ ok: entry.ok,
+ artifact: path.join(artifactRoot, entry.artifactName),
+ })),
+ };
+
+ for (const entry of responseEntries) {
+ await fs.writeFile(path.join(artifactRoot, entry.artifactName), `${entry.bodyText}\n`, 'utf8');
+ }
+
+ await writeJson(path.join(artifactRoot, 'ctc01-playwright-summary.json'), summary);
+ await writeJson(path.join(artifactRoot, 'ctc01-playwright-console.json'), consoleEntries);
+ await writeJson(path.join(artifactRoot, 'ctc01-playwright-pageerrors.json'), pageErrors);
+ await writeJson(path.join(artifactRoot, 'ctc01-playwright-requestfailures.json'), requestFailures);
+
+ console.log(JSON.stringify(summary, null, 2));
+ } finally {
+ await browser.close();
+ }
+}
+
+await run();