test: verify bundled decoders and artifact budgets (#7)
This commit is contained in:
@@ -1,16 +1,44 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
test('viewer3d resolves hashed Draco and staged IFC decoders under a production subpath', async ({
|
||||
const basisFixture = readFileSync(
|
||||
new URL('../fixtures/viewer3d/BasisTexture.gltf', import.meta.url),
|
||||
);
|
||||
const basisTexture = readFileSync(
|
||||
new URL('../fixtures/viewer3d/BasisTexture.ktx2', import.meta.url),
|
||||
);
|
||||
|
||||
test('viewer3d resolves bundled model decoders under a production subpath', async ({
|
||||
page,
|
||||
}) => {
|
||||
const failedRequests: string[] = [];
|
||||
const responseUrls: string[] = [];
|
||||
page.on('requestfailed', (request) => failedRequests.push(request.url()));
|
||||
page.on('response', (response) => responseUrls.push(response.url()));
|
||||
await page.route(
|
||||
/^https?:\/\/[^/?]+\/viewer-3d\/e2e-fixtures\/BasisTexture\.gltf(?:\?.*)?$/,
|
||||
(route) =>
|
||||
route.fulfill({
|
||||
body: basisFixture,
|
||||
contentType: 'model/gltf+json',
|
||||
}),
|
||||
);
|
||||
await page.route(
|
||||
/^https?:\/\/[^/?]+\/viewer-3d\/e2e-fixtures\/BasisTexture\.ktx2(?:\?.*)?$/,
|
||||
(route) =>
|
||||
route.fulfill({
|
||||
body: basisTexture,
|
||||
contentType: 'image/ktx2',
|
||||
}),
|
||||
);
|
||||
|
||||
for (const fixture of ['Duck.optimized.glb', 'Cube.ifc']) {
|
||||
for (const fixture of [
|
||||
'samples/Duck.optimized.glb',
|
||||
'e2e-fixtures/BasisTexture.gltf',
|
||||
'samples/Cube.ifc',
|
||||
]) {
|
||||
await page.goto(
|
||||
`http://127.0.0.1:43174/viewer-3d/?model=/viewer-3d/samples/${fixture}`,
|
||||
`http://127.0.0.1:43174/viewer-3d/?model=/viewer-3d/${fixture}`,
|
||||
);
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
@@ -31,6 +59,11 @@ test('viewer3d resolves hashed Draco and staged IFC decoders under a production
|
||||
/\/viewer-3d\/assets\/draco_decoder-.+\.wasm$/.test(new URL(url).pathname),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
responseUrls.some((url) =>
|
||||
/\/viewer-3d\/assets\/basis_transcoder-.+\.wasm$/.test(new URL(url).pathname),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(responseUrls.some((url) => url.endsWith('/viewer-3d/web-ifc/web-ifc.wasm'))).toBe(true);
|
||||
expect(failedRequests).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user