-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathclose-confirm.test.mjs
More file actions
42 lines (32 loc) · 1.62 KB
/
close-confirm.test.mjs
File metadata and controls
42 lines (32 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import assert from 'node:assert/strict';
import path from 'node:path';
import { readFile } from 'node:fs/promises';
import { test } from 'node:test';
import { fileURLToPath } from 'node:url';
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.resolve(scriptDir, '..', '..');
const htmlPath = path.join(projectRoot, 'ui', 'close-confirm.html');
const readHtml = async () => readFile(htmlPath, 'utf8');
test('close confirm dialog uses locale copy as the single source of truth for button labels', async () => {
const html = await readHtml();
assert.match(html, /trayButton\.textContent = copy\.tray;/);
assert.match(html, /exitButton\.textContent = copy\.exit;/);
});
test('close confirm dialog avoids exposing raw invoke errors to users', async () => {
const html = await readHtml();
assert.doesNotMatch(html, /invokeError\.message/);
assert.match(html, /error\.textContent = copy\.submitError;/);
});
test('close confirm dialog routes Tauri command calls through a local invoke wrapper', async () => {
const html = await readHtml();
assert.match(html, /const invokeTauri =/);
assert.doesNotMatch(html, /window\.__TAURI_INTERNALS__\?\.invoke/);
assert.match(html, /await invokeTauri\(/);
});
test('close confirm dialog reads close action values from query params instead of hard-coded literals', async () => {
const html = await readHtml();
assert.match(html, /const trayAction = params\.get\("trayAction"\);/);
assert.match(html, /const exitAction = params\.get\("exitAction"\);/);
assert.doesNotMatch(html, /submit\("tray"\)/);
assert.doesNotMatch(html, /submit\("exit"\)/);
});