[e2e tests] Replace hardcoded default wp-env credentials (#50617)

This commit is contained in:
Adrian Moldovan 2024-08-13 11:54:37 +01:00 committed by GitHub
parent 8707e71eb3
commit eaa13c0151
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 30 additions and 19 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev

View File

@ -6,6 +6,7 @@ const { encodeCredentials } = require( '../../../utils/plugin-utils' );
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
const { setOption } = require( '../../../utils/options' );
const { admin } = require( '../../../test-data/data' );
const test = base.extend( {
assemblerPageObject: async ( { page }, use ) => {
@ -528,8 +529,8 @@ test.describe( 'Assembler -> Color Pickers', { tag: '@gutenberg' }, () => {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},

View File

@ -4,6 +4,7 @@ const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
const { setOption } = require( '../../../utils/options' );
const { encodeCredentials } = require( '../../../utils/plugin-utils' );
const { admin } = require( '../../../test-data/data' );
const test = base.extend( {
pageObject: async ( { page }, use ) => {
@ -179,8 +180,8 @@ test.describe( 'Assembler -> Homepage', { tag: '@gutenberg' }, () => {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},

View File

@ -1,4 +1,5 @@
const { encodeCredentials } = require( '../../../../utils/plugin-utils' );
const { admin } = require( '../../../../test-data/data' );
export class LogoPickerPage {
page;
@ -58,8 +59,8 @@ export class LogoPickerPage {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},

View File

@ -1,4 +1,5 @@
const { encodeCredentials } = require( '../../utils/plugin-utils' );
const { admin } = require( '../../test-data/data' );
export class CustomizeStorePage {
request;
@ -11,8 +12,8 @@ export class CustomizeStorePage {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},

View File

@ -1,5 +1,5 @@
const { test: baseTest, expect } = require( '../../fixtures/fixtures' );
const { customer } = require( '../../test-data/data' );
const { admin, customer } = require( '../../test-data/data' );
const emailContent = '#wp-mail-logging-modal-content-body-content';
const emailContentHtml = '#wp-mail-logging-modal-format-html';
@ -250,10 +250,10 @@ test.describe(
await page.goto( 'wp-login.php' );
await page
.getByLabel( 'Username or Email Address' )
.fill( 'admin' );
.fill( admin.username );
await page
.getByLabel( 'Password', { exact: true } )
.fill( 'password' );
.fill( admin.password );
await page.getByRole( 'button', { name: 'Log In' } ).click();
await page.goto(
`wp-admin/tools.php?page=wpml_plugin_log&s=${ encodeURIComponent(

View File

@ -1,5 +1,6 @@
const { test, expect } = require( '@playwright/test' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;
const { admin } = require( '../../test-data/data' );
const productPrice = '18.16';
const simpleProductName = 'Simple single product';
@ -100,8 +101,8 @@ test.describe(
page,
} ) => {
await page.goto( 'my-account' );
await page.locator( '#username' ).fill( 'admin' );
await page.locator( '#password' ).fill( 'password' );
await page.locator( '#username' ).fill( admin.username );
await page.locator( '#password' ).fill( admin.password );
await page.locator( 'text=Log in' ).click();
await page.goto( `product/${ simpleProductSlug }` );

View File

@ -1,12 +1,13 @@
const { encodeCredentials } = require( './plugin-utils' );
const { admin } = require( '../test-data/data' );
const setFeatureFlag = async ( request, baseURL, flagName, enable ) => {
const apiContext = await request.newContext( {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},
@ -23,8 +24,8 @@ const resetFeatureFlags = async ( request, baseURL ) => {
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},

View File

@ -2,6 +2,7 @@
* Internal dependencies
*/
import { encodeCredentials } from './plugin-utils';
const { admin } = require( '../test-data/data' );
export const setOption = async (
request,
@ -13,8 +14,8 @@ export const setOption = async (
baseURL,
extraHTTPHeaders: {
Authorization: `Basic ${ encodeCredentials(
'admin',
'password'
admin.username,
admin.password
) }`,
cookie: '',
},