Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Utils: Ensure deleteAllUsers does not delete current user #58320

Merged
merged 1 commit into from Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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