History

Harden picker add e2e selection

Rhys Sullivan committed 4 months ago

Commit 609d07e1 parent 1464f064 files · +34 −26Browse files

Unified · Split

4 files
  1. e2e/scenarios/google-per-service-add-ui.test.ts +3 −15
  2. e2e/scenarios/microsoft-per-workload-add-ui.test.ts +10 −10
  3. e2e/scenarios/support/picker.ts +21 −0
  4. examples/all-plugins/src/main.ts +0 −1
e2e/scenarios/google-per-service-add-ui.test.ts+3−15
@@ -34,7 +34,7 @@ import { Effect } from "effect"; · 33 unmodified lines
3434
3535 import { scenario } from "../src/scenario";
3636 import { Browser, Target } from "../src/services";
37−import { setPresetChecked } from "./support/picker";
37+import { clearCheckedPresets, setPresetChecked } from "./support/picker";
3838
3939 scenario(
4040 "Google · the per-service picker fans out to separate integrations and skips existing ones",
@@ -59,17 +59,7 @@ scenario( · 18 unmodified lines
5959 async () => {
6060 // Clear every featured default, then select only the three preset
6161 // products under test.
62− const featuredDefaults = [
63− "google-calendar",
64− "google-gmail",
65− "google-sheets",
66− "google-drive",
67− "google-docs",
68− ];
69− for (const presetId of featuredDefaults) {
70− await setPresetChecked(page, presetId, false);
71− }
72−
62+ await clearCheckedPresets(page);
7363 for (const presetId of ["google-calendar", "google-gmail", "google-drive"]) {
7464 await setPresetChecked(page, presetId, true);
7565 }
@@ -152,9 +142,7 @@ scenario( · 76 unmodified lines
152142 await page.getByText("Customize your Google connection").waitFor();
153143
154144 // Clear the featured defaults so only Calendar (already added) is checked.
155− for (const presetId of ["google-gmail", "google-sheets", "google-drive", "google-docs"]) {
156− await setPresetChecked(page, presetId, false);
157− }
145+ await clearCheckedPresets(page);
158146 await setPresetChecked(page, "google-calendar", true);
159147
160148 await page.getByTestId("google-add-submit").click();
e2e/scenarios/microsoft-per-workload-add-ui.test.ts+10−10
@@ -26,7 +26,7 @@ import { Effect } from "effect"; · 25 unmodified lines
2626
2727 import { scenario } from "../src/scenario";
2828 import { Browser, Target } from "../src/services";
29−import { setPresetChecked } from "./support/picker";
29+import { clearCheckedPresets, setPresetChecked } from "./support/picker";
3030
3131 scenario(
3232 "Microsoft · the per-workload picker fans out to separate integrations and skips existing ones",
@@ -46,11 +46,8 @@ scenario( · 13 unmodified lines
4646 });
4747
4848 await step("Clear defaults, check Mail + Calendar, and add a custom scope", async () => {
49− // The featured defaults (profile, mail, calendar, contacts, tasks, files)
50− // start checked; clear them, then select only the two under test.
51− for (const presetId of ["profile", "mail", "calendar", "contacts", "tasks", "files"]) {
52− await setPresetChecked(page, presetId, false);
53− }
49+ // Clear every checked default, then select only the two under test.
50+ await clearCheckedPresets(page);
5451 for (const presetId of ["mail", "calendar"]) {
5552 await setPresetChecked(page, presetId, true);
5653 }
@@ -66,7 +63,12 @@ scenario( · 9 unmodified lines
6663 await page.getByTestId("microsoft-add-submit").click();
6764 // Each workload fetches + stream-compiles the 37MB Graph spec; allow a
6865 // wide window for the result panel to populate.
69− await page.getByTestId("microsoft-add-results").waitFor({ timeout: 300_000 });
66+ const results = page.getByTestId("microsoft-add-results");
67+ await results.waitFor({ timeout: 300_000 });
68+ expect(
69+ await results.locator('[data-testid^="add-result-row-"]').count(),
70+ "only Mail, Calendar, and the custom scope are created",
71+ ).toBe(3);
7072
7173 for (const presetId of ["mail", "calendar"]) {
7274 const row = page.getByTestId(`add-result-row-${presetId}`);
@@ -118,9 +120,7 @@ scenario( · 45 unmodified lines
118120 await page.goto("/integrations/add/microsoft", { waitUntil: "domcontentloaded" });
119121 await page.getByText("Customize Microsoft Graph").waitFor();
120122
121− for (const presetId of ["profile", "mail", "calendar", "contacts", "tasks", "files"]) {
122− await setPresetChecked(page, presetId, false);
123− }
123+ await clearCheckedPresets(page);
124124 await setPresetChecked(page, "mail", true);
125125
126126 await page.getByTestId("microsoft-add-submit").click();
e2e/scenarios/support/picker.ts+21−0
@@ -27,3 +27,24 @@ export const setPresetChecked = async ( · 26 unmodified lines
2727 )
2828 .toBe(String(checked));
2929 };
30+
31+export const clearCheckedPresets = async (page: Page): Promise<void> => {
32+ const boxes = page.locator('[data-testid^="preset-checkbox-"]');
33+ await boxes.first().waitFor();
34+
35+ const checkedPresetIds: string[] = [];
36+ const count = await boxes.count();
37+ for (let index = 0; index < count; index += 1) {
38+ const box = boxes.nth(index);
39+ if ((await box.getAttribute("aria-checked")) !== "true") continue;
40+
41+ const testId = await box.getAttribute("data-testid");
42+ if (testId?.startsWith("preset-checkbox-")) {
43+ checkedPresetIds.push(testId.slice("preset-checkbox-".length));
44+ }
45+ }
46+
47+ for (const presetId of checkedPresetIds) {
48+ await setPresetChecked(page, presetId, false);
49+ }
50+};
examples/all-plugins/src/main.ts+0−1
@@ -418,7 +418,6 @@ const program = Effect.gen(function* () { · 417 unmodified lines
418418 console.log(" executor.fileSecrets.filePath: ", executor.fileSecrets.filePath);
419419
420420 // executor.mcp.addServer({ transport: "remote", name: "...", endpoint: "...", slug: "..." });
421− // executor.google.addBundle({ urls: ["..."], slug: "google" });
422421 // executor.onepassword.configure({ auth: { kind: "desktop-app", accountName: "..." }, vaultId: "..." });
423422
424423 // -------------------------------------------------------------------------