-
Notifications
You must be signed in to change notification settings - Fork 295
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
Check for gathering data state in Search Console and Analytics before showing User Input notification. #7198
Merged
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
dd207d9
Check for gathering data state in Search Console and Analytics before…
tofumatt cb98195
Merge branch 'develop' into fix/6607.
10upsimon cae57ed
Merge branch 'develop' of github.com:google/site-kit-wp into develop.
10upsimon c18a364
Merge branch 'develop' of github.com:google/site-kit-wp into develop.
10upsimon d5da3b7
Merge branch develop into fix/6607.
10upsimon 4b4b670
Return null from KeyMetricsSetupCTAWidget when gathering data.
techanvil 3147fd6
Reorder conditions for consistency.
techanvil 90b011e
Fix E2E test, providing mock data to avoid "gathering data" state.
techanvil b04538f
Add an explanatory comment.
techanvil b6687c8
Tidy up.
techanvil 023f282
Update paths for consistency.
techanvil 0d7a974
Fix KeyMetricsSetupCTAWidget stories.
techanvil 642b6f7
Prevent warnings in Storybook due to unhandled POST to data-available…
techanvil 75fa2df
Update regexes for consistency.
techanvil 6b1d719
Fix tests for KeyMetricsSetupCTAWidget.
techanvil 43321a6
Update tests to use getWidgetComponentProps.
techanvil 334d63b
Merge branch 'develop' into fix/6607.
techanvil efa0d9f
Add tests for when SC/GA4 are gathering data.
techanvil 59cbdeb
Add provideGatheringDataState utility function.
techanvil 13200cb
Refactor tests and story to use provideGatheringDataState helper.
techanvil 3c52eea
Add JSDoc for new utility helpers.
techanvil 405e91e
Remove unneeded calls to set reference date.
techanvil 6658567
Rename variable.
techanvil 0442858
Remove unnecessary setting of global data.
techanvil 4bc8ad5
Rename variable.
techanvil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { set } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -37,6 +42,8 @@ import { | |
setupAnalytics, | ||
setupAnalytics4, | ||
} from '../utils'; | ||
import { getAnalytics4MockResponse } from '../../../assets/js/modules/analytics-4/utils/data-mock'; | ||
import { getSearchConsoleMockResponse } from '../../../assets/js/modules/search-console/util/data-mock'; | ||
|
||
describe( 'User Input Settings', () => { | ||
async function fillInInputSettings() { | ||
|
@@ -95,13 +102,50 @@ describe( 'User Input Settings', () => { | |
); | ||
} | ||
|
||
function getMultiDimensionalObjectFromParams( params ) { | ||
return Object.entries( params ).reduce( ( acc, [ key, value ] ) => { | ||
set( acc, key, value ); | ||
return acc; | ||
}, {} ); | ||
} | ||
|
||
beforeAll( async () => { | ||
await page.setRequestInterception( true ); | ||
|
||
useRequestInterception( ( request ) => { | ||
const url = request.url(); | ||
|
||
if ( url.match( '/google-site-kit/v1/modules' ) ) { | ||
const paramsObject = Object.fromEntries( | ||
new URL( url ).searchParams.entries() | ||
); | ||
|
||
// Provide mock data for Analytics 4 and Search Console requests to ensure they are not in the "gathering data" state. | ||
if ( | ||
url.match( | ||
'/google-site-kit/v1/modules/analytics-4/data/report?' | ||
) | ||
) { | ||
request.respond( { | ||
status: 200, | ||
body: JSON.stringify( | ||
getAnalytics4MockResponse( | ||
// Some of the keys are nested paths e.g. `metrics[0][name]`, so we need to convert the search params to a multi-dimensional object. | ||
getMultiDimensionalObjectFromParams( paramsObject ) | ||
) | ||
), | ||
Comment on lines
+130
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🏆 👍 |
||
} ); | ||
} else if ( | ||
url.match( | ||
'/google-site-kit/v1/modules/search-console/data/searchanalytics?' | ||
) | ||
) { | ||
request.respond( { | ||
status: 200, | ||
body: JSON.stringify( | ||
getSearchConsoleMockResponse( paramsObject ) | ||
), | ||
} ); | ||
} else if ( url.match( '/google-site-kit/v1/modules' ) ) { | ||
request.respond( { status: 200 } ); | ||
} else { | ||
request.continue(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 added to prevent warnings in stories about POSTing to the
data-available
endpoint once the gathering data state has been determined.