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

Conversation

WunderBart
Copy link
Member

@WunderBart WunderBart commented Jan 26, 2024

What?

When calling deleteAllUsers, let's ensure we don't attempt to delete the current user, which can be a non-admin user.

Testing Instructions

Create a non-admin account and provide the credentials (export WP_USERNAME and WP_PASSWORD). Run e.g. the autocomplete-and-mentions.spec.js suite and ensure it doesn't attempt to delete the current user in the afterAll hook.

@WunderBart WunderBart self-assigned this Jan 26, 2024
@WunderBart WunderBart added the [Package] E2E Test Utils /packages/e2e-test-utils label Jan 26, 2024
@WunderBart WunderBart marked this pull request as ready for review January 26, 2024 15:21
@Mamaduka
Copy link
Member

What do you mean by non-admin user? A user with different username that default one for tests?

Should we just check against username which should be unique? Because ID = 1 isn’t always guaranteed.

@Mamaduka Mamaduka added the [Type] Bug An existing feature does not function as intended label Jan 26, 2024
@WunderBart
Copy link
Member Author

WunderBart commented Feb 1, 2024

What do you mean by non-admin user? A user with different username that default one for tests?

Yep! Basically a user that is currently logged in and is not Admin (the default account).

Should we just check against username which should be unique? Because ID = 1 isn’t always guaranteed.

Oh, I haven't changed that bit. I thought the default root account has always id == 1, no? We can change that to compare against "Admin" username instead if that's more solid!

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the default root account has always id == 1, no?

Auto incremented IDs are never guaranteed IMO. But logic has been working so far so no need to change it yet 😄

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry forgot to approve.

@WunderBart
Copy link
Member Author

WunderBart commented Feb 1, 2024

Ugh, I just noticed that it should be OR not AND. It should filter out either the id=1 or the current user by username. Will fix that shortly.

edit: Lol nope, it's all good actually! 😅

@WunderBart WunderBart merged commit 726c5c6 into trunk Feb 1, 2024
57 of 61 checks passed
@WunderBart WunderBart deleted the fix/e2e-util-remove-all-users branch February 1, 2024 15:16
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants