CI/CD / preconditions (pull_request) Successful in 2s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m17s
CI/CD / test_and_check_app (pull_request) Successful in 6m24s
CI/CD / Publish immutable image (pull_request) Skipped
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m27s
59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import test from 'node:test';
|
|
import { en } from '../ui/locales/en.js';
|
|
import { normalizeServer, needsConfirmation } from '../ui/server.js';
|
|
|
|
const html = readFileSync(new URL('../ui/index.html', import.meta.url), 'utf8');
|
|
|
|
test('workspace selection is hidden before native configuration is available', () => {
|
|
assert.match(html, /<main id="workspace-settings" hidden>/);
|
|
assert.match(html, /id="startup-loading" role="status"/);
|
|
});
|
|
|
|
test('every launcher text resolves to a nonempty English translation', () => {
|
|
for (const [, key] of html.matchAll(/data-i18n="([^"]+)"/g)) {
|
|
assert.equal(typeof en[key], 'string', key);
|
|
assert.ok(en[key].trim(), key);
|
|
}
|
|
});
|
|
|
|
test('installation addresses support custom domains, ports and base paths', () => {
|
|
assert.equal(
|
|
normalizeServer(' HTTPS://Example.com:443/kanban '),
|
|
'https://example.com/kanban/',
|
|
);
|
|
assert.equal(normalizeServer('https://[::1]:8443/'), 'https://[::1]:8443/');
|
|
for (const input of [
|
|
'http://example.com',
|
|
'https:example.com',
|
|
'https://user:secret@example.com',
|
|
'https://user@example.com',
|
|
'https://example.com/?token=secret',
|
|
'https://example.com/#secret',
|
|
'https://exa\nmple.com',
|
|
'https://example.com\\other',
|
|
'file:///tmp/test',
|
|
'javascript:alert(1)',
|
|
'',
|
|
]) {
|
|
assert.throws(() => normalizeServer(input), undefined, input);
|
|
}
|
|
});
|
|
|
|
test('changing the installation requires confirmation, retrying does not', () => {
|
|
assert.equal(needsConfirmation(null, 'https://example.com/'), false);
|
|
assert.equal(
|
|
needsConfirmation('https://example.com/', 'https://example.com/'),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
needsConfirmation('https://example.com/', 'https://example.com:8443/'),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
needsConfirmation('https://example.com/a/', 'https://example.com/b/'),
|
|
true,
|
|
);
|
|
});
|