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.4 KB
Raw Blame
// "New Event" from outside the window — the taskbar's jump list, `skykeep --new event`
// (src-tauri/src/apps.rs): a Calendar window made for it opens with a new event started; one
// already open, even on another app, is told, comes to Calendar and starts one.
import { engine } from "./engine.mjs";
import { SERVICES, installStub } from "./stub.mjs";

const b = await engine.launch();
let failures = 0;
const ok = (pass, msg) => { console.log(`${pass ? "PASS" : "FAIL"} ${msg}`); if (!pass) failures++; };
const started = (page) => page.locator('.cx-popover input[placeholder="New Event"]').count();
const stub = { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true, notesFixture: true };

{
  const ctx = await b.newContext({ viewport: { width: 1300, height: 850 } });
  await ctx.addInitScript(installStub, stub);
  const page = await ctx.newPage();
  page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
  await page.goto("http://localhost:4173/?app=calendar&new=event", { waitUntil: "networkidle" });
  await page.waitForTimeout(800);
  ok((await page.locator('main.content[data-screen="calendar"]').count()) === 1, "a window made for it is Calendar");
  ok((await started(page)) === 1, "with a new event started in it");
  await ctx.close();
}

{
  const ctx = await b.newContext({ viewport: { width: 1300, height: 850 } });
  await ctx.addInitScript(installStub, stub);
  const page = await ctx.newPage();
  page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
  await page.goto("http://localhost:4173/?app=notes", { waitUntil: "networkidle" });
  await page.waitForTimeout(800);
  ok((await started(page)) === 0, "a window open on Notes has no event started");
  // As Skykeep tells the open window (apps.rs, new_event).
  await page.evaluate(() => window.__emit("quince://new-event", null));
  await page.waitForTimeout(1000);
  ok((await page.locator('main.content[data-screen="calendar"]').count()) === 1, "told, it comes to Calendar");
  ok((await started(page)) === 1, "and starts a new event there");
  await page.keyboard.press("Escape");
  await page.waitForTimeout(300);
  await page.evaluate(() => window.__emit("quince://new-event", null));
  await page.waitForTimeout(600);
  ok((await started(page)) === 1, "told again with Calendar built, it starts another");
  await ctx.close();
}

await b.close();
process.exitCode = failures ? 1 : 0;