Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/verify_starters_de.mjs

2.8 KiB, 1 run

created by r2519314175:695, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1// The starter tags in a language that is not English: are they offered, and
2// does adopting one file the word the chip showed?
3import { open, shot } from './harness.mjs';
4
5const s = await open({ name: 'starters' });
6const { page } = s;
7let bad = 0;
8const check = (ok, what) => { console.log(`${ok ? 'PASS' : 'FAIL'} ${what}`); if (!ok) bad++; };
9
10const boxes = () => page.$$eval('.diamond-box .session-box-name', els => els.map(e => e.textContent));
11
12async function newDiamond(name) {
13 await page.click('#new-diamond-btn', { force: true });
14 await page.waitForSelector('.dlg-input', { timeout: 10000 });
15 await page.fill('.dlg-input', name);
16 await page.click('.dlg-ok', { force: true });
17 await page.waitForTimeout(700);
18}
19await newDiamond('Ein Diamant');
20
21// Switch the app to German through its own service.
22await page.evaluate(async () => { await window.DaimondI18n.setLocale('de'); });
23await page.waitForTimeout(900);
24const loc = await page.evaluate(() => window.DaimondI18n.locale());
25check(loc === 'de', `the app is in German (${loc})`);
26
27// Open the tag editor.
28await page.$$eval('.diamond-box', els => els[0].click());
29await page.waitForTimeout(500);
30for (const b of await page.$$('.crystal-act')) {
31 const t = await b.textContent();
32 if (/Tags|Schlagw/i.test(t)) { await b.click({ force: true }); break; }
33}
34await page.waitForSelector('.tag-editor', { timeout: 5000 });
35
36const sugs = await page.$$eval('.tag-sug .tag-chip', els => els.map(e => e.textContent));
37console.log('offered:', JSON.stringify(sugs));
38check(JSON.stringify(sugs.slice(0, 4)) === JSON.stringify(['person', 'projekt', 'thema', 'organisation']),
39 'the German starters are offered, in order');
40
41// Adopt one: the chip's own word must be the tag that gets filed.
42const before = sugs[1];
43const chips = await page.$$('.tag-sug .tag-chip');
44await chips[1].click({ force: true });
45await page.waitForTimeout(700);
46const on = await page.$$eval('.tag-row:not(.tag-sug) .tag-chip', els => els.map(e => e.textContent.replace('×', '')));
47console.log('on the Diamond:', JSON.stringify(on));
48check(on.includes(before), `adopting ${JSON.stringify(before)} files exactly that word`);
49
50// And it must not be offered again, which is what a chip/tag mismatch would do.
51const after = await page.$$eval('.tag-sug .tag-chip', els => els.map(e => e.textContent));
52check(!after.includes(before), `${JSON.stringify(before)} is no longer offered once adopted`);
53
54// A starter carries no closer; a tag the user made does.
55const closers = await page.$$eval('.tag-sug .tag-chip', els =>
56 els.map(e => ({ tag: e.textContent, kill: !!e.querySelector('.tag-kill') })));
57check(closers.filter(c => c.kill).length === 0,
58 `the remaining starters carry no delete control: ${JSON.stringify(closers)}`);
59
60await shot(s, 'starters-de');
61console.log(bad ? `\n${bad} FAILED` : '\nALL PASS');
62await s.close();
63process.exit(bad ? 1 : 0);