-
Notifications
You must be signed in to change notification settings - Fork 889
chore: add e2e tests for organization members #15807
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3da8fc7
wuuba
aslilac cd88542
hmm
aslilac 6e2bd03
fix dbmem `OrganizationMembers` implementation
aslilac d193bb1
>:(
aslilac d4fd10a
[_screaming intensifies_]
aslilac 0943342
specify org name
aslilac 85f72f8
:|
aslilac e1cde70
remove debugging code
aslilac fe0d4ae
fix userspage tests
aslilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,50 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { setupApiCalls } from "../api"; | ||
import { expectUrl } from "../expectUrl"; | ||
import { createUser, randomName, requiresLicense } from "../helpers"; | ||
import { beforeCoderTest } from "../hooks"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await beforeCoderTest(page); | ||
await setupApiCalls(page); | ||
}); | ||
|
||
test("add and remove organization member", async ({ page }) => { | ||
requiresLicense(); | ||
|
||
// Create a new organization to test | ||
await page.goto("/organizations/new", { waitUntil: "domcontentloaded" }); | ||
const name = randomName(); | ||
await page.getByLabel("Slug").fill(name); | ||
await page.getByLabel("Display name").fill(`Org ${name}`); | ||
await page.getByLabel("Description").fill(`Org description ${name}`); | ||
await page.getByLabel("Icon", { exact: true }).fill("/emojis/1f957.png"); | ||
await page.getByRole("button", { name: "Submit" }).click(); | ||
|
||
// Navigate to members page | ||
await expectUrl(page).toHavePathName(`/organizations/${name}`); | ||
await expect(page.getByText("Organization created.")).toBeVisible(); | ||
await page.getByText("Members").click(); | ||
|
||
// Add a user to the org | ||
const personToAdd = await createUser(page); | ||
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(); | ||
|
||
// Give them a role | ||
await addedRow.getByLabel("Edit user roles").click(); | ||
await page.getByText("Organization User Admin").click(); | ||
await page.getByText("Organization Template Admin").click(); | ||
await page.mouse.click(10, 10); // close the popover by clicking outside of it | ||
await expect(addedRow.getByText("Organization User Admin")).toBeVisible(); | ||
await expect(addedRow.getByText("+1 more")).toBeVisible(); | ||
|
||
// Remove them from the org | ||
await addedRow.getByLabel("More options").click(); | ||
await page.getByText("Remove").click(); // Click the "Remove" option | ||
await page.getByRole("button", { name: "Remove" }).click(); // Click "Remove" in the confirmation dialog | ||
await expect(addedRow).not.toBeVisible(); | ||
}); |
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
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 |
---|---|---|
@@ -1,71 +1,13 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { randomName } from "../../helpers"; | ||
import { test } from "@playwright/test"; | ||
import { createUser } from "../../helpers"; | ||
import { beforeCoderTest } from "../../hooks"; | ||
|
||
test.beforeEach(async ({ page }) => await beforeCoderTest(page)); | ||
|
||
test("create user with password", async ({ page, baseURL }) => { | ||
await page.goto(`${baseURL}/deployment/users`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
await expect(page).toHaveTitle("Users - Coder"); | ||
|
||
await page.getByRole("button", { name: "Create user" }).click(); | ||
await expect(page).toHaveTitle("Create User - Coder"); | ||
|
||
const name = randomName(); | ||
const userValues = { | ||
username: name, | ||
name: name, | ||
email: `${name}@coder.com`, | ||
loginType: "password", | ||
password: "s3cure&password!", | ||
}; | ||
|
||
await page.getByLabel("Username").fill(userValues.username); | ||
await page.getByLabel("Full name").fill(userValues.username); | ||
await page.getByLabel("Email").fill(userValues.email); | ||
await page.getByLabel("Login Type").click(); | ||
await page.getByRole("option", { name: "Password", exact: false }).click(); | ||
// Using input[name=password] due to the select element utilizing 'password' | ||
// as the label for the currently active option. | ||
const passwordField = page.locator("input[name=password]"); | ||
await passwordField.fill(userValues.password); | ||
await page.getByRole("button", { name: "Create user" }).click(); | ||
await expect(page.getByText("Successfully created user.")).toBeVisible(); | ||
|
||
await expect(page).toHaveTitle("Users - Coder"); | ||
await expect(page.locator("tr", { hasText: userValues.email })).toBeVisible(); | ||
test("create user with password", async ({ page }) => { | ||
await createUser(page); | ||
}); | ||
|
||
test("create user without full name is optional", async ({ page, baseURL }) => { | ||
await page.goto(`${baseURL}/deployment/users`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
await expect(page).toHaveTitle("Users - Coder"); | ||
|
||
await page.getByRole("button", { name: "Create user" }).click(); | ||
await expect(page).toHaveTitle("Create User - Coder"); | ||
|
||
const name = randomName(); | ||
const userValues = { | ||
username: name, | ||
email: `${name}@coder.com`, | ||
loginType: "password", | ||
password: "s3cure&password!", | ||
}; | ||
|
||
await page.getByLabel("Username").fill(userValues.username); | ||
await page.getByLabel("Email").fill(userValues.email); | ||
await page.getByLabel("Login Type").click(); | ||
await page.getByRole("option", { name: "Password", exact: false }).click(); | ||
// Using input[name=password] due to the select element utilizing 'password' | ||
// as the label for the currently active option. | ||
const passwordField = page.locator("input[name=password]"); | ||
await passwordField.fill(userValues.password); | ||
await page.getByRole("button", { name: "Create user" }).click(); | ||
await expect(page.getByText("Successfully created user.")).toBeVisible(); | ||
|
||
await expect(page).toHaveTitle("Users - Coder"); | ||
await expect(page.locator("tr", { hasText: userValues.email })).toBeVisible(); | ||
test("create user without full name", async ({ page }) => { | ||
await createUser(page, { name: "" }); | ||
}); |
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
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
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
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.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all taken verbatim from the existing
createUserWithPassword
test. It just seems like the kind of thing that's helpful to turn into a reusable function.