Skip to content

Commit 13412e2

Browse files
committed
yay!!!!
1 parent 3a8af89 commit 13412e2

File tree

8 files changed

+55
-62
lines changed

8 files changed

+55
-62
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,13 @@ jobs:
472472
- run: pnpm playwright:install
473473
working-directory: site
474474

475+
# Run tests that don't require an enterprise license without an enterprise license
476+
- run: pnpm playwright:test --forbid-only --workers 1
477+
env:
478+
DEBUG: pw:api
479+
working-directory: site
480+
481+
# Run all of the tests with an enterprise license
475482
- run: pnpm playwright:test --forbid-only --workers 1
476483
env:
477484
DEBUG: pw:api

site/e2e/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ export const gitAuth = {
3434
};
3535

3636
export const enterpriseLicense = process.env.CODER_E2E_ENTERPRISE_LICENSE ?? "";
37-
export const skipEnterpriseTests = !enterpriseLicense;

site/e2e/enterprise.setup.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

site/e2e/tests.setup.ts renamed to site/e2e/global.setup.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { test, expect } from "@playwright/test";
22
import { Language } from "pages/CreateUserPage/CreateUserForm";
33
import * as constants from "./constants";
4+
import { requiresEnterpriseLicense } from "./helpers";
45
import { storageState } from "./playwright.config";
56

67
test("setup first user", async ({ page }) => {
@@ -16,3 +17,14 @@ test("setup first user", async ({ page }) => {
1617

1718
await page.getByTestId("button-select-template").isVisible();
1819
});
20+
21+
test("setup license", async ({ page }) => {
22+
requiresEnterpriseLicense();
23+
await page.goto("/deployment/licenses", { waitUntil: "domcontentloaded" });
24+
25+
await page.getByText("Add a license").click();
26+
await page.getByRole("textbox").fill(constants.enterpriseLicense);
27+
await page.getByText("Upload License").click();
28+
29+
await page.getByText("You have successfully added a license").isVisible();
30+
});

site/e2e/helpers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type BrowserContext, expect, type Page } from "@playwright/test";
1+
import { type BrowserContext, expect, type Page, test } from "@playwright/test";
22
import axios from "axios";
33
import { type ChildProcess, exec, spawn } from "child_process";
44
import { randomUUID } from "crypto";
@@ -16,6 +16,7 @@ import {
1616
agentPProfPort,
1717
coderMain,
1818
coderPort,
19+
enterpriseLicense,
1920
prometheusPort,
2021
} from "./constants";
2122
import {
@@ -30,6 +31,11 @@ import {
3031
type RichParameter,
3132
} from "./provisionerGenerated";
3233

34+
// requiresEnterpriseLicense will skip the test if we're not running with an enterprise license
35+
export function requiresEnterpriseLicense() {
36+
test.skip(!enterpriseLicense);
37+
}
38+
3339
// createWorkspace creates a workspace for a template.
3440
// It does not wait for it to be running, but it does navigate to the page.
3541
export const createWorkspace = async (

site/e2e/playwright.config.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,18 @@ export default defineConfig({
1515
projects: [
1616
{
1717
name: "testsSetup",
18-
testMatch: /tests.setup\.ts/,
18+
testMatch: /global.setup\.ts/,
1919
},
2020
{
2121
name: "tests",
2222
testMatch: /.*\.spec\.ts/,
2323
dependencies: ["testsSetup"],
24-
use: {
25-
storageState: storageState,
26-
},
27-
timeout: 60_000,
28-
},
29-
{
30-
name: "enterpriseSetup",
31-
testMatch: /enterprise.setup\.ts/,
32-
dependencies: ["testsSetup"],
33-
use: {
34-
storageState: storageState,
35-
},
36-
},
37-
{
38-
name: "enterprise",
39-
testMatch: /.*\.enterpriseSpec\.ts/,
40-
dependencies: ["enterpriseSetup"],
41-
use: {
42-
storageState: storageState,
43-
},
4424
timeout: 60_000,
4525
},
4626
],
4727
reporter: [["./reporter.ts"]],
4828
use: {
29+
storageState,
4930
baseURL: `http://localhost:${coderPort}`,
5031
video: "retain-on-failure",
5132
...(wsEndpoint

site/e2e/tests/updateTemplate.enterpriseSpec.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

site/e2e/tests/updateTemplate.spec.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { test } from "@playwright/test";
2-
import { createTemplate, updateTemplateSettings } from "../helpers";
1+
import { expect, test } from "@playwright/test";
2+
import {
3+
createTemplate,
4+
requiresEnterpriseLicense,
5+
updateTemplateSettings,
6+
} from "../helpers";
37

48
test("template update with new name redirects on successful submit", async ({
59
page,
@@ -10,3 +14,24 @@ test("template update with new name redirects on successful submit", async ({
1014
name: "new-name",
1115
});
1216
});
17+
18+
test("require latest version", async ({ page }) => {
19+
requiresEnterpriseLicense();
20+
21+
const templateName = await createTemplate(page);
22+
23+
await page.goto(`/templates/${templateName}/settings`, {
24+
waitUntil: "domcontentloaded",
25+
});
26+
await expect(page).toHaveURL(`/templates/${templateName}/settings`);
27+
let checkbox = await page.waitForSelector("#require_active_version");
28+
await checkbox.click();
29+
await page.getByTestId("form-submit").click();
30+
31+
await page.goto(`/templates/${templateName}/settings`, {
32+
waitUntil: "domcontentloaded",
33+
});
34+
checkbox = await page.waitForSelector("#require_active_version");
35+
await checkbox.scrollIntoViewIfNeeded();
36+
expect(await checkbox.isChecked()).toBe(true);
37+
});

0 commit comments

Comments
 (0)