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

Remove 'response.deleted' check #45992

Merged
merged 4 commits into from
Nov 24, 2022

Conversation

albarin
Copy link
Contributor

@albarin albarin commented Nov 23, 2022

What?

The goal of this change is to prevent the tests using the deteleAllTemplates from failing when the response is undefined or null.

Why?

When a template couldn't be deleted the response variable is null, but the code is trying to access the deleted property on it, and giving this error:

TypeError: Cannot read properties of undefined (reading 'deleted')

How?

Removing the response.deleted check. if deleted is present it will be always true, any other error will make the request fail and it'll go on the catch.

@codesandbox
Copy link

codesandbox bot commented Nov 23, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 23, 2022
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @albarin! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

Copy link

@robinwpdeveloper robinwpdeveloper left a comment

Choose a reason for hiding this comment

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

Pretty simple fix and does null check properly.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Tool] E2E Test Utils /packages/e2e-test-utils labels Nov 23, 2022
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.

Thanks, @albarin!

@albarin albarin changed the title Check if response is not null or undefined before accessing the 'deleted' property Remove 'response.deleted' check Nov 24, 2022
@albarin albarin force-pushed the fix-delete-all-templates branch from 6d9b9d5 to a79ab30 Compare November 24, 2022 09:32
@ntsekouras ntsekouras enabled auto-merge (squash) November 24, 2022 09:56
@ntsekouras
Copy link
Contributor

Thank you for your contribution @albarin and congrats on your first commit in Gutenberg 🎉

@ntsekouras ntsekouras merged commit 735b64d into WordPress:trunk Nov 24, 2022
@github-actions
Copy link

Congratulations on your first merged pull request, @albarin! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Tool] 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.

4 participants