Skip to content

Commit 4246349

Browse files
committed
e2e test
1 parent 94a8338 commit 4246349

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

site/e2e/api.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ export const createGroup = async (orgId: string) => {
5353
return group;
5454
};
5555

56+
export const createOrganization = async () => {
57+
const name = randomName();
58+
const org = await API.createOrganization({
59+
name,
60+
display_name: `Org ${name}`,
61+
description: `Org description ${name}`,
62+
icon: "/emojis/1f957.png",
63+
});
64+
return org;
65+
};
66+
5667
export async function verifyConfigFlagBoolean(
5768
page: Page,
5869
config: DeploymentConfig,

site/e2e/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default defineConfig({
147147
gitAuth.validatePath,
148148
),
149149
CODER_PPROF_ADDRESS: "127.0.0.1:" + coderdPProfPort,
150-
CODER_EXPERIMENTS: e2eFakeExperiment1 + "," + e2eFakeExperiment2,
150+
CODER_EXPERIMENTS: `multi-organization,${e2eFakeExperiment1},${e2eFakeExperiment2}`,
151151

152152
// Tests for Deployment / User Authentication / OIDC
153153
CODER_OIDC_ISSUER_URL: "https://accounts.google.com",

site/e2e/tests/organizations.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { test, expect } from "@playwright/test";
2+
import {
3+
createGroup,
4+
createOrganization,
5+
getCurrentOrgId,
6+
setupApiCalls,
7+
} from "../api";
8+
import { requiresEnterpriseLicense } from "../helpers";
9+
import { beforeCoderTest } from "../hooks";
10+
import { expectUrl } from "../expectUrl";
11+
12+
test.beforeEach(async ({ page }) => await beforeCoderTest(page));
13+
14+
test("create and delete organization", async ({ page, baseURL }) => {
15+
requiresEnterpriseLicense();
16+
await setupApiCalls(page);
17+
18+
// Create an organzation
19+
await page.goto(`${baseURL}/organizations/new`, {
20+
waitUntil: "domcontentloaded",
21+
});
22+
23+
await page.getByLabel("Name", { exact: true }).fill("floop");
24+
await page.getByLabel("Display name").fill("Floop");
25+
await page.getByLabel("Description").fill("Org description floop");
26+
await page.getByLabel("Icon", { exact: true }).fill("/emojis/1f957.png");
27+
28+
await page.getByRole("button", { name: "Submit" }).click();
29+
30+
// Expect to be redirected to the new organization
31+
await expectUrl(page).toHavePathName("/organizations/floop");
32+
await expect(page.getByText("Organization created.")).toBeVisible();
33+
34+
await page.getByRole("button", { name: "Delete this organization" }).click();
35+
const dialog = page.getByTestId("dialog");
36+
await dialog.getByLabel("Name").fill("floop");
37+
await dialog.getByRole("button", { name: "Delete" }).click();
38+
await expect(page.getByText("Organization deleted.")).toBeVisible();
39+
});

0 commit comments

Comments
 (0)