Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

2.7 KB
Raw Blame
// No keyring to keep the session (a window manager without one, a session over SSH): signed in
// all the same, and said once, calmly — a quiet line under the account in the sidebar, the
// whole sentence with what fixes it in Settings. With a keyring, nothing is said.
import { engine } from "./engine.mjs";
import { SERVICES, installStub } from "./stub.mjs";
const BASE = process.env.BASE ?? process.env.URL ?? "http://localhost:4173";
const b = await engine.launch();
let failures = 0;
const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };

async function open(notKept) {
  const ctx = await b.newContext({ viewport: { width: 1180, height: 820 } });
  await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });
  await ctx.addInitScript((notKept) => {
    const inner = window.__TAURI_INTERNALS__.invoke;
    window.__TAURI_INTERNALS__.invoke = async (cmd, args) => {
      if (cmd === "auth_status") return { hasStoredSession: true, signedIn: true, libraryReady: true, notKept };
      return inner(cmd, args);
    };
  }, notKept);
  const page = await ctx.newPage();
  await page.goto(BASE, { waitUntil: "networkidle" });
  await page.waitForTimeout(400);
  return { ctx, page };
}

{
  const { ctx, page } = await open(true);
  const line = page.locator(".sidebar-not-kept");
  ok(await line.isVisible(), "the sidebar says the sign-in is not saved");
  ok((await line.innerText()).trim() === "Sign-in not saved", `in a few words  [${await line.innerText()}]`);
  ok(/keyring/.test((await line.getAttribute("title")) ?? ""), "and the whole sentence is under the pointer");
  const fits = await line.evaluate((el) => el.scrollWidth <= el.clientWidth);
  ok(fits, "its words fit the sidebar");
  await page.locator(".sidebar-account").click();
  await page.waitForSelector(".settings");
  const note = page.locator(".settings-account-note");
  const said = (await note.innerText()).trim();
  ok(await note.isVisible() && /until Skykeep closes/.test(said) && /GNOME Keyring or KWallet/.test(said), `Settings says what it means and what fixes it  [${said}]`);
  ok(!(await page.locator(".settings [role=alert]").count()), "calmly: no alert");
  await ctx.close();
}
{
  const { ctx, page } = await open(false);
  ok(!(await page.locator(".sidebar-not-kept").count()), "with a keyring, the sidebar says nothing");
  await page.locator(".sidebar-account").click();
  await page.waitForSelector(".settings");
  ok(!(await page.locator(".settings-account-note").count()), "nor does Settings");
  await ctx.close();
}
await b.close();
console.log(failures ? `\n${failures} FAILED` : "\nall passed");
process.exit(failures ? 1 : 0);