[web] Previews and the team: a Previews screen (see: 1 click, close: 2), sign-in from a setup or invite link, Settings → Team (invite: 3 clicks), previews-only API tokens; click-counted tests
This commit is contained in:
@@ -170,6 +170,37 @@ describe("ROADMAP §4 flows, clicks counted", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("T4 flows, clicks counted", () => {
|
||||
it("See active previews = 1 click", async () => {
|
||||
start();
|
||||
const nav = (await screen.findAllByRole("navigation", { name: "Main" }, T))[0];
|
||||
await click(within(nav).getByRole("link", { name: "Previews" }));
|
||||
await screen.findByRole("link", { name: "fix-42--shop.preview.home.test" }, T);
|
||||
expect(clicks).toBe(1);
|
||||
});
|
||||
|
||||
it("Kill a preview = 2 clicks (Close → Close preview)", async () => {
|
||||
start("/previews");
|
||||
await click(await screen.findByRole("button", { name: "Close" }, T));
|
||||
await click(await screen.findByRole("button", { name: "Close preview" }));
|
||||
await waitFor(() => expect(called("DELETE", "/previews/fix-42--shop.preview.home.test")).toBe(true), T);
|
||||
await screen.findByRole("heading", { name: "No previews open" }, T);
|
||||
expect(clicks).toBe(2);
|
||||
});
|
||||
|
||||
it("Invite a teammate: Settings → Team → Invite = 3 clicks, the link shown", async () => {
|
||||
start();
|
||||
const nav = (await screen.findAllByRole("navigation", { name: "Main" }, T))[0];
|
||||
await click(within(nav).getByRole("link", { name: "Settings" }));
|
||||
await click(await screen.findByRole("tab", { name: "Team" }));
|
||||
await user.type(await screen.findByLabelText("Name"), "Petra");
|
||||
await click(screen.getByRole("button", { name: "Invite" }));
|
||||
const link = (await screen.findByLabelText("Invite link", {}, T)) as HTMLInputElement;
|
||||
expect(link.value).toMatch(/\/#signin=iin_testcode$/);
|
||||
expect(clicks).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("focus", () => {
|
||||
it("+ Host puts the cursor in Hostname, so typing right after the click lands there", async () => {
|
||||
start();
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface Mock {
|
||||
calls: { method: string; path: string; body: unknown }[];
|
||||
state: {
|
||||
engine: "pingora" | "caddy";
|
||||
previewClosed: boolean;
|
||||
switching: number;
|
||||
intermediate: "ok" | "due";
|
||||
renewal: boolean;
|
||||
@@ -65,7 +66,7 @@ export type Route = [string, RegExp, (mm: RegExpMatchArray, body: Json) => [numb
|
||||
export function newMock(): Mock {
|
||||
return {
|
||||
calls: [],
|
||||
state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [] },
|
||||
state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [], previewClosed: false },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,6 +171,17 @@ export function mockRoutes(m: Mock): Route[] {
|
||||
["GET", /^\/tokens$/, () => [200, { items: [] }]],
|
||||
["POST", /^\/tokens$/, (_, b) => [201, { id: "tk_1", name: b.name, token: "ian_tk1_secretvalue", expires_at: later(365 * 86400) }]],
|
||||
["GET", /^\/share-links$/, () => [200, { items: [], epoch: 0 }]],
|
||||
// T4: previews and the team (invented .test names only).
|
||||
["GET", /^\/previews$/, () => [200, {
|
||||
domain: "preview.home.test",
|
||||
items: m.state.previewClosed ? [] : [{ hostname: "fix-42--shop.preview.home.test", url: "https://fix-42--shop.preview.home.test/", project: "team/shop", branch: "fix-42", upstream: "http://10.0.0.7:8080", expires_at: later(86400), state: "live" }],
|
||||
}]],
|
||||
["DELETE", /^\/previews\/fix-42--shop\.preview\.home\.test$/, () => {
|
||||
m.state.previewClosed = true;
|
||||
return [202, { apply: apply("ch_pv", "queued", "Closed the preview of fix-42 (team/shop)", ["fix-42--shop.preview.home.test"]) }];
|
||||
}],
|
||||
["GET", /^\/team$/, () => [200, { me: { id: "m1", name: "Mark", role: "admin", added_at: now(), tessera_root: null, match_code: null }, members: [{ id: "m1", name: "Mark", role: "admin", added_at: now(), tessera_root: null, match_code: null }], invites: [], authelia: false }]],
|
||||
["POST", /^\/team\/invites$/, (_, b) => [201, { invite: { id: "iv1", name: b.name, role: b.role, expires_at: later(7 * 86400) }, link_fragment: "#signin=iin_testcode" }]],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user