-
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
Conversation
await page.goto("/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 username = userValues.username ?? randomName(); | ||
const name = userValues.name ?? username; | ||
const email = userValues.email ?? `${username}@coder.com`; | ||
const password = userValues.password || "s3cure&password!"; | ||
|
||
await page.getByLabel("Username").fill(username); | ||
if (name) { | ||
await page.getByLabel("Full name").fill(name); | ||
} | ||
await page.getByLabel("Email").fill(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(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: email })).toBeVisible(); |
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.
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.
Overall looks good. How about adding a test to verify a user cannot edit their own roles?
Also, in the future once this PR and the custom roles e2e PR is merged. I think it could be useful to create a custom role and test assigning the custom role to a user.
Yeah, custom roles have their own ticket for adding tests. That's up next. |
Closes coder/internal#165 |
No description provided.