Skip to content
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

[Backport release_3_9] Tests - Move HTTP requests metadata from Cypress to Playwright #5241

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 0 additions & 222 deletions tests/end2end/cypress/integration/requests-metadata-ghaction.js

This file was deleted.

41 changes: 20 additions & 21 deletions tests/end2end/playwright/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
import { test as setup } from '@playwright/test';
// @ts-ignore
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'));
});
Loading
Loading