- Notifications
You must be signed in to change notification settings - Fork925
chore: add e2e test for org groups#15853
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletionssite/e2e/api.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletionssite/e2e/helpers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletionssite/e2e/tests/organizationGroups.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
createGroup, | ||
createOrganization, | ||
createUser, | ||
setupApiCalls, | ||
} from "../api"; | ||
import { expectUrl } from "../expectUrl"; | ||
import { randomName, requiresLicense } from "../helpers"; | ||
import { beforeCoderTest } from "../hooks"; | ||
test.beforeEach(async ({ page }) => { | ||
await beforeCoderTest(page); | ||
await setupApiCalls(page); | ||
}); | ||
test("create group", async ({ page }) => { | ||
requiresLicense(); | ||
// Create a new organization | ||
const org = await createOrganization(); | ||
await page.goto(`/organizations/${org.name}`); | ||
// Navigate to groups page | ||
await page.getByText("Groups").click(); | ||
await expect(page).toHaveTitle(`Groups - Org ${org.name} - Coder`); | ||
// Create a new group | ||
await page.getByText("Create group").click(); | ||
await expect(page).toHaveTitle("Create Group - Coder"); | ||
const name = randomName(); | ||
await page.getByLabel("Name", { exact: true }).fill(name); | ||
const displayName = `Group ${name}`; | ||
await page.getByLabel("Display Name").fill(displayName); | ||
await page.getByLabel("Avatar URL").fill("/emojis/1f60d.png"); | ||
await page.getByRole("button", { name: "Submit" }).click(); | ||
await expectUrl(page).toHavePathName( | ||
`/organizations/${org.name}/groups/${name}`, | ||
); | ||
await expect(page).toHaveTitle(`${displayName} - Coder`); | ||
await expect(page.getByText("No members yet")).toBeVisible(); | ||
await expect(page.getByText(displayName)).toBeVisible(); | ||
// Add a user to the group | ||
const personToAdd = await createUser(org.id); | ||
await page.getByPlaceholder("User email or username").fill(personToAdd.email); | ||
await page.getByRole("option", { name: personToAdd.email }).click(); | ||
await page.getByRole("button", { name: "Add user" }).click(); | ||
const addedRow = page.locator("tr", { hasText: personToAdd.email }); | ||
await expect(addedRow).toBeVisible(); | ||
// Ensure we can't add a user who isn't in the org | ||
const otherOrg = await createOrganization(); | ||
const personToReject = await createUser(otherOrg.id); | ||
await page | ||
.getByPlaceholder("User email or username") | ||
.fill(personToReject.email); | ||
await expect(page.getByText("No users found")).toBeVisible(); | ||
// Remove someone from the group | ||
await addedRow.getByLabel("More options").click(); | ||
await page.getByText("Remove").click(); | ||
await expect(addedRow).not.toBeVisible(); | ||
// Delete the group | ||
await page.getByRole("button", { name: "Delete" }).click(); | ||
const dialog = page.getByTestId("dialog"); | ||
await dialog.getByLabel("Name of the group to delete").fill(name); | ||
await dialog.getByRole("button", { name: "Delete" }).click(); | ||
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`); | ||
}); | ||
test("change quota settings", async ({ page }) => { | ||
requiresLicense(); | ||
// Create a new organization and group | ||
const org = await createOrganization(); | ||
const group = await createGroup(org.id); | ||
// Go to settings | ||
await page.goto(`/organizations/${org.name}/groups/${group.name}`); | ||
await page.getByRole("button", { name: "Settings" }).click(); | ||
expectUrl(page).toHavePathName( | ||
`/organizations/${org.name}/groups/${group.name}/settings`, | ||
); | ||
// Update Quota | ||
await page.getByLabel("Quota Allowance").fill("100"); | ||
await page.getByRole("button", { name: "Submit" }).click(); | ||
// We should get sent back to the group page afterwards | ||
expectUrl(page).toHavePathName( | ||
`/organizations/${org.name}/groups/${group.name}`, | ||
); | ||
// ...and that setting should persist if we go back | ||
await page.getByRole("button", { name: "Settings" }).click(); | ||
await expect(page.getByLabel("Quota Allowance")).toHaveValue("100"); | ||
}); |
16 changes: 4 additions & 12 deletionssite/e2e/tests/organizationMembers.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionsite/src/pages/ManagementSettingsPage/GroupsPage/GroupPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletionsite/src/pages/ManagementSettingsPage/GroupsPage/GroupsPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletionssite/src/pages/ManagementSettingsPage/OrganizationMembersPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 15 additions & 7 deletionssite/src/pages/ManagementSettingsPage/OrganizationProvisionersPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.