Skip to content

Commit

Permalink
Merge pull request #7430 from google/enhance/6698-follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv authored Aug 11, 2023
2 parents d8de137 + b324474 commit 189e251
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 60 deletions.
11 changes: 0 additions & 11 deletions assets/js/googlesitekit/modules/create-gathering-data-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import invariant from 'invariant';
import API from 'googlesitekit-api';
import Data from 'googlesitekit-data';
import { createFetchStore } from '../data/create-fetch-store';
import { actions as errorStoreActions } from '../data/create-error-store';

const { receiveError } = errorStoreActions;

const { createRegistryControl } = Data;

Expand Down Expand Up @@ -184,14 +181,6 @@ export const createGatheringDataStore = (

yield actions.receiveIsGatheringData( ! dataAvailability );

if ( dataAvailability === null ) {
yield receiveError(
{ message: 'Unable to determine gathering data state.' },
'isGatheringData',
[]
);
}

if ( dataAvailability ) {
yield fetchSaveDataAvailableStateStore.actions.fetchSaveDataAvailableState();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describe( 'createGatheringDataStore', () => {
);
} );

it( 'should set gathering data state and dispatch an error when selectDataAvailability returns NULL', async () => {
it( 'should set gathering data state to TRUE when selectDataAvailability returns NULL', async () => {
selectDataAvailability.mockReturnValue( null );

registry.registerStore(
Expand All @@ -336,15 +336,6 @@ describe( 'createGatheringDataStore', () => {
expect( registry.select( STORE_NAME ).isGatheringData() ).toBe(
true
);

const error = registry
.select( STORE_NAME )
.getErrorForSelector( 'isGatheringData' );

expect( error ).not.toBeUndefined();
expect( error.message ).toBe(
'Unable to determine gathering data state.'
);
} );
} );
} );
Expand Down
8 changes: 4 additions & 4 deletions assets/js/modules/analytics-4/datastore/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ import { createGatheringDataStore } from '../../../googlesitekit/modules/create-
const { createRegistrySelector } = Data;

/**
* Returns report args for the zero data report.
* Returns report args for a sample report.
*
* @since 1.107.0
*
* @param {Function} select The select function of the registry.
* @return {Object} Report args.
*/
const getZeroDataReportArgs = ( select ) => {
const getSampleReportArgs = ( select ) => {
const { startDate, endDate } = select( CORE_USER ).getDateRangeDates( {
offsetDays: DATE_RANGE_OFFSET,
} );
Expand Down Expand Up @@ -153,7 +153,7 @@ const gatheringDataStore = createGatheringDataStore( 'analytics-4', {
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
const hasZeroData = select( MODULES_ANALYTICS_4 ).hasZeroData();

const args = getZeroDataReportArgs( select );
const args = getSampleReportArgs( select );

const hasResolvedReport = select(
MODULES_ANALYTICS_4
Expand Down Expand Up @@ -362,7 +362,7 @@ const baseSelectors = {
* @return {boolean|undefined} Returns `true` if the report is zero, otherwise `false`. Returns `undefined` while resolving.
*/
hasZeroData: createRegistrySelector( ( select ) => () => {
const args = getZeroDataReportArgs( select );
const args = getSampleReportArgs( select );

// Disable reason: select needs to be called here or it will never run.
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
Expand Down
9 changes: 0 additions & 9 deletions assets/js/modules/analytics-4/datastore/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,6 @@ describe( 'modules/analytics-4 report', () => {
// Wait for resolvers to run.
await waitForTimeouts( 30 );

const error = registry
.select( MODULES_ANALYTICS_4 )
.getErrorForSelector( 'isGatheringData' );

expect( error ).not.toBeUndefined();
expect( error.message ).toBe(
'Unable to determine gathering data state.'
);

expect( isGatheringData() ).toBe( true );
expect( console ).toHaveErrored();
expect( fetchMock ).not.toHaveFetched( dataAvailableRegexp );
Expand Down
8 changes: 4 additions & 4 deletions assets/js/modules/analytics/datastore/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ import { createGatheringDataStore } from '../../../googlesitekit/modules/create-
const { createRegistrySelector } = Data;

/**
* Returns report args for the zero data report.
* Returns report args for a sample report.
*
* @since 1.107.0
*
* @param {Function} select The select function of the registry.
* @return {Object} Report args.
*/
const getZeroDataReportArgs = ( select ) => {
const getSampleReportArgs = ( select ) => {
const { startDate, endDate } = select( CORE_USER ).getDateRangeDates( {
offsetDays: DATE_RANGE_OFFSET,
} );
Expand Down Expand Up @@ -154,7 +154,7 @@ const gatheringDataStore = createGatheringDataStore( 'analytics', {
dataAvailable:
global._googlesitekitModulesData?.[ 'data_available_analytics' ],
selectDataAvailability: createRegistrySelector( ( select ) => () => {
const args = getZeroDataReportArgs( select );
const args = getSampleReportArgs( select );

// Disable reason: select needs to be called here or it will never run.
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
Expand Down Expand Up @@ -366,7 +366,7 @@ const baseSelectors = {
return true;
}

const args = getZeroDataReportArgs( select );
const args = getSampleReportArgs( select );

// Disable reason: select needs to be called here or it will never run.
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
Expand Down
9 changes: 0 additions & 9 deletions assets/js/modules/analytics/datastore/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,6 @@ describe( 'modules/analytics report', () => {
// Wait for resolvers to run.
await waitForTimeouts( 30 );

const error = registry
.select( MODULES_ANALYTICS )
.getErrorForSelector( 'isGatheringData' );

expect( error ).not.toBeUndefined();
expect( error.message ).toBe(
'Unable to determine gathering data state.'
);

expect( console ).toHaveErroredWith( ...consoleError );
expect( isGatheringData() ).toBe( true );
expect( fetchMock ).not.toHaveFetched( dataAvailableRegexp );
Expand Down
8 changes: 4 additions & 4 deletions assets/js/modules/search-console/datastore/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ import { createGatheringDataStore } from '../../../googlesitekit/modules/create-
const { createRegistrySelector } = Data;

/**
* Returns report args for the zero data report.
* Returns report args for a sample report.
*
* @since 1.107.0
*
* @param {Function} select The select function of the registry.
* @return {Object} Report args.
*/
const getZeroDataReportArgs = ( select ) => {
const getSampleReportArgs = ( select ) => {
const url = select( CORE_SITE ).getCurrentEntityURL();
const { compareStartDate: startDate, endDate } = select(
CORE_USER
Expand Down Expand Up @@ -118,7 +118,7 @@ const gatheringDataStore = createGatheringDataStore( 'search-console', {
dataAvailable:
global._googlesitekitModulesData?.[ 'data_available_search-console' ],
selectDataAvailability: createRegistrySelector( ( select ) => () => {
const reportArgs = getZeroDataReportArgs( select );
const reportArgs = getSampleReportArgs( select );
// Disable reason: select needs to be called here or it will never run.
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
const report = select( MODULES_SEARCH_CONSOLE ).getReport( reportArgs );
Expand Down Expand Up @@ -211,7 +211,7 @@ const baseSelectors = {
return true;
}

const args = getZeroDataReportArgs( select );
const args = getSampleReportArgs( select );

// Disable reason: select needs to be called here or it will never run.
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
Expand Down
9 changes: 0 additions & 9 deletions assets/js/modules/search-console/datastore/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,6 @@ describe( 'modules/search-console report', () => {
// Wait for resolvers to run.
await waitForTimeouts( 30 );

const error = registry
.select( MODULES_SEARCH_CONSOLE )
.getErrorForSelector( 'isGatheringData' );

expect( error ).not.toBeUndefined();
expect( error.message ).toBe(
'Unable to determine gathering data state.'
);

expect( console ).toHaveErroredWith( ...consoleError );
expect( isGatheringData() ).toBe( true );
expect( fetchMock ).not.toHaveFetched( dataAvailableRegexp );
Expand Down

0 comments on commit 189e251

Please sign in to comment.