Skip to content

chore: clean up groups page #16259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 29, 2025
Prev Previous commit
Next Next commit
:^)
  • Loading branch information
aslilac committed Jan 24, 2025
commit 9d4c705183fc9930625d2a9fbc223d63a3fe9e5c
2 changes: 1 addition & 1 deletion site/e2e/tests/groups/addMembers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
getCurrentOrgId,
setupApiCalls,
} from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
import { defaultOrganizationName } from "../../constants";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
Expand Down
6 changes: 3 additions & 3 deletions site/e2e/tests/groups/addUsersToDefaultGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from "@playwright/test";
import { createUser, getCurrentOrgId, setupApiCalls } from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
import { defaultOrganizationName } from "../../constants";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
Expand All @@ -26,12 +26,12 @@ test(`Every user should be automatically added to the default '${DEFAULT_GROUP_N
Array.from({ length: numberOfMembers }, () => createUser(orgId)),
);

await page.goto(`${baseURL}/organization/${orgName}/groups`, {
await page.goto(`${baseURL}/organizations/${orgName}/groups`, {
waitUntil: "domcontentloaded",
});
await expect(page).toHaveTitle("Groups - Coder");

const groupRow = page.getByRole("row", { name: DEFAULT_GROUP_NAME });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, we try to use getByRole as much as possible, just curious why you switched this to getByText?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stopped working 🤷‍♀️ I tried to figure out what was going on but the dom looks basically identical to me. No idea why it broke.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it, I having been seeing the same type of things sometimes. Trying to figure out best practices to avoid test flakes.

const groupRow = page.getByText(DEFAULT_GROUP_NAME);
await groupRow.click();
await expect(page).toHaveTitle(`${DEFAULT_GROUP_NAME} - Coder`);

Expand Down
2 changes: 1 addition & 1 deletion site/e2e/tests/groups/createGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from "@playwright/test";
import { defaultOrganizationName } from "../../constants";
import { randomName, requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
import { defaultOrganizationName } from "../../constants";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
Expand Down
2 changes: 1 addition & 1 deletion site/e2e/tests/groups/removeGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from "@playwright/test";
import { createGroup, getCurrentOrgId, setupApiCalls } from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
import { defaultOrganizationName } from "../../constants";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
Expand Down
2 changes: 1 addition & 1 deletion site/e2e/tests/groups/removeMember.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
getCurrentOrgId,
setupApiCalls,
} from "../../api";
import { defaultOrganizationName } from "../../constants";
import { requiresLicense } from "../../helpers";
import { login } from "../../helpers";
import { beforeCoderTest } from "../../hooks";
import { defaultOrganizationName } from "../../constants";

test.beforeEach(async ({ page }) => {
beforeCoderTest(page);
Expand Down
4 changes: 2 additions & 2 deletions site/e2e/tests/organizationGroups.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test("create group", async ({ page }) => {

// Navigate to groups page
await page.getByRole("link", { name: "Groups" }).click();
await expect(page).toHaveTitle(`Groups - Org ${org.name} - Coder`);
await expect(page).toHaveTitle("Groups - Coder");

// Create a new group
await page.getByText("Create group").click();
Expand Down Expand Up @@ -72,7 +72,7 @@ test("create group", async ({ page }) => {
await expect(page.getByText("Group deleted successfully.")).toBeVisible();

await expectUrl(page).toHavePathName(`/organizations/${org.name}/groups`);
await expect(page).toHaveTitle(`Groups - Org ${org.name} - Coder`);
await expect(page).toHaveTitle("Groups - Coder");
});

test("change quota settings", async ({ page }) => {
Expand Down
2 changes: 1 addition & 1 deletion site/src/modules/management/DeploymentSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAuthenticated } from "contexts/auth/RequireAuth";
import { useDashboard } from "modules/dashboard/useDashboard";
import type { FC } from "react";
import { DeploymentSidebarView } from "./DeploymentSidebarView";
import { useDashboard } from "modules/dashboard/useDashboard";

/**
* A sidebar for deployment settings.
Expand Down
8 changes: 3 additions & 5 deletions site/src/pages/GroupsPage/GroupsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import GroupAdd from "@mui/icons-material/GroupAddOutlined";
import { Button } from "components/Button/Button";
import { getErrorMessage } from "api/errors";
import { groupsByOrganization } from "api/queries/groups";
import { organizationPermissions } from "api/queries/organizations";
import { Button } from "components/Button/Button";
import { EmptyState } from "components/EmptyState/EmptyState";
import { displayError } from "components/GlobalSnackbar/utils";
import { Loader } from "components/Loader/Loader";
Expand All @@ -14,8 +14,8 @@ import { Helmet } from "react-helmet-async";
import { useQuery } from "react-query";
import { Link as RouterLink } from "react-router-dom";
import { pageTitle } from "utils/page";
import GroupsPageView from "./GroupsPageView";
import { useGroupsSettings } from "./GroupsPageProvider";
import GroupsPageView from "./GroupsPageView";

export const GroupsPage: FC = () => {
const feats = useFeatureVisibility();
Expand Down Expand Up @@ -53,9 +53,7 @@ export const GroupsPage: FC = () => {
return (
<>
<Helmet>
<title>
{pageTitle("Groups", organization.display_name || organization.name)}
</title>
<title>{pageTitle("Groups")}</title>
</Helmet>

<Stack
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/GroupsPage/GroupsPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Interpolation, Theme } from "@emotion/react";
import AddOutlined from "@mui/icons-material/AddOutlined";
import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight";
import AvatarGroup from "@mui/material/AvatarGroup";
import { Button } from "components/Button/Button";
import Skeleton from "@mui/material/Skeleton";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
Expand All @@ -14,6 +13,7 @@ import type { Group } from "api/typesGenerated";
import { Avatar } from "components/Avatar/Avatar";
import { AvatarData } from "components/Avatar/AvatarData";
import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton";
import { Button } from "components/Button/Button";
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
import { EmptyState } from "components/EmptyState/EmptyState";
import { Paywall } from "components/Paywall/Paywall";
Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/UsersPage/UsersPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
PaginationContainer,
type PaginationResult,
} from "components/PaginationWidget/PaginationContainer";
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
import { Stack } from "components/Stack/Stack";
import { UserPlusIcon } from "lucide-react";
import type { ComponentProps, FC } from "react";
import { Link as RouterLink } from "react-router-dom";
import { UsersFilter } from "./UsersFilter";
import { UsersTable } from "./UsersTable/UsersTable";
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
import { Stack } from "components/Stack/Stack";

export interface UsersPageViewProps {
users?: readonly TypesGen.User[];
Expand Down
Loading