Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified archify.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion archify/renderers/shared/generated-validators.mjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions archify/schemas/class.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"locale": {
"$ref": "common.schema.json#/$defs/locale"
},
"translations": {
"$ref": "common.schema.json#/$defs/translations"
},
"subtitle": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions archify/schemas/timeline.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"locale": {
"$ref": "common.schema.json#/$defs/locale"
},
"translations": {
"$ref": "common.schema.json#/$defs/translations"
},
"subtitle": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions archify/schemas/tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"locale": {
"$ref": "common.schema.json#/$defs/locale"
},
"translations": {
"$ref": "common.schema.json#/$defs/translations"
},
"subtitle": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions archify/schemas/waterfall.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"locale": {
"$ref": "common.schema.json#/$defs/locale"
},
"translations": {
"$ref": "common.schema.json#/$defs/translations"
},
"subtitle": {
"type": "string"
},
Expand Down
9 changes: 9 additions & 0 deletions test/motion-governor-browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ test('Motion Governor preserves mode, ownership, ambient completion and real cal
assert.ok(navigation.loaderId, 'Motion fixture must load a new document.');
}
await loaded;
if (!preserveStorage && !fixture) {
// Chrome's file-backed storage can outlive Storage.clearDataForStorageKey
// between fresh fixture navigations. Remove only this test preference
// after the new document has loaded so each fixture starts cleanly.
await run('localStorage.removeItem("archify-motion")');
const resetLoaded = browser.cdp.waitFor('Page.loadEventFired', session);
await send('Page.reload');
await resetLoaded;
}
await run('document.fonts.ready');
assert.equal(await run('window.motionNavigation'), expectedNavigation, 'Motion fixture document identity');
}
Expand Down
46 changes: 46 additions & 0 deletions test/new-type-translations.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const root = fileURLToPath(new URL('../archify/', import.meta.url));
const examples = {
tree: 'payment-platform.tree.json', class: 'payments.class.json',
timeline: 'payment-incident.timeline.json', waterfall: 'checkout-request.waterfall.json',
};

for (const [type, example] of Object.entries(examples)) {
test(`${type}: shared Viewer translation overrides work through the public CLI`, (t) => {
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-translations-'));
t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
const doc = JSON.parse(fs.readFileSync(path.join(root, 'examples', example), 'utf8'));
doc.meta.locale = 'en';
doc.meta.translations = { 'viewer.common.close': 'Close this panel' };
const input = path.join(directory, 'input.json');
const output = path.join(directory, 'diagram.html');
const run = () => {
fs.writeFileSync(input, JSON.stringify(doc));
return spawnSync(process.execPath, [path.join(root, 'bin/archify.mjs'), 'render', type, input, output], { encoding: 'utf8' });
};
let result = run();
assert.equal(result.status, 0, result.stderr);
const html = fs.readFileSync(output, 'utf8');
const payload = html.match(/<script id="archify-i18n-data" type="application\/json">([\s\S]*?)<\/script>/);
assert.ok(payload);
const messages = JSON.parse(payload[1]).messages;
assert.equal(messages['viewer.common.close'], 'Close this panel');
assert.equal(messages['viewer.common.copyLink'], JSON.parse(fs.readFileSync(path.join(root, 'locales/en.json'), 'utf8'))['viewer.common.copyLink']);
doc.meta.translations = {};
result = run();
assert.equal(result.status, 0, result.stderr);
const empty = fs.readFileSync(output, 'utf8');
delete doc.meta.translations;
assert.equal(run().status, 0);
assert.equal(fs.readFileSync(output, 'utf8'), empty);
doc.meta.translations = { 'viewer.common.close': 42 };
assert.equal(run().status, 1);
});
}
Loading