Files
coder/site/e2e/global.setup.ts
T
Michael SmithandMcKayla Washburn 1d925ab043 fix: ensure user admins can always see users table (#15226)
Closes #15212

## Changes made
- Updated logic so that proxy config is only requested when appropriate,
instead of for all users on all deployment pages
- Split up the main context provider for the `/deployment` and
`/organizations` routes, and updated layout logic for
`ManagementSettingsLayout` layout component. This ensures the sidebar is
always visible, even if request errors happen
- Added additional routing safeguards to make sure that even if a user
can view one page in the deployment section, they won't be able to
navigate directly to any arbitrary deployment page
- Updated logic for sidebar navigation to ensure that nav items only
appear when the user truly has permission
- Centralized a lot of the orgs logic into the `useAuthenticated` hook
- Added additional check cases to the `permissions.tsx` file, to give
more granularity, and added missing type-checking
- Extended the API for the `RequirePermissions` component to let it
redirect users anywhere
- Updated some of our testing setup files to ensure that types were
defined correctly

---------

Co-authored-by: McKayla Washburn <mckayla@hey.com>
2024-10-29 01:06:33 -04:00

49 lines
1.9 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { API } from "api/api";
import { Language } from "pages/CreateUserPage/CreateUserForm";
import { setupApiCalls } from "./api";
import * as constants from "./constants";
import { expectUrl } from "./expectUrl";
import { storageState } from "./playwright.config";
test("setup deployment", async ({ page }) => {
await page.goto("/", { waitUntil: "domcontentloaded" });
await setupApiCalls(page);
const exists = await API.hasFirstUser();
// First user already exists, abort early. All tests execute this as a dependency,
// if you run multiple tests in the UI, this will fail unless we check this.
if (exists) {
return;
}
// Setup first user
await page.getByLabel(Language.usernameLabel).fill(constants.username);
await page.getByLabel(Language.emailLabel).fill(constants.email);
await page.getByLabel(Language.passwordLabel).fill(constants.password);
await page.getByTestId("create").click();
await expectUrl(page).toHavePathName("/workspaces");
await page.context().storageState({ path: storageState });
await page.getByTestId("button-select-template").isVisible();
// Setup license
if (constants.premiumTestsRequired || constants.license) {
// Make sure that we have something that looks like a real license
expect(constants.license).toBeTruthy();
expect(constants.license.length).toBeGreaterThan(92); // the signature alone should be this long
expect(constants.license.split(".").length).toBe(3); // otherwise it's invalid
await page.goto("/deployment/licenses", { waitUntil: "domcontentloaded" });
await expect(page).toHaveTitle("License Settings - Coder");
await page.getByText("Add a license").click();
await page.getByRole("textbox").fill(constants.license);
await page.getByText("Upload License").click();
await expect(
page.getByText("You have successfully added a license"),
).toBeVisible();
}
});