Skip to content

chore(site): add e2e tests for groups #12866

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 11 commits into from
Apr 5, 2024
Merged
Prev Previous commit
Next Next commit
Add remove group test
  • Loading branch information
BrunoQuaresma committed Apr 4, 2024
commit 89237fca55de999f82ccdf8f938e6827d996ee97
35 changes: 35 additions & 0 deletions site/e2e/tests/groups/removeGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect } from "@playwright/test";
import * as API from "api/api";
import { randomName, setupApiCalls } from "../../helpers";
import { beforeCoderTest } from "../../hooks";

test.beforeEach(async ({ page }) => await beforeCoderTest(page));

test("remove group", async ({ page, baseURL }) => {
await setupApiCalls(page);
const currentUser = await API.getAuthenticatedUser();
const name = randomName();
const orgId = currentUser.organization_ids[0];
const group = await API.createGroup(orgId, {
name,
display_name: `Display Name of ${name}`,
avatar_url: "/emojis/1f60d.png",
quota_allowance: 0,
});

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

const groupRow = page.locator("tr", { hasText: group.display_name });
await groupRow.click();

await expect(page).toHaveTitle(`${group.display_name} - Coder`);
await page.getByRole("button", { name: "Delete" }).click();

const dialog = page.getByTestId("dialog");
await dialog.getByLabel("Name of the group to delete").fill(group.name);
await dialog.getByRole("button", { name: "Delete" }).click();
await expect(page.getByText("Group deleted successfully.")).toBeVisible();

await expect(page).toHaveTitle("Groups - Coder");
});
1 change: 1 addition & 0 deletions site/src/pages/GroupsPage/GroupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export const GroupPage: FC = () => {
onConfirm={async () => {
try {
await deleteGroupMutation.mutateAsync(groupId);
displaySuccess("Group deleted successfully.");
navigate("/groups");
} catch (error) {
displayError(getErrorMessage(error, "Failed to delete group."));
Expand Down