-
Notifications
You must be signed in to change notification settings - Fork 296
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
Fix/10036-duplicate-survey-triggers #10167
base: develop
Are you sure you want to change the base?
Conversation
Build files for 256306d are ready:
|
Size Change: +94 B (0%) Total Size: 2 MB
ℹ️ View Unchanged
|
jest.mock( 'react-use', () => ( { | ||
...jest.requireActual( 'react-use' ), | ||
useIntersection: () => ( { | ||
isIntersecting: true, | ||
} ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this wasn't broken before. The addition of requireActual
here is something we do elsewhere and is necessary to preserve the normal function of other hooks from the package. Without this, the test was failing with useMountedState is not a function
.
@@ -91,12 +86,6 @@ export default { | |||
'^/google-site-kit/v1/core/user/data/survey-trigger' | |||
) | |||
); | |||
fetchMock.postOnce( | |||
new RegExp( | |||
'^/google-site-kit/v1/core/user/data/survey-timeout' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint has been entirely removed.
yield commonActions.await( | ||
dispatch( CORE_USER ).triggerSurvey( 'fpm_setup_completed' ) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this seems unrelated, it fixes stability issues in other tests where submitChanges
is awaited where additional arbitrary waits were necessary.
const args = ttl ? { ttl } : {}; | ||
return API.set( 'core', 'user', 'survey-trigger', { | ||
triggerID, | ||
...args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally added the ttl
unconditionally but it would have required many tests to be updated as there were several the have toHaveFetched
with a specific body. Rather than modifying the tests to assert a partial (as some have been here), we pass it if it's a non-falsy value. It defaults to 0
and has no effect if it's not a positive value, so this should be safe.
|
||
function lockSurveyTrigger( triggerID ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As simple "private" (self-describing) actions, these don't need doc blocks.
error: false, | ||
}; | ||
} finally { | ||
yield unlockSurveyTrigger( triggerID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures the lock is always released regardless of when the return happens without duplicating throughout.
@@ -41,13 +37,8 @@ export const mockSurveyEndpoints = () => { | |||
body: {}, | |||
} ); | |||
|
|||
fetchMock.getOnce( surveyTimeoutEndpoint, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mock was incorrect to start with since the survey-timeout
endpoint was POST only – survey-timeouts
has GET.
Summary
Addresses issue:
Relevant technical choices
survey-trigger
survey-timeout
endpoint entirelyNote: a few unrelated instabilities remain in JS + E2E tests
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist