From d231ecf4541d3ef30108a32a469803ccafb7be30 Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:43:36 +0200 Subject: [PATCH] Build/Test Tools: Give each application passwords E2E test its own user. Each test used the admin user and revoked all of its application passwords. When two copies of the spec ran at the same time in the parallel project, each copy deleted the passwords of the other. See #66392. --- .../profile/applications-passwords.test.js | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/tests/e2e/specs/profile/applications-passwords.test.js b/tests/e2e/specs/profile/applications-passwords.test.js index 2e9a359e798ca..cfc17856a92ab 100644 --- a/tests/e2e/specs/profile/applications-passwords.test.js +++ b/tests/e2e/specs/profile/applications-passwords.test.js @@ -1,23 +1,33 @@ /** - * WordPress dependencies + * Internal dependencies */ -import { test, expect } from '@wordpress/e2e-test-utils-playwright'; +import { test, expect } from '../../fixtures'; +import { signIn } from '../../fixtures/user'; const TEST_APPLICATION_NAME = 'Test Application'; test.describe( 'Manage applications passwords', () => { test.use( { - applicationPasswords: async ( { requestUtils, admin, page }, use ) => { - const applicationPasswords = new ApplicationPasswords( { - requestUtils, - admin, - page, + storageState: { cookies: [], origins: [] }, + // Each test uses its own user, so parallel copies do not see each other's application passwords. + applicationPasswords: async ( + { requestUtils, admin, page, userFactory }, + use + ) => { + const { user, username, password } = await userFactory.create( { + roles: [ 'subscriber' ], } ); - - // Revoke before the test too: a run that was interrupted leaves passwords behind. - await applicationPasswords.delete(); - await use( applicationPasswords ); - await applicationPasswords.delete(); + await signIn( page, username, password ); + await expect( page ).toHaveURL( /\/wp-admin\/profile\.php/ ); + + await use( + new ApplicationPasswords( { + requestUtils, + admin, + page, + userId: user.id, + } ) + ); }, } ); @@ -93,10 +103,11 @@ test.describe( 'Manage applications passwords', () => { } ); class ApplicationPasswords { - constructor( { requestUtils, page, admin }) { + constructor( { requestUtils, page, admin, userId } ) { this.requestUtils = requestUtils; this.page = page; this.admin = admin; + this.userId = userId; } async create(applicationName = TEST_APPLICATION_NAME) { @@ -113,14 +124,7 @@ class ApplicationPasswords { async get() { return this.requestUtils.rest( { method: 'GET', - path: '/wp/v2/users/me/application-passwords', - } ); - } - - async delete() { - await this.requestUtils.rest( { - method: 'DELETE', - path: '/wp/v2/users/me/application-passwords', + path: `/wp/v2/users/${ this.userId }/application-passwords`, } ); } }