-
-
Notifications
You must be signed in to change notification settings - Fork 173
UI Tests for username change on /settings page. #1203
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
base: develop
Are you sure you want to change the base?
Changes from 6 commits
67c5c4f
e6883a5
87038df
01c19f8
071f93a
f9140cf
fcd1dbb
2b779b6
c6949d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import test from "@playwright/test"; | ||
| import { test, expect } from "@playwright/test"; | ||
| import { loggedInAsUserOne } from "./utils"; | ||
|
|
||
| test.describe("Unauthenticated setttings Page", () => { | ||
|
|
@@ -10,6 +10,38 @@ test.describe("Authenticated settings Page", () => { | |
| test.beforeEach(async ({ page }) => { | ||
| await loggedInAsUserOne(page); | ||
| }); | ||
| // | ||
| // Replace with tests for authenticated users | ||
|
|
||
| // Test for changing username | ||
| test('Username input field', async ({ page }) => { | ||
| await page.goto('http://localhost:3000/settings', { timeout: 30000 }); | ||
|
||
|
|
||
| // Wait for the username input field to be visible | ||
| await page.locator('input[id="username"]').waitFor(); | ||
|
|
||
| // Test that the input field is visible and has the correct attributes | ||
| const inputField = page.locator('input[id="username"]'); | ||
| await expect(inputField).toBeVisible(); | ||
| await expect(inputField).toHaveAttribute('type', 'text'); | ||
| await expect(inputField).toHaveAttribute('autocomplete', 'username'); | ||
|
|
||
| // Test that the error message appears when the input field is invalid | ||
| await inputField.fill('45&p^x#@!96%*()'); | ||
| await page.locator('button[type="submit"]').click(); | ||
| const errorMessage = page.locator('p:text-is("Username can only contain alphanumerics and dashes.")') | ||
| await expect(errorMessage).toBeVisible(); | ||
| await expect(errorMessage).toHaveText('Username can only contain alphanumerics and dashes.'); | ||
petercr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Reset the form | ||
| await page.locator('button:has-text("Reset")').click(); | ||
|
|
||
| // Test that the input field can be filled with a valid value and saves it | ||
| await inputField.fill('codu-rules'); | ||
| await page.locator('button[type="submit"]').click(); | ||
| const toastError = page.locator('.toast-success'); | ||
| await expect(toastError).toBeVisible(); | ||
| await expect(toastError).toBeHidden(); | ||
petercr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Reload the page and check that the input field has the correct value | ||
| await page.reload(); | ||
| await expect(inputField).toHaveValue('codu-rules'); | ||
|
||
| }); | ||
petercr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
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.
Can we change this to authenticated settings page. Because the user is authenticated for these tests
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.
I'm not sure exactly what you're saying here?
Did you want a separate file for auth vs. un-auth tests, because doesn't a user have to be logged in to edit their profile?
I guess I could use more detail on this ππ»
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.
Your new test is ran inside a test suite called 'Unauthenticated setttings Page'
But this is an authenticated test because users need to login to change their username.
If you just change the name of the test it will be fixed