Extract pw common functions

This commit is contained in:
Alex P 2023-05-29 09:47:42 +03:00
parent 9b15b70e63
commit 87ac3f1650
No known key found for this signature in database
GPG key ID: 54487A734A204D71
6 changed files with 137 additions and 155 deletions

View file

@ -0,0 +1,26 @@
const {
WP_MERCHANT_USER,
WP_MERCHANT_PASSWORD,
WP_CUSTOMER_USER,
WP_CUSTOMER_PASSWORD,
} = process.env;
export const loginAsAdmin = async (page) => {
await page.goto('/wp-admin');
await page.locator('input[name="log"]').fill(WP_MERCHANT_USER);
await page.locator('input[name="pwd"]').fill(WP_MERCHANT_PASSWORD);
await Promise.all([
page.waitForNavigation(),
page.locator('text=Log In').click()
]);
}
export const loginAsCustomer = async (page) => {
await page.goto('/wp-admin');
await page.locator('input[name="log"]').fill(WP_CUSTOMER_USER);
await page.locator('input[name="pwd"]').fill(WP_CUSTOMER_PASSWORD);
await Promise.all([
page.waitForNavigation(),
page.locator('text=Log In').click()
]);
}