|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import * as API from "api/api"; |
| 3 | +import { setupApiCalls } from "../../api"; |
| 4 | +import { e2eFakeExperiment1, e2eFakeExperiment2 } from "../../constants"; |
| 5 | + |
| 6 | +test("experiments", async ({ page }) => { |
| 7 | + await setupApiCalls(page); |
| 8 | + |
| 9 | + // Load experiments from backend API |
| 10 | + const availableExperiments = await API.getAvailableExperiments(); |
| 11 | + |
| 12 | + // Verify if the site lists the same experiments |
| 13 | + await page.goto("/deployment/general", { waitUntil: "networkidle" }); |
| 14 | + |
| 15 | + const experimentsLocator = page.locator( |
| 16 | + "div.options-table tr.option-experiments ul.option-array", |
| 17 | + ); |
| 18 | + await expect(experimentsLocator).toBeVisible(); |
| 19 | + |
| 20 | + // Firstly, check if all enabled experiments are listed |
| 21 | + expect( |
| 22 | + experimentsLocator.locator( |
| 23 | + `li.option-array-item-${e2eFakeExperiment1}.option-enabled`, |
| 24 | + ), |
| 25 | + ).toBeVisible; |
| 26 | + expect( |
| 27 | + experimentsLocator.locator( |
| 28 | + `li.option-array-item-${e2eFakeExperiment2}.option-enabled`, |
| 29 | + ), |
| 30 | + ).toBeVisible; |
| 31 | + |
| 32 | + // Secondly, check if available experiments are listed |
| 33 | + for (const experiment of availableExperiments.safe) { |
| 34 | + const experimentLocator = experimentsLocator.locator( |
| 35 | + `li.option-array-item-${experiment}`, |
| 36 | + ); |
| 37 | + await expect(experimentLocator).toBeVisible(); |
| 38 | + } |
| 39 | +}); |
0 commit comments