-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests - Move HTTP requests metadata from Cypress to Playwright
- Loading branch information
Showing
3 changed files
with
236 additions
and
243 deletions.
There are no files selected for viewing
222 changes: 0 additions & 222 deletions
222
tests/end2end/cypress/integration/requests-metadata-ghaction.js
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,40 +1,38 @@ | ||
import { test as setup } from '@playwright/test'; | ||
import path from 'path'; | ||
import { Page } from '@playwright/test'; | ||
|
||
const user_in_group_aFile = path.join(__dirname, './.auth/user_in_group_a.json'); | ||
|
||
setup('authenticate as user_in_group_a', async ({ page }) => { | ||
/** | ||
* Performs the authentication steps | ||
* @param {Page} page The page object | ||
* @param {string} login The login | ||
* @param {string} password The password | ||
* @param {string} user_file The path to the file where the cookies will be stored | ||
*/ | ||
export async function auth_using_login(page: Page, login: string, password: string, user_file: string) { | ||
// Perform authentication steps. Replace these actions with your own. | ||
await page.goto('admin.php/auth/login?auth_url_return=%2Findex.php'); | ||
await page.locator('#jforms_jcommunity_login_auth_login').fill('user_in_group_a'); | ||
await page.locator('#jforms_jcommunity_login_auth_password').fill('admin'); | ||
await page.locator('#jforms_jcommunity_login_auth_login').fill(login); | ||
await page.locator('#jforms_jcommunity_login_auth_password').fill(password); | ||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
// Wait until the page receives the cookies. | ||
// | ||
// Sometimes login flow sets cookies in the process of several redirects. | ||
// Wait for the final URL to ensure that the cookies are actually set. | ||
await page.waitForURL('index.php'); | ||
|
||
// End of authentication steps. | ||
await page.context().storageState({ path: user_file }); | ||
} | ||
|
||
await page.context().storageState({ path: user_in_group_aFile }); | ||
setup('authenticate as user_in_group_a', async ({ page }) => { | ||
await auth_using_login(page, 'user_in_group_a', 'admin', path.join(__dirname, './.auth/user_in_group_a.json')); | ||
}); | ||
|
||
const adminFile = path.join(__dirname, './.auth/admin.json'); | ||
|
||
setup('authenticate as admin', async ({ page }) => { | ||
// Perform authentication steps. Replace these actions with your own. | ||
await page.goto('admin.php/auth/login?auth_url_return=%2Findex.php'); | ||
await page.locator('#jforms_jcommunity_login_auth_login').fill('admin'); | ||
await page.locator('#jforms_jcommunity_login_auth_password').fill('admin'); | ||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
// Wait until the page receives the cookies. | ||
// | ||
// Sometimes login flow sets cookies in the process of several redirects. | ||
// Wait for the final URL to ensure that the cookies are actually set. | ||
await page.waitForURL('index.php'); | ||
|
||
// End of authentication steps. | ||
await auth_using_login(page, 'admin', 'admin', path.join(__dirname, './.auth/admin.json')); | ||
}); | ||
|
||
await page.context().storageState({ path: adminFile }); | ||
setup('authenticate as publisher', async ({ page }) => { | ||
await auth_using_login(page, 'publisher', 'admin', path.join(__dirname, './.auth/publisher.json')); | ||
}); |
Oops, something went wrong.