SOURCE / PINNED RELEASE
Made of little things.
Nappakura
- Release
- a75ca0f8b596…
- Author-recorded commit
- 4463126213fa…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-8db03001b62
Archive hash verified: b448d77b767ae754…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import assert from 'node:assert/strict';
import { readFile, realpath, mkdir } from 'node:fs/promises';
import { createRequire } from 'node:module';
const require = createRequire(
await realpath(new URL('../node_modules/@napplet/conformance-cli/package.json', import.meta.url)),
);
const { chromium } = require('playwright');
if (!process.env.NAPPLET_PREVIEW_URL)
throw new Error('Set NAPPLET_PREVIEW_URL to the updated soyLI preview URL.');
const browser = await chromium.launch({ headless: true });
const out = new URL('../.napplet-space/ui-checks/', import.meta.url);
await mkdir(out, { recursive: true });
try {
const page = await browser.newPage({
viewport: { width: 1600, height: 1000 },
});
page.setDefaultTimeout(15000);
const errors = [];
page.on('pageerror', (e) => errors.push(e.message));
await page.goto(process.env.NAPPLET_PREVIEW_URL);
const f = page.frameLocator('iframe');
await f.locator('#modelName').waitFor();
// The manual toolbar and agent tools edit the same document and history.
await f.getByRole('button', { name: '+ Primitive', exact: true }).click();
await f.locator('#model-kind').selectOption('box');
await f.locator('#model-sizeMm').fill('40');
await f.locator('#modelApply').click();
await page.getByRole('button', { name: 'Agent tools', exact: true }).click();
await page.getByText(/tools · inspect and try a call/).click();
assert.equal(
await page.getByRole('button', { name: 'Run tool', exact: true }).isDisabled(),
true,
);
await page.getByLabel('Allow shell tool access for this document', { exact: true }).check();
const invoke = async (name, args) => {
await page.getByLabel('Agent tool', { exact: true }).selectOption({ label: name });
await page.getByLabel('Tool arguments', { exact: true }).fill(JSON.stringify(args));
await page.getByRole('button', { name: 'Run tool', exact: true }).click();
await page
.getByLabel('Tool result', { exact: true })
.filter({ hasNotText: 'Running…' })
.waitFor();
return page.getByLabel('Tool result', { exact: true }).innerText();
};
const call = async (name, args) => JSON.parse(await invoke(name, args));
let doc = await call('inspect_document', { includeGeometry: true });
assert.equal(doc.polygons, 6);
assert.deepEqual(doc.dimensions, [40, 40, 40]);
assert.equal(doc.revision, 1);
const face = doc.polygonIds[0];
doc = await call('extrude_faces', {
expectedRevision: doc.revision,
polygonIds: [face],
distanceMm: 10,
});
assert.equal(doc.polygons, 10);
doc = await call('inset_face', {
expectedRevision: doc.revision,
polygonId: face,
ratio: 0.7,
});
const edge = doc.edges[0];
doc = await call('split_edge', {
expectedRevision: doc.revision,
edgeId: edge.id,
fraction: 0.5,
});
doc = await call('inspect_document', { includeGeometry: true });
const prior = doc.revision;
doc = await call('transform_geometry', {
expectedRevision: doc.revision,
kind: 'polygon',
ids: doc.polygonIds,
operation: 'move',
values: [0, 0, 0.2],
});
assert.match(
await invoke('delete_faces', {
expectedRevision: prior,
polygonIds: [face],
}),
/Stale document/,
);
doc = await call('undo', { expectedRevision: doc.revision });
doc = await call('redo', { expectedRevision: doc.revision });
doc = await call('configure_print', {
expectedRevision: doc.revision,
sizeMm: 100,
});
doc = await call('unfold_pattern', { expectedRevision: doc.revision });
doc = await call('arrange_pattern', { expectedRevision: doc.revision });
const issues = await call('check_printability', {});
assert.deepEqual(issues.issues, []);
const selectExport = async () => {
await page.getByLabel('Agent tool', { exact: true }).selectOption({ label: 'export_pdf' });
await page
.getByLabel('Tool arguments', { exact: true })
.fill(JSON.stringify({ expectedRevision: doc.revision }));
await page.getByRole('button', { name: 'Run tool', exact: true }).click();
};
await selectExport();
await page.getByRole('button', { name: 'Cancel', exact: true }).click();
await page
.getByLabel('Tool result', { exact: true })
.filter({ hasNotText: 'Running…' })
.waitFor();
assert.match(
await page.getByLabel('Tool result', { exact: true }).innerText(),
/cancel|denied|declin/i,
);
await selectExport();
await page.getByRole('button', { name: 'Save file', exact: true }).click();
await page
.getByLabel('Tool result', { exact: true })
.filter({ hasNotText: 'Running…' })
.waitFor();
const exported = JSON.parse(await page.getByLabel('Tool result', { exact: true }).innerText());
assert.match(exported.status, /host-file-panel/);
assert.equal(exported.mime, 'application/pdf');
await page.getByLabel('Close agent tools', { exact: true }).click();
const downloading = page.waitForEvent('download');
await page.getByRole('link', { name: /box.pdf/ }).click();
const file = new URL('modelled-box.pdf', out).pathname;
await (await downloading).saveAs(file);
assert.equal((await readFile(file, 'utf8')).startsWith('%PDF-1.4'), true);
await page.screenshot({ path: new URL('modelling-wide.png', out).pathname });
// Fullscreen + small-frame layout: the shell dialog remains usable above the app.
await page.getByRole('button', { name: 'Agent tools', exact: true }).click();
await page.getByText(/tools · inspect and try a call/).click();
await page.locator('iframe').evaluate((el) => el.requestFullscreen());
await page.getByLabel('Tool arguments', { exact: true }).fill('{}');
await page.getByLabel('Close agent tools', { exact: true }).click();
await page.evaluate(() => document.fullscreenElement && document.exitFullscreen());
for (const [width, height] of [
[900, 600],
[320, 560],
[200, 160],
]) {
await page.locator('iframe').evaluate(
(el, [w, h]) => {
el.style.width = w + 'px';
el.style.height = h + 'px';
el.style.flex = 'none';
},
[width, height],
);
await f.locator('#modelName').waitFor({ state: 'attached' });
await page.screenshot({
path: new URL(`modelling-${width}.png`, out).pathname,
});
const overflow = await f.locator('html').evaluate((el) => ({
x: el.scrollWidth > innerWidth,
y: el.scrollHeight > innerHeight,
}));
assert.equal(overflow.x, false);
if (width === 320) {
const canvas = await f.locator('#modelCanvas').boundingBox();
assert.ok(canvas.height >= 120, `Model viewport collapsed to ${canvas.height}px`);
assert.equal(
await f.getByRole('toolbar', { name: 'Modelling tools' }).getByRole('button').count(),
9,
);
}
}
await page.getByRole('button', { name: 'Agent tools', exact: true }).click();
await page.getByText(/tools · inspect and try a call/).click();
await page.getByRole('button', { name: 'Revoke access', exact: true }).click();
assert.equal(
await page.getByRole('button', { name: 'Run tool', exact: true }).isDisabled(),
true,
);
assert.deepEqual(errors, []);
console.log(
'PASS shared toolbar/tools: box → extrusion → inset → split → vertex move → stale rejection → undo/redo → unfold → arrange → NAP-FS denial/approval → valid PDF; fullscreen and narrow-frame checks.',
);
} finally {
await browser.close();
}
