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? |
| 3 | import { open, shot } from './harness.mjs'; |
| 4 | |
| 5 | const s = await open({ name: 'starters' }); |
| 6 | const { page } = s; |
| 7 | let bad = 0; |
| 8 | const check = (ok, what) => { console.log(`${ok ? 'PASS' : 'FAIL'} ${what}`); if (!ok) bad++; }; |
| 9 | |
| 10 | const boxes = () => page.$$eval('.diamond-box .session-box-name', els => els.map(e => e.textContent)); |
| 11 | |
| 12 | async 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 | } |
| 19 | await newDiamond('Ein Diamant'); |
| 20 | |
| 21 | // Switch the app to German through its own service. |
| 22 | await page.evaluate(async () => { await window.DaimondI18n.setLocale('de'); }); |
| 23 | await page.waitForTimeout(900); |
| 24 | const loc = await page.evaluate(() => window.DaimondI18n.locale()); |
| 25 | check(loc === 'de', `the app is in German (${loc})`); |
| 26 | |
| 27 | // Open the tag editor. |
| 28 | await page.$$eval('.diamond-box', els => els[0].click()); |
| 29 | await page.waitForTimeout(500); |
| 30 | for (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 | } |
| 34 | await page.waitForSelector('.tag-editor', { timeout: 5000 }); |
| 35 | |
| 36 | const sugs = await page.$$eval('.tag-sug .tag-chip', els => els.map(e => e.textContent)); |
| 37 | console.log('offered:', JSON.stringify(sugs)); |
| 38 | check(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. |
| 42 | const before = sugs[1]; |
| 43 | const chips = await page.$$('.tag-sug .tag-chip'); |
| 44 | await chips[1].click({ force: true }); |
| 45 | await page.waitForTimeout(700); |
| 46 | const on = await page.$$eval('.tag-row:not(.tag-sug) .tag-chip', els => els.map(e => e.textContent.replace('×', ''))); |
| 47 | console.log('on the Diamond:', JSON.stringify(on)); |
| 48 | check(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. |
| 51 | const after = await page.$$eval('.tag-sug .tag-chip', els => els.map(e => e.textContent)); |
| 52 | check(!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. |
| 55 | const closers = await page.$$eval('.tag-sug .tag-chip', els => |
| 56 | els.map(e => ({ tag: e.textContent, kill: !!e.querySelector('.tag-kill') }))); |
| 57 | check(closers.filter(c => c.kill).length === 0, |
| 58 | `the remaining starters carry no delete control: ${JSON.stringify(closers)}`); |
| 59 | |
| 60 | await shot(s, 'starters-de'); |
| 61 | console.log(bad ? `\n${bad} FAILED` : '\nALL PASS'); |
| 62 | await s.close(); |
| 63 | process.exit(bad ? 1 : 0); |