From 726c5c62761003b92fea1d696fd4e3b62d27417f Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 1 Feb 2024 16:16:11 +0100 Subject: [PATCH] Ensure deleteAllUsers does not delete current user (#58320) --- .../e2e-test-utils-playwright/src/request-utils/users.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/request-utils/users.ts b/packages/e2e-test-utils-playwright/src/request-utils/users.ts index 0997a7f51b5cb0..11df5f37468ca6 100644 --- a/packages/e2e-test-utils-playwright/src/request-utils/users.ts +++ b/packages/e2e-test-utils-playwright/src/request-utils/users.ts @@ -5,6 +5,7 @@ import type { RequestUtils } from './index'; export interface User { id: number; + name: string; email: string; } @@ -110,8 +111,11 @@ async function deleteAllUsers( this: RequestUtils ) { // The users endpoint doesn't support batch request yet. const responses = await Promise.all( users - // Do not delete root user. - .filter( ( user: User ) => user.id !== 1 ) + // Do not delete neither root user nor the current user. + .filter( + ( user: User ) => + user.id !== 1 && user.name !== this.user.username + ) .map( ( user: User ) => deleteUser.bind( this )( user.id ) ) );