-
Notifications
You must be signed in to change notification settings - Fork 928
chore(site): add e2e to test add and remove user #12851
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
13 commits
Select commit
Hold shift + click to select a range
aae70a0
chore(site): add e2e to test add and remove user
BrunoQuaresma 2e21bb8
Fix JS test
BrunoQuaresma 055d787
Make tests more atomic and safe
BrunoQuaresma 63b4aaf
Make it easier to know when redirect happens
BrunoQuaresma 1763b27
Remove unused file
BrunoQuaresma f08b42e
add logs to debug
BrunoQuaresma 6f7a949
Add more console.log around
BrunoQuaresma 31f55f9
Verify headers
BrunoQuaresma adb1537
Check headers
BrunoQuaresma 54b84a9
Log error
BrunoQuaresma 314b3da
Use 127.0.0.1
BrunoQuaresma 8f15ff3
Remove consoles
BrunoQuaresma 772b757
Remove missed console
BrunoQuaresma 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { randomName } 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}/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(); | ||
}); |
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,33 @@ | ||
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 user", async ({ page, baseURL }) => { | ||
await setupApiCalls(page); | ||
const currentUser = await API.getAuthenticatedUser(); | ||
const name = randomName(); | ||
const user = await API.createUser({ | ||
email: `${name}@coder.com`, | ||
username: name, | ||
password: "s3cure&password!", | ||
login_type: "password", | ||
disable_login: false, | ||
organization_id: currentUser.organization_ids[0], | ||
}); | ||
|
||
await page.goto(`${baseURL}/users`, { waitUntil: "domcontentloaded" }); | ||
await expect(page).toHaveTitle("Users - Coder"); | ||
|
||
const userRow = page.locator("tr", { hasText: user.email }); | ||
await userRow.getByRole("button", { name: "More options" }).click(); | ||
await userRow.getByText("Delete", { exact: false }).click(); | ||
|
||
const dialog = page.getByTestId("dialog"); | ||
await dialog.getByLabel("Name of the user to delete").fill(user.username); | ||
await dialog.getByRole("button", { name: "Delete" }).click(); | ||
|
||
await expect(page.getByText("Successfully deleted the user.")).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
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
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.
Uh oh!
There was an error while loading. Please reload this page.