Skip to content

test(site): add e2e tests for experiments #12940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mtojek committed Apr 11, 2024
commit 7a032f1da588d268252ccc0144d93c4cf4f147fb
2 changes: 1 addition & 1 deletion site/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig({
use: {
baseURL: `http://localhost:${coderPort}`,
video: "retain-on-failure",
viewport: { width: 2048, height: 1600 },
viewport: { width: 2560, height: 1440 },
...(wsEndpoint
? {
connectOptions: {
Expand Down
23 changes: 9 additions & 14 deletions site/e2e/tests/deployment/general.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect, test } from "@playwright/test";
import * as API from "api/api";
import { setupApiCalls } from "../../api";
import { e2eFakeExperiment1, e2eFakeExperiment2 } from "../../constants";

test("experiments", async ({ page }) => {
await setupApiCalls(page);

// Load experiments from backend API
const availableExperiments = await API.getAvailableExperiments();
const enabledExperiments = await API.getExperiments();

// Verify if the site lists the same experiments
await page.goto("/deployment/general", { waitUntil: "networkidle" });
Expand All @@ -17,22 +17,17 @@ test("experiments", async ({ page }) => {
);
await expect(experimentsLocator).toBeVisible();

// eslint-disable-next-line no-console -- HTML for experiments
console.log(experimentsLocator.innerHTML());
// Firstly, check if all enabled experiments are listed
expect(experimentsLocator.locator("li", { hasText: e2eFakeExperiment1 }))
.toBeVisible;
expect(experimentsLocator.locator("li", { hasText: e2eFakeExperiment2 }))
.toBeVisible;

// Firstly, check if available experiments are listed
availableExperiments.safe.map(async (experiment) => {
const experimentLocator = experimentsLocator.locator(
`li.option-array-item-${experiment}`,
);
await expect(experimentLocator).toBeVisible();
});

// Secondly, check if all enabled experiments are listed
enabledExperiments.map(async (experiment) => {
// Secondly, check if available experiments are listed
for (const experiment of availableExperiments.safe) {
const experimentLocator = experimentsLocator.locator(
`li.option-array-item-${experiment}.option-enabled`,
);
await expect(experimentLocator).toBeVisible();
});
}
});