// Run with Node's test runner and Playwright on the module path; see README.md. // zhujiu on Discord: the Quit question (quit-ask.test.cjs) wants a way not // to be asked again, and a switch to have it back. Settings › General › // Ask before quitting is On by default, says when it asks, and Off saves // quitNoAsk with the rest of the settings kept; a quitNoAsk the question's // Don't ask again saved shows Off, and On saves it false. The app's only: // a browser's page (magpie web) quits without asking, so the row isn't // there. In every language, both engines, 1100 and 420 wide; segments, // never a native "); const on = row.locator(".segs button", { hasText: w.on }); const off = row.locator(".segs button", { hasText: w.off }); assert.equal(await on.getAttribute("aria-pressed"), "true", "On by default"); const before = await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings")?.scrollTop]); await press(page, off); await until(() => saved.length); assert.equal(saved.length, 1, "saved once"); assert.equal(saved[0].quitNoAsk, true); assert.equal(saved[0].keepAwake, true, "the row near it kept"); assert.equal(saved[0].redact, true, "the rest kept"); assert.equal(saved[0].lang, lang); assert.deepEqual(await page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings")?.scrollTop]), before, "the click moved nothing"); }); test(`${engine} ${lang} ${width}: after Don't ask again it shows Off, and On asks again`, async (t) => { const { page, saved } = await open(t, { quitNoAsk: true }); const row = page.locator("#setPage-general #quitAskRow"); await row.waitFor(); await reach(page, row); const on = row.locator(".segs button", { hasText: w.on }); assert.equal(await row.locator(".segs button", { hasText: w.off }).getAttribute("aria-pressed"), "true", "Off, as the question left it"); await press(page, on); await until(() => saved.length); assert.equal(saved.length, 1, "saved once"); assert.equal(saved[0].quitNoAsk, false); assert.equal(saved[0].keepAwake, true, "the rest kept"); }); if (width === 420) test(`${engine} ${lang}: a browser's page has no Ask before quitting`, async (t) => { const { page } = await open(t, {}, true); await page.locator("#setPage-general #langPick").waitFor({ state: "attached" }); assert.equal(await page.locator("#quitAskRow").isVisible(), false); }); } }