mirror of
https://github.com/coder/coder.git
synced 2026-10-25 09:42:55 +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.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { login, requiresLicense } from "../../helpers";
|
|
import { beforeCoderTest } from "../../hooks";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
beforeCoderTest(page);
|
|
await login(page);
|
|
});
|
|
|
|
test("license was added successfully", async ({ page }) => {
|
|
requiresLicense();
|
|
|
|
await page.goto("/deployment/licenses", { waitUntil: "domcontentloaded" });
|
|
const firstLicense = page.locator(".licenses > .license-card", {
|
|
hasText: "#1",
|
|
});
|
|
await expect(firstLicense).toBeVisible();
|
|
|
|
// Trial vs. Enterprise?
|
|
const accountType = firstLicense.locator(".account-type");
|
|
await expect(accountType).toHaveText("Premium");
|
|
|
|
// License should not be expired yet
|
|
const licenseExpires = firstLicense.locator(".license-expires");
|
|
const licenseExpiresDate = new Date(await licenseExpires.innerText());
|
|
const now = new Date();
|
|
expect(licenseExpiresDate.getTime()).toBeGreaterThan(now.getTime());
|
|
|
|
// "Remove" button should be visible
|
|
const removeButton = firstLicense.locator(".remove-button");
|
|
await expect(removeButton).toBeVisible();
|
|
});
|