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

Flaky Jetpack E2E: revise Advertising: Promote spec to use the first post and to not create posts unnecessarily. #81563

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

worldomonation
Copy link
Contributor

@worldomonation worldomonation commented Sep 8, 2023

Related to: #80730, #81550.

Proposed Changes

This PR further revises the Advertising: Promote spec to stop the creation of unnecessary posts.
Furthermore, this PR also changes the selection method of the post from title-based to row number based,

Testing Instructions

Ensure the following build configurations are passing:

  • Calypso E2E (desktop)
  • Jetpack E2E Simple (mobile)
  • Jetpack E2E Simple (desktop)
  • Jetpack E2E AT (desktop)

This particular PR survived 50 rounds of repeated testing:

image

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

@worldomonation worldomonation self-assigned this Sep 8, 2023
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@worldomonation worldomonation marked this pull request as ready for review September 11, 2023 05:22
@worldomonation worldomonation requested a review from a team as a code owner September 11, 2023 05:22
@worldomonation worldomonation requested a review from a team September 11, 2023 05:22
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 11, 2023
- implement new method to see if there are posts on the site.

test/e2e/specs/tools/advertising__promote.ts
- stop creating new post unnecessarily
@worldomonation worldomonation force-pushed the fix/jetpack-e2e-advertising-promote-first-post branch from f93ca7d to 19b9206 Compare September 11, 2023 05:24
Copy link
Contributor

@karenroldan karenroldan left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀 left a couple of non-blocking suggestions. Feel free to merge! 👍🏻

* @param param1 Keyed object parameter.
* @param {SitePostState} param1.state State of the published post.
*/
async siteHasPost(
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): We can also check for the expected response structure & API-specific errors.

if ( response.hasOwnProperty( 'error' ) ) {
	throw new Error(
		`${ ( response as ErrorResponse ).error }: ${ ( response as ErrorResponse ).message }`
	);
}

if (!response || !response.counts || !response.counts.all) {
	throw new Error('Unexpected response structure');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I played around with this a bit, and it appears this endpoint doesn't ever return an error - it only returns a 404 (if anything in the path is wrong, for example site ID) or the actual values.

params
);

return response.counts.all[ state ] !== 0 ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): We can simplify this to return response.counts.all[state] !== 0 since it already returns a boolean value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, what an embarrassingly unnecessary ternary.

Copy link
Contributor

Choose a reason for hiding this comment

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

We've all been there! 😄

- remove unnecessary ternary

packages/calypso-e2e/src/types/rest-api-client.types.ts
- add new type to type check the response from PostCounts endpoint.
@worldomonation worldomonation removed the request for review from a team September 11, 2023 13:42
@worldomonation worldomonation merged commit eb0925a into trunk Sep 11, 2023
3 checks passed
@worldomonation worldomonation deleted the fix/jetpack-e2e-advertising-promote-first-post branch September 11, 2023 15:21
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants