Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334import { describe, expect, it } from "vitest";import { resolve } from "node:path";import { runCheck } from "../../runner/checks";
/** The real scripts/checks/session-check.ts, loaded the way `call session-check` loads it. */const checksDir = resolve(__dirname, "../../scripts/checks");const run = (over: { args?: string[]; account?: string; page: string }) => runCheck({ name: "session-check", checksDir, args: over.args ?? [], vars: {}, timeoutMs: 20_000, profile: "test-qian", account: over.account, read: async () => over.page, url: async () => "https://app.test/", load: (p) => import(p), exists: () => true, });
describe("scripts/checks/session-check.ts", () => { it("passes when the page shows the profile's own account", async () => { expect(await run({ account: "qian.pds.malldao.xyz", page: "Signed in as @qian.pds.malldao.xyz" })).toEqual({ ok: true }); }); it("takes the handle from its argument when it has one, which wins over the profile's", async () => { expect(await run({ args: ["buster.pds.malldao.xyz"], account: "qian.pds.malldao.xyz", page: "Signed in as @buster.pds.malldao.xyz" })).toEqual({ ok: true }); }); it("fails as a mismatch with the instructions when signed out, naming the profile", async () => { const r = await run({ account: "qian.pds.malldao.xyz", page: "Sign in to continue" }); expect(r).toMatchObject({ ok: false, reason: "mismatch", expected: "qian.pds.malldao.xyz", found: "signed out" }); expect(r.ok === false && "message" in r && r.message).toContain("aite profile open test-qian"); }); it("fails naming both accounts when it is the wrong one", async () => { const r = await run({ account: "qian.pds.malldao.xyz", page: "Signed in as @buster.pds.malldao.xyz" }); expect(r).toMatchObject({ ok: false, expected: "qian.pds.malldao.xyz", found: "buster.pds.malldao.xyz" }); }); it("with no handle anywhere it fails rather than passing", async () => { const r = await run({ page: "Signed in as @anyone.example" }); expect(r.ok).toBe(false); });});