Skip to content

Commit 967a381

Browse files
authored
fix: fix flaky IDP e2e tests (#16331)
resolves coder/internal#325
1 parent 760a70d commit 967a381

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

site/e2e/tests/deployment/idpOrgSync.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ test.beforeEach(async ({ page }) => {
1616
});
1717

1818
test.describe("IdpOrgSyncPage", () => {
19+
test.describe.configure({ retries: 1 });
20+
1921
test("show empty table when no org mappings are present", async ({
2022
page,
2123
}) => {
@@ -149,7 +151,6 @@ test.describe("IdpOrgSyncPage", () => {
149151
});
150152

151153
const idpOrgInput = page.getByLabel("IdP organization name");
152-
const orgSelector = page.getByPlaceholder("Select organization");
153154
const addButton = page.getByRole("button", {
154155
name: /Add IdP organization/i,
155156
});
@@ -159,8 +160,16 @@ test.describe("IdpOrgSyncPage", () => {
159160
await idpOrgInput.fill("new-idp-org");
160161

161162
// Select Coder organization from combobox
163+
const orgSelector = page.getByPlaceholder("Select organization");
164+
await expect(orgSelector).toBeAttached();
165+
await expect(orgSelector).toBeVisible();
162166
await orgSelector.click();
163-
await page.getByRole("option", { name: orgName }).click();
167+
await page.waitForTimeout(1000);
168+
169+
const option = await page.getByRole("option", { name: orgName });
170+
await expect(option).toBeAttached({ timeout: 30000 });
171+
await expect(option).toBeVisible();
172+
await option.click();
164173

165174
// Add button should now be enabled
166175
await expect(addButton).toBeEnabled();

site/e2e/tests/organizations/idpGroupSync.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ test.beforeEach(async ({ page }) => {
1616
});
1717

1818
test.describe("IdpGroupSyncPage", () => {
19+
test.describe.configure({ retries: 1 });
20+
1921
test("show empty table when no group mappings are present", async ({
2022
page,
2123
}) => {
@@ -149,7 +151,6 @@ test.describe("IdpGroupSyncPage", () => {
149151
});
150152

151153
const idpOrgInput = page.getByLabel("IdP group name");
152-
const orgSelector = page.getByPlaceholder("Select group");
153154
const addButton = page.getByRole("button", {
154155
name: /Add IdP group/i,
155156
});
@@ -159,8 +160,16 @@ test.describe("IdpGroupSyncPage", () => {
159160
await idpOrgInput.fill("new-idp-group");
160161

161162
// Select Coder organization from combobox
162-
await orgSelector.click();
163-
await page.getByRole("option", { name: /Everyone/i }).click();
163+
const groupSelector = page.getByPlaceholder("Select group");
164+
await expect(groupSelector).toBeAttached();
165+
await expect(groupSelector).toBeVisible();
166+
await groupSelector.click();
167+
await page.waitForTimeout(1000);
168+
169+
const option = await page.getByRole("option", { name: /Everyone/i });
170+
await expect(option).toBeAttached({ timeout: 30000 });
171+
await expect(option).toBeVisible();
172+
await option.click();
164173

165174
// Add button should now be enabled
166175
await expect(addButton).toBeEnabled();

site/e2e/tests/organizations/idpRoleSync.spec.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ import { login } from "../../helpers";
1010
import { beforeCoderTest } from "../../hooks";
1111

1212
test.beforeEach(async ({ page }) => {
13+
requiresLicense();
1314
beforeCoderTest(page);
1415
await login(page);
1516
await setupApiCalls(page);
1617
});
1718

1819
test.describe("IdpRoleSyncPage", () => {
20+
test.describe.configure({ retries: 1 });
21+
1922
test("show empty table when no role mappings are present", async ({
2023
page,
2124
}) => {
22-
requiresLicense();
2325
const org = await createOrganizationWithName(randomName());
2426
await page.goto(`/organizations/${org.name}/idp-sync?tab=roles`, {
2527
waitUntil: "domcontentloaded",
@@ -36,7 +38,6 @@ test.describe("IdpRoleSyncPage", () => {
3638
});
3739

3840
test("add new IdP role mapping with API", async ({ page }) => {
39-
requiresLicense();
4041
const org = await createOrganizationWithName(randomName());
4142
await createRoleSyncSettings(org.id);
4243

@@ -58,7 +59,6 @@ test.describe("IdpRoleSyncPage", () => {
5859
});
5960

6061
test("delete a IdP role to coder role mapping row", async ({ page }) => {
61-
requiresLicense();
6262
const org = await createOrganizationWithName(randomName());
6363
await createRoleSyncSettings(org.id);
6464

@@ -79,7 +79,6 @@ test.describe("IdpRoleSyncPage", () => {
7979
});
8080

8181
test("update sync field", async ({ page }) => {
82-
requiresLicense();
8382
const org = await createOrganizationWithName(randomName());
8483
await page.goto(`/organizations/${org.name}/idp-sync?tab=roles`, {
8584
waitUntil: "domcontentloaded",
@@ -107,7 +106,6 @@ test.describe("IdpRoleSyncPage", () => {
107106
test("export policy button is enabled when sync settings are present", async ({
108107
page,
109108
}) => {
110-
requiresLicense();
111109
const org = await createOrganizationWithName(randomName());
112110
await page.goto(`/organizations/${org.name}/idp-sync?tab=roles`, {
113111
waitUntil: "domcontentloaded",
@@ -121,7 +119,6 @@ test.describe("IdpRoleSyncPage", () => {
121119
});
122120

123121
test("add new IdP role mapping with UI", async ({ page }) => {
124-
requiresLicense();
125122
const orgName = randomName();
126123
await createOrganizationWithName(orgName);
127124

@@ -130,30 +127,41 @@ test.describe("IdpRoleSyncPage", () => {
130127
});
131128

132129
const idpOrgInput = page.getByLabel("IdP role name");
133-
const roleSelector = page.getByPlaceholder("Select role");
134130
const addButton = page.getByRole("button", {
135131
name: /Add IdP role/i,
136132
});
137133

138134
await expect(addButton).toBeDisabled();
139135

140-
await idpOrgInput.fill("new-idp-role");
136+
const idpRoleName = randomName();
137+
await idpOrgInput.fill(idpRoleName);
141138

142139
// Select Coder role from combobox
140+
const roleSelector = page.getByPlaceholder("Select role");
141+
await expect(roleSelector).toBeAttached();
142+
await expect(roleSelector).toBeVisible();
143143
await roleSelector.click();
144-
await page.getByRole("option", { name: /Organization Admin/i }).click();
144+
145+
await page.getByRole("combobox").click();
146+
await page.waitForTimeout(1000);
147+
148+
const option = await page.getByRole("option", {
149+
name: /Organization Admin/i,
150+
});
151+
152+
await expect(option).toBeAttached({ timeout: 30000 });
153+
await expect(option).toBeVisible();
154+
await option.click();
145155

146156
// Add button should now be enabled
147157
await expect(addButton).toBeEnabled();
148158

149159
await addButton.click();
150160

151161
// Verify new mapping appears in table
152-
const newRow = page.getByTestId("role-new-idp-role");
162+
const newRow = page.getByTestId(`role-${idpRoleName}`);
153163
await expect(newRow).toBeVisible();
154-
await expect(
155-
newRow.getByRole("cell", { name: "new-idp-role" }),
156-
).toBeVisible();
164+
await expect(newRow.getByRole("cell", { name: idpRoleName })).toBeVisible();
157165
await expect(
158166
newRow.getByRole("cell", { name: "organization-admin" }),
159167
).toBeVisible();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy