-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
E2e Test Fixes #25058
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
E2e Test Fixes #25058
Changes from all commits
8fd961c
7182dc9
eef1e5b
40c02fc
aedd0e1
9d5280d
14dc954
6abecd1
1ade3aa
daf8251
ee2e1d4
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 |
---|---|---|
|
@@ -16,32 +16,30 @@ test('Load Homepage', async ({page}) => { | |
test('Test Register Form', async ({page}, workerInfo) => { | ||
const response = await page.goto('/user/sign_up'); | ||
await expect(response?.status()).toBe(200); // Status OK | ||
await page.type('input[name=user_name]', `e2e-test-${workerInfo.workerIndex}`); | ||
await page.type('input[name=email]', `e2e-test-${workerInfo.workerIndex}@test.com`); | ||
await page.type('input[name=password]', 'test123'); | ||
await page.type('input[name=retype]', 'test123'); | ||
await page.click('form button.ui.green.button:visible'); | ||
await page.locator('input#user_name').fill(`e2e-test-${workerInfo.workerIndex}`); | ||
await page.locator('input#email').fill(`e2e-test-${workerInfo.workerIndex}@test.com`); | ||
await page.locator('input#password').fill('test123'); | ||
await page.locator('input#retype').fill('test123'); | ||
await page.locator('form button.ui.green.button:visible').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
// Make sure we routed to the home page. Else login failed. | ||
await expect(page.url()).toBe(`${workerInfo.project.use.baseURL}/`); | ||
await expect(page.locator('.dashboard-navbar span>img.ui.avatar')).toBeVisible(); | ||
await expect(page.locator('.ui.positive.message.flash-success')).toHaveText('Account was successfully created.'); | ||
|
||
save_visual(page); | ||
await save_visual(page); | ||
}); | ||
|
||
test('Test Login Form', async ({page}, workerInfo) => { | ||
const response = await page.goto('/user/login'); | ||
await expect(response?.status()).toBe(200); // Status OK | ||
|
||
await page.type('input[name=user_name]', `user2`); | ||
await page.type('input[name=password]', `password`); | ||
await page.click('form button.ui.green.button:visible'); | ||
|
||
await page.waitForLoadState('networkidle'); | ||
await page.locator('input#user_name').fill('user2'); | ||
await page.locator('input#password').fill('password'); | ||
await page.locator('form button.ui.green.button:visible').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also a rather suboptimal selector. Afraid we have to add some class names to make tests more robust against class name changes. |
||
|
||
await expect(page.url()).toBe(`${workerInfo.project.use.baseURL}/`); | ||
|
||
save_visual(page); | ||
await save_visual(page); | ||
}); | ||
|
||
test('Test Logged In User', async ({browser}, workerInfo) => { | ||
|
@@ -53,5 +51,5 @@ test('Test Logged In User', async ({browser}, workerInfo) => { | |
// Make sure we routed to the home page. Else login failed. | ||
await expect(page.url()).toBe(`${workerInfo.project.use.baseURL}/`); | ||
|
||
save_visual(page); | ||
await save_visual(page); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @ts-check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this for? |
||
import {test, expect} from '@playwright/test'; | ||
import {login_user, save_visual, load_logged_in_context} from './utils_e2e.js'; | ||
|
||
test.beforeAll(async ({browser}, workerInfo) => { | ||
await login_user(browser, workerInfo, 'user2'); | ||
}); | ||
|
||
test('Test New Issue', async ({browser}, workerInfo) => { | ||
const context = await load_logged_in_context(browser, workerInfo, 'user2'); | ||
|
||
const page = await context.newPage(); | ||
|
||
let response = await page.goto('/user2/repo2/issues'); | ||
await expect(response?.status()).toBe(200); // Status OK | ||
|
||
// Click New Issue | ||
await page.getByRole('link', {name: 'New Issue'}).click(); | ||
|
||
await expect(page).toHaveURL(`${workerInfo.project.use.baseURL}/user2/repo2/issues/new`); | ||
|
||
await page.locator('[name=title]').fill(`New Issue: ${workerInfo.title}`); | ||
await page.locator('[name=content]').fill(` | ||
# Test Header | ||
|
||
- [ ] Unchecked list item | ||
- [ ] Second unchecked list item | ||
- [x] Checked list item | ||
`); | ||
|
||
// Switch to preview | ||
const previewButton = page.getByText('Preview'); | ||
await previewButton.click(); | ||
await expect(previewButton).toHaveClass(/(^|\W)active($|\W)/); | ||
await expect(page.locator('[data-tab-panel=markdown-previewer]')).toBeVisible(); | ||
await expect(page.getByRole('heading', {name: 'Test Header'})).toBeVisible(); | ||
|
||
// Create issue | ||
await page.getByRole('button', {name: 'Create Issue'}).click(); | ||
await expect(page).toHaveURL(`${workerInfo.project.use.baseURL}/user2/repo2/issues/3`); | ||
|
||
await expect(page.getByRole('heading', {name: 'Test Header'})).toBeVisible(); | ||
|
||
// Test checkboxes | ||
const checkboxes = page.locator('.task-list-item > [type=checkbox]'); | ||
await expect(checkboxes).toHaveCount(3); | ||
await expect(checkboxes.first()).not.toBeChecked(); | ||
const checkboxPostPromise = page.waitForResponse(`${workerInfo.project.use.baseURL}/user2/repo2/issues/3/content`); | ||
await checkboxes.first().click(); // Toggle checkbox | ||
await expect(checkboxes.first()).toBeChecked(); | ||
expect((await checkboxPostPromise).status()).toBe(200); // Wait for successful content post response | ||
response = await page.reload(); // Reload page to check consistency | ||
await expect(checkboxes.first()).toBeChecked(); | ||
|
||
await save_visual(page); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,16 @@ const LOGIN_PASSWORD = 'password'; | |
export async function login_user(browser, workerInfo, user) { | ||
// Set up a new context | ||
const context = await browser.newContext(); | ||
const page = await context.newPage(); | ||
|
||
// Route to login page | ||
// Note: this could probably be done more quickly with a POST | ||
const response = await page.goto('/user/login'); | ||
await expect(response?.status()).toBe(200); // Status OK | ||
|
||
// Fill out form | ||
await page.type('input[name=user_name]', user); | ||
await page.type('input[name=password]', LOGIN_PASSWORD); | ||
await page.click('form button.ui.green.button:visible'); | ||
|
||
await page.waitForLoadState('networkidle'); | ||
|
||
await expect(page.url(), {message: `Failed to login user ${user}`}).toBe(`${workerInfo.project.use.baseURL}/`); | ||
|
||
const response = await context.request.post('/user/login', { | ||
form: { | ||
'user_name': user, | ||
'password': LOGIN_PASSWORD | ||
} | ||
}); | ||
expect(response).toBeOK(); | ||
// Save state | ||
await context.storageState({path: `${ARTIFACTS_PATH}/state-${user}-${workerInfo.workerIndex}.json`}); | ||
|
||
|
@@ -53,7 +47,7 @@ export async function save_visual(page) { | |
timeout: 20000, | ||
mask: [ | ||
page.locator('.dashboard-navbar span>img.ui.avatar'), | ||
page.locator('.ui.dropdown.jump.item span>img.ui.avatar'), | ||
page.locator('.ui.dropdown.jump.item.tooltip span>img.ui.avatar'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No better selector available? Maybe add a class name? This will break too easily. |
||
], | ||
}); | ||
} | ||
|
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 surposed ths
fmt.Printf
passes the linter.