Skip to content

Commit

Permalink
Ensure deleteAllUsers does not delete current user (#58320)
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart authored Feb 1, 2024
1 parent 2a6b7c1 commit 726c5c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/e2e-test-utils-playwright/src/request-utils/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { RequestUtils } from './index';

export interface User {
id: number;
name: string;
email: string;
}

Expand Down Expand Up @@ -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 ) )
);

Expand Down

0 comments on commit 726c5c6

Please sign in to comment.