Content-Length: 435190 | pFad | http://github.com/coder/coder/commit/29486f9d4e146df282fabeca291867691a109310

B7 fix: fix e2e tests (#19076) · coder/coder@29486f9 · GitHub
Skip to content

Commit 29486f9

Browse files
authored
fix: fix e2e tests (#19076)
Closes coder/internal#824
1 parent b666d52 commit 29486f9

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

site/e2e/helpers.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ export const createWorkspace = async (
127127
const name = randomName();
128128
await page.getByLabel("name").fill(name);
129129

130+
if (buildParameters.length > 0) {
131+
await page.waitForSelector("form", { state: "visible" });
132+
}
133+
130134
await fillParameters(page, richParameters, buildParameters);
131135

132136
if (useExternalAuth) {
@@ -898,28 +902,29 @@ const fillParameters = async (
898902
);
899903
}
900904

901-
const parameterLabel = await page.waitForSelector(
902-
`[data-testid='parameter-field-${richParameter.name}']`,
903-
{ state: "visible" },
905+
// Use modern locator approach instead of waitForSelector
906+
const parameterLabel = page.getByTestId(
907+
`parameter-field-${richParameter.name}`,
904908
);
909+
await expect(parameterLabel).toBeVisible();
905910

906911
if (richParameter.type === "bool") {
907-
const parameterField = await parameterLabel.waitForSelector(
908-
`[data-testid='parameter-field-bool'] .MuiRadio-root input[value='${buildParameter.value}']`,
909-
);
912+
const parameterField = parameterLabel
913+
.getByTestId("parameter-field-bool")
914+
.locator(`.MuiRadio-root input[value='${buildParameter.value}']`);
910915
await parameterField.click();
911916
} else if (richParameter.options.length > 0) {
912-
const parameterField = await parameterLabel.waitForSelector(
913-
`[data-testid='parameter-field-options'] .MuiRadio-root input[value='${buildParameter.value}']`,
914-
);
917+
const parameterField = parameterLabel
918+
.getByTestId("parameter-field-options")
919+
.locator(`.MuiRadio-root input[value='${buildParameter.value}']`);
915920
await parameterField.click();
916921
} else if (richParameter.type === "list(string)") {
917922
throw new Error("not implemented yet"); // FIXME
918923
} else {
919924
// text or number
920-
const parameterField = await parameterLabel.waitForSelector(
921-
"[data-testid='parameter-field-text'] input",
922-
);
925+
const parameterField = parameterLabel
926+
.getByTestId("parameter-field-text")
927+
.locator("input");
923928
await parameterField.fill(buildParameter.value);
924929
}
925930
}
@@ -1217,22 +1222,34 @@ export const disableDynamicParameters = async (
12171222
waitUntil: "domcontentloaded",
12181223
});
12191224

1225+
await page.waitForSelector("form", { state: "visible" });
1226+
12201227
// Find and uncheck the "Enable dynamic parameters" checkbox
12211228
const dynamicParamsCheckbox = page.getByRole("checkbox", {
12221229
name: /Enable dynamic parameters for workspace creation/,
12231230
});
12241231

1232+
await dynamicParamsCheckbox.waitFor({ state: "visible" });
1233+
12251234
// If the checkbox is checked, uncheck it
12261235
if (await dynamicParamsCheckbox.isChecked()) {
12271236
await dynamicParamsCheckbox.click();
12281237
}
12291238

12301239
// Save the changes
1231-
await page.getByRole("button", { name: /save/i }).click();
1240+
const saveButton = page.getByRole("button", { name: /save/i });
1241+
await saveButton.waitFor({ state: "visible" });
1242+
await saveButton.click();
12321243

12331244
// Wait for the success message or page to update
1234-
await page.waitForSelector("text=Template updated successfully", {
1235-
state: "visible",
1236-
timeout: 10000,
1237-
});
1245+
await page
1246+
.locator("[role='alert']:has-text('Template updated successfully')")
1247+
.first()
1248+
.waitFor({
1249+
state: "visible",
1250+
timeout: 15000,
1251+
});
1252+
1253+
// Additional wait to ensure the changes are persisted
1254+
await page.waitForTimeout(500);
12381255
};

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/coder/commit/29486f9d4e146df282fabeca291867691a109310

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy