-
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
Enhance/#6932 - GA4 dashboard prompt banner notification #7026
Changes from 6 commits
03823b0
2abc24e
7af2c5c
934d091
038e4ef
084f73b
ade237e
e6b0044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,6 +33,7 @@ import { | |||||||||||
PROFILE_CREATE, | ||||||||||||
DASHBOARD_VIEW_UA, | ||||||||||||
DASHBOARD_VIEW_GA4, | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID, | ||||||||||||
} from './constants'; | ||||||||||||
import * as fixtures from './__fixtures__'; | ||||||||||||
import { | ||||||||||||
|
@@ -134,6 +135,11 @@ describe( 'modules/analytics settings', () => { | |||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedTours( [ ga4Reporting.slug ] ); | ||||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedItems( [ | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID, | ||||||||||||
] ); | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
it( 'dispatches createProperty if the "set up a new property" option is chosen', async () => { | ||||||||||||
|
@@ -621,6 +627,132 @@ describe( 'modules/analytics settings', () => { | |||||||||||
} ); | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
describe( 'dismiss switch ga4 dashboard view notification', () => { | ||||||||||||
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. We should capitalise the initials in GA4 when using it in a sentence... I'd also make the following minor grammatical tweak:
Suggested change
|
||||||||||||
const fetchDismissItemRegExp = new RegExp( | ||||||||||||
'^/google-site-kit/v1/core/user/data/dismiss-item' | ||||||||||||
); | ||||||||||||
|
||||||||||||
it( 'should not dismiss the switch ga4 dashboard view notification if it is a UA dashboard view', async () => { | ||||||||||||
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. As above:
Suggested change
|
||||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedItems( [] ); | ||||||||||||
registry | ||||||||||||
.dispatch( MODULES_ANALYTICS ) | ||||||||||||
.setSettings( validSettings ); | ||||||||||||
|
||||||||||||
fetchMock.postOnce( gaSettingsEndpoint, { | ||||||||||||
body: validSettings, | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
expect( | ||||||||||||
registry.select( MODULES_ANALYTICS ).getDashboardView() | ||||||||||||
).toBe( DASHBOARD_VIEW_UA ); | ||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( false ); | ||||||||||||
|
||||||||||||
await registry | ||||||||||||
.dispatch( MODULES_ANALYTICS ) | ||||||||||||
.submitChanges(); | ||||||||||||
|
||||||||||||
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. Seeing as we have to wait for resolvers to run in the successful test case below, we should probably add it here too, to ensure this test isn't giving us a false positive.
Suggested change
|
||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( false ); | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
it( 'should not dismiss the switch ga4 dashboard view notification if it is already dismissed', async () => { | ||||||||||||
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. As above:
Suggested change
|
||||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedItems( [ | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID, | ||||||||||||
] ); | ||||||||||||
registry.dispatch( MODULES_ANALYTICS ).setSettings( { | ||||||||||||
...validSettings, | ||||||||||||
dashboardView: DASHBOARD_VIEW_GA4, | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
fetchMock.postOnce( gaSettingsEndpoint, { | ||||||||||||
body: validSettings, | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
expect( | ||||||||||||
registry.select( MODULES_ANALYTICS ).getDashboardView() | ||||||||||||
).toBe( DASHBOARD_VIEW_GA4 ); | ||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( true ); | ||||||||||||
|
||||||||||||
await registry | ||||||||||||
.dispatch( MODULES_ANALYTICS ) | ||||||||||||
.submitChanges(); | ||||||||||||
|
||||||||||||
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. As above:
Suggested change
|
||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( true ); | ||||||||||||
|
||||||||||||
expect( fetchMock ).not.toHaveFetched( | ||||||||||||
fetchDismissItemRegExp | ||||||||||||
); | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
it( 'should dismiss the switch ga4 dashboard view notification if it has not been dismissed yet', async () => { | ||||||||||||
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. As above:
Suggested change
|
||||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedItems( [] ); | ||||||||||||
registry.dispatch( MODULES_ANALYTICS ).setSettings( { | ||||||||||||
...validSettings, | ||||||||||||
dashboardView: DASHBOARD_VIEW_GA4, | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
fetchMock.postOnce( gaSettingsEndpoint, { | ||||||||||||
body: validSettings, | ||||||||||||
} ); | ||||||||||||
fetchMock.post( fetchDismissItemRegExp, { | ||||||||||||
body: [ GA4_DASHBOARD_VIEW_NOTIFICATION_ID ], | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( false ); | ||||||||||||
|
||||||||||||
await registry | ||||||||||||
.dispatch( MODULES_ANALYTICS ) | ||||||||||||
.submitChanges(); | ||||||||||||
|
||||||||||||
// Wait for resolvers to run. | ||||||||||||
await waitForDefaultTimeouts(); | ||||||||||||
|
||||||||||||
expect( fetchMock ).toHaveFetched( fetchDismissItemRegExp ); | ||||||||||||
expect( | ||||||||||||
registry | ||||||||||||
.select( CORE_USER ) | ||||||||||||
.isItemDismissed( | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID | ||||||||||||
) | ||||||||||||
).toBe( true ); | ||||||||||||
} ); | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
describe( 'analytics-4', () => { | ||||||||||||
beforeEach( () => { | ||||||||||||
registry | ||||||||||||
|
@@ -768,6 +900,11 @@ describe( 'modules/analytics settings', () => { | |||||||||||
registry | ||||||||||||
.dispatch( MODULES_ANALYTICS ) | ||||||||||||
.receiveGetSettings( validSettings ); | ||||||||||||
registry | ||||||||||||
.dispatch( CORE_USER ) | ||||||||||||
.receiveGetDismissedItems( [ | ||||||||||||
GA4_DASHBOARD_VIEW_NOTIFICATION_ID, | ||||||||||||
] ); | ||||||||||||
expect( | ||||||||||||
registry.select( MODULES_ANALYTICS ).haveSettingsChanged() | ||||||||||||
).toBe( false ); | ||||||||||||
|
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.
@hussain-t, I really don't think we should be disabling this rule in any new scenarios. By disabling the rule it means we can keep adding more complexity to this function without any warning or check on it, which is a bit of a step backward.
Please can you instead refactor this function a bit, extracting some of it into new functions if needs be.