Skip to content

Commit 5e95f31

Browse files
committed
fix(e2e): improve stability of createWorkspace tests
This commit addresses several potential sources of flakiness in the createWorkspace e2e tests: 1. Enhanced disableDynamicParameters function: - Use networkidle instead of domcontentloaded for better page loading - Add explicit waits for form and checkbox visibility - Use more robust selectors for success messages - Add timeout buffers for UI state changes 2. Improved createWorkspace function: - Use networkidle for more reliable page loading - Add form readiness check before filling parameters - Add timeout buffer for form element rendering 3. Enhanced fillParameters function: - Add explicit timeout to parameter field selectors These changes should significantly reduce test flakiness by ensuring all UI elements are fully loaded and stable before interaction.
1 parent 1320b8d commit 5e95f31

File tree

1 file changed

+49
-28
lines changed

1 file changed

+49
-28
lines changed

site/e2e/helpers.ts

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,20 @@ export const createWorkspace = async (
120120
: `${template.organization}/${template.name}`;
121121

122122
await page.goto(`/templates/${templatePath}/workspace`, {
123-
waitUntil: "domcontentloaded",
123+
waitUntil: "networkidle",
124124
});
125125
await expectUrl(page).toHavePathName(`/templates/${templatePath}/workspace`);
126126

127127
const name = randomName();
128128
await page.getByLabel("name").fill(name);
129129

130+
// Wait for the form to be fully loaded before filling parameters
131+
if (buildParameters.length > 0) {
132+
await page.waitForSelector("form", { state: "visible" });
133+
// Additional wait to ensure all form elements are rendered
134+
await page.waitForTimeout(500);
135+
}
136+
130137
await fillParameters(page, richParameters, buildParameters);
131138

132139
if (useExternalAuth) {
@@ -900,7 +907,7 @@ const fillParameters = async (
900907

901908
const parameterLabel = await page.waitForSelector(
902909
`[data-testid='parameter-field-${richParameter.name}']`,
903-
{ state: "visible" },
910+
{ state: "visible", timeout: 10000 },
904911
);
905912

906913
if (richParameter.type === "bool") {
@@ -1209,30 +1216,44 @@ export async function addUserToOrganization(
12091216
* dynamic parameters by unchecking the "Enable dynamic parameters" checkbox.
12101217
*/
12111218
export const disableDynamicParameters = async (
1212-
page: Page,
1213-
templateName: string,
1214-
orgName = defaultOrganizationName,
1219+
page: Page,
1220+
templateName: string,
1221+
orgName = defaultOrganizationName,
12151222
) => {
1216-
await page.goto(`/templates/${orgName}/${templateName}/settings`, {
1217-
waitUntil: "domcontentloaded",
1218-
});
1219-
1220-
// Find and uncheck the "Enable dynamic parameters" checkbox
1221-
const dynamicParamsCheckbox = page.getByRole("checkbox", {
1222-
name: /Enable dynamic parameters for workspace creation/,
1223-
});
1224-
1225-
// If the checkbox is checked, uncheck it
1226-
if (await dynamicParamsCheckbox.isChecked()) {
1227-
await dynamicParamsCheckbox.click();
1228-
}
1229-
1230-
// Save the changes
1231-
await page.getByRole("button", { name: /save/i }).click();
1232-
1233-
// Wait for the success message or page to update
1234-
await page.waitForSelector("text=Template updated successfully", {
1235-
state: "visible",
1236-
timeout: 10000,
1237-
});
1238-
};
1223+
await page.goto(`/templates/${orgName}/${templateName}/settings`, {
1224+
waitUntil: "networkidle",
1225+
});
1226+
1227+
// Wait for the page to be fully loaded and the form to be visible
1228+
await page.waitForSelector("form", { state: "visible" });
1229+
1230+
// Find the "Enable dynamic parameters" checkbox and wait for it to be visible
1231+
const dynamicParamsCheckbox = page.getByRole("checkbox", {
1232+
name: /Enable dynamic parameters for workspace creation/,
1233+
});
1234+
1235+
// Wait for the checkbox to be visible and stable
1236+
await dynamicParamsCheckbox.waitFor({ state: "visible" });
1237+
1238+
// If the checkbox is checked, uncheck it
1239+
if (await dynamicParamsCheckbox.isChecked()) {
1240+
await dynamicParamsCheckbox.click();
1241+
1242+
// Wait a bit for the UI to update after the click
1243+
await page.waitForTimeout(100);
1244+
}
1245+
1246+
// Find and click the save button
1247+
const saveButton = page.getByRole("button", { name: /save/i });
1248+
await saveButton.waitFor({ state: "visible" });
1249+
await saveButton.click();
1250+
1251+
// Wait for the success message with a more robust selector
1252+
await page.waitForSelector("[role='alert'], .MuiAlert-root, text=Template updated successfully", {
1253+
state: "visible",
1254+
timeout: 15000,
1255+
});
1256+
1257+
// Additional wait to ensure the changes are persisted
1258+
await page.waitForTimeout(500);
1259+
};

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