Skip to content

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 9 commits into from
Dec 11, 2024
Merged

Conversation

aslilac
Copy link
Member

@aslilac aslilac commented Dec 9, 2024

No description provided.

Comment on lines +1004 to +1030
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();
Copy link
Member Author

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.

@aslilac aslilac marked this pull request as ready for review December 11, 2024 01:09
@aslilac aslilac requested a review from jaaydenh December 11, 2024 01:09
Copy link
Contributor

@jaaydenh jaaydenh left a 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.

@aslilac
Copy link
Member Author

aslilac commented Dec 11, 2024

Yeah, custom roles have their own ticket for adding tests. That's up next.

@aslilac aslilac merged commit 06e7739 into main Dec 11, 2024
33 checks passed
@aslilac aslilac deleted the lilac/e2e-org-members branch December 11, 2024 22:48
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2024
@aslilac
Copy link
Member Author

aslilac commented Dec 11, 2024

Closes coder/internal#165

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants