Skip to content

Commit 173de86

Browse files
committed
Update test to show loading state for unresolved custom dimensions.
Mark the custom dimensions as not yet resolved to ensure the loading state is displayed correctly in the SettingsAdvancedDataBreakdowns component during tests.
1 parent 419abbb commit 173de86

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

assets/js/modules/analytics-4/components/settings/SettingsAdvancedDataBreakdowns.test.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,24 @@ describe( 'SettingsAdvancedDataBreakdowns', () => {
9999
registry
100100
.dispatch( MODULES_ANALYTICS_4 )
101101
.receiveGetAdvancedDataBreakdownsSettings( {} );
102-
// Select a property whose custom dimensions aren't in the store, and
103-
// keep the request for them pending.
104-
registry.dispatch( MODULES_ANALYTICS_4 ).setPropertyID( '654321' );
105-
freezeFetch(
106-
new RegExp(
107-
'^/google-site-kit/v1/modules/analytics-4/data/custom-dimensions'
108-
)
109-
);
102+
// Mark the custom dimensions as not yet resolved, so the row shows its
103+
// loading state.
104+
registry
105+
.dispatch( MODULES_ANALYTICS_4 )
106+
.invalidateResolution( 'getCustomDimensions', [ propertyID ] );
110107

111108
const { container, waitForRegistry } = render(
112109
<SettingsAdvancedDataBreakdowns />,
113110
{ registry }
114111
);
115112

116-
// The pending custom-dimensions request still dispatches its start
117-
// action, so wait for that state update inside `act()`. Without this,
118-
// the update lands after the test and React logs an `act()` warning.
119-
await waitForRegistry();
120-
121113
expect(
122114
container.querySelector(
123115
'.googlesitekit-settings-measurement-row--loading'
124116
)
125117
).toBeInTheDocument();
118+
119+
await waitForRegistry();
126120
} );
127121

128122
it( 'shows a progress bar while no property is selected', () => {

0 commit comments

Comments
 (0)