-
Notifications
You must be signed in to change notification settings - Fork 294
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
Enhancement/9846 fpm setup banner error handling #9969
Enhancement/9846 fpm setup banner error handling #9969
Conversation
Build files for b48a6ce have been deleted. |
Size Change: +1.12 kB (+0.06%) Total Size: 1.99 MB
ℹ️ View Unchanged
|
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.
Great work, @ankitrox! This almost looks good. However, I've left a few comments to be addressed before we merge. To avoid an iteration, I will address the changes myself.
@@ -247,6 +247,47 @@ describe( 'FirstPartyModeSetupBanner', () => { | |||
} ); | |||
} ); | |||
|
|||
it( 'should display the error when CTA is clicked', async () => { |
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.
Let's make it more descriptive
it( 'should display the error when CTA is clicked', async () => { | |
should display the error message when the CTA button is clicked and the request fails |
@@ -33,13 +33,16 @@ import { CORE_NOTIFICATIONS } from '../../datastore/constants'; | |||
import { CORE_LOCATION } from '../../../datastore/location/constants'; | |||
import useNotificationEvents from '../../hooks/useNotificationEvents'; | |||
import { SpinnerButton } from 'googlesitekit-components'; | |||
import { CORE_SITE } from '../../../datastore/site/constants'; |
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.
Let's move it below CORE_LOCATION
@@ -0,0 +1,53 @@ | |||
/** | |||
* Site Kit by Google, Copyright 2024 Google LLC |
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.
* Site Kit by Google, Copyright 2024 Google LLC | |
* Site Kit by Google, Copyright 2025 Google LLC |
Default.args = { | ||
setupRegistry: () => { | ||
fetchMock.post( | ||
new RegExp( '^/google-site-kit/v1/core/site/data/fpm-settings' ), | ||
{ | ||
body: JSON.stringify( { | ||
isEnabled: true, | ||
isFPMHealthy: true, | ||
isScriptAccessEnabled: true, | ||
} ), | ||
status: 200, | ||
} | ||
); | ||
}, | ||
}; |
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 is unnecessary. We can remove it.
Default.args = { | |
setupRegistry: () => { | |
fetchMock.post( | |
new RegExp( '^/google-site-kit/v1/core/site/data/fpm-settings' ), | |
{ | |
body: JSON.stringify( { | |
isEnabled: true, | |
isFPMHealthy: true, | |
isScriptAccessEnabled: true, | |
} ), | |
status: 200, | |
} | |
); | |
}, | |
}; |
fetchMock.post( | ||
new RegExp( '^/google-site-kit/v1/core/site/data/fpm-settings' ), | ||
{ | ||
body: JSON.stringify( { | ||
code: 'test_error', | ||
message: 'Test Error', | ||
data: { | ||
reason: 'test_reason', | ||
}, | ||
} ), | ||
status: 500, | ||
} | ||
); |
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 fetchMock
is unnecessary since we are mocking the error using receiveError
below.
fetchMock.post( | |
new RegExp( '^/google-site-kit/v1/core/site/data/fpm-settings' ), | |
{ | |
body: JSON.stringify( { | |
code: 'test_error', | |
message: 'Test Error', | |
data: { | |
reason: 'test_reason', | |
}, | |
} ), | |
status: 500, | |
} | |
); |
|
||
export default { | ||
title: 'Modules/FirstPartyMode/Dashboard/FirstPartyModeSetupBanner', | ||
decorators: [ | ||
( Story ) => { | ||
( Story, { args } ) => { | ||
fetchMock.restore(); |
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.
We can remove this.
fetchMock.restore(); |
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.
Great work, @ankitrox! LGTM 👍
Note: I've verified that the CI build failures are unrelated to this PR.
Summary
Addresses issue:
Relevant technical choices
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