mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Closes coder/internal#168 Gets rid of the "global state" authentication, and adds a `login` helper which should be called at the beginning of each test. This means that not every test needs to authenticated as admin, and we can even have tests that encompass multiple permission levels. We also now create more than just the single admin user during setup, so that we can have a set of users to pick from as appropriate.
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { API } from "api/api";
|
|
import { setupApiCalls } from "../../api";
|
|
import { e2eFakeExperiment1, e2eFakeExperiment2 } from "../../constants";
|
|
import { login } from "../../helpers";
|
|
import { beforeCoderTest } from "../../hooks";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
beforeCoderTest(page);
|
|
await login(page);
|
|
await setupApiCalls(page);
|
|
});
|
|
|
|
test("experiments", async ({ page }) => {
|
|
// Load experiments from backend API
|
|
const availableExperiments = await API.getAvailableExperiments();
|
|
|
|
// Verify if the site lists the same experiments
|
|
await page.goto("/deployment/general", { waitUntil: "networkidle" });
|
|
|
|
const experimentsLocator = page.locator(
|
|
"div.options-table tr.option-experiments ul.option-array",
|
|
);
|
|
await expect(experimentsLocator).toBeVisible();
|
|
|
|
// Firstly, check if all enabled experiments are listed
|
|
expect(
|
|
experimentsLocator.locator(
|
|
`li.option-array-item-${e2eFakeExperiment1}.option-enabled`,
|
|
),
|
|
).toBeVisible;
|
|
expect(
|
|
experimentsLocator.locator(
|
|
`li.option-array-item-${e2eFakeExperiment2}.option-enabled`,
|
|
),
|
|
).toBeVisible;
|
|
|
|
// Secondly, check if available experiments are listed
|
|
for (const experiment of availableExperiments.safe) {
|
|
const experimentLocator = experimentsLocator.locator(
|
|
`li.option-array-item-${experiment}`,
|
|
);
|
|
await expect(experimentLocator).toBeVisible();
|
|
}
|
|
});
|