Skip to content

Commit aa394e7

Browse files
committed
Sync with develop.
2 parents 3f12c05 + 7f8377f commit aa394e7

File tree

58 files changed

+933
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+933
-32
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
!.github
77
!.vscode
88
.vscode/*
9+
!.wordpress-org/
910
!.vscode/extensions.json
1011
!.vscode/settings.json
1112
!.editorconfig

.wordpress-org/banner-1544x500.png

69.3 KB
Loading

.wordpress-org/banner-772x250.png

35.8 KB
Loading

.wordpress-org/icon-128x128.png

10.8 KB
Loading

.wordpress-org/icon-256x256.png

9.81 KB
Loading

assets/js/components/KeyMetrics/MetricsSelectionPanel/SelectionPanelFooter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ SelectionPanelFooter.propTypes = {
187187
selectedItemSlugs: PropTypes.array,
188188
saveSettings: PropTypes.func,
189189
saveError: PropTypes.object,
190-
itemLimitError: PropTypes.string,
191190
minSelectedItemCount: PropTypes.number,
192191
maxSelectedItemCount: PropTypes.number,
193192
isBusy: PropTypes.bool,

assets/js/components/ReportError.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { uniqWith } from 'lodash';
2727
*/
2828
import { Fragment } from '@wordpress/element';
2929
import { __, sprintf } from '@wordpress/i18n';
30+
import { removeQueryArgs } from '@wordpress/url';
3031

3132
/**
3233
* Internal dependencies
@@ -92,7 +93,12 @@ export default function ReportError( { moduleSlug, error } ) {
9293
errors.map( ( err ) => ( {
9394
...err,
9495
message: getMessage( err ),
95-
reconnectURL: err.data?.reconnectURL,
96+
// The `code` parameter contains a session ID which can vary
97+
// between requests, so we ignore it for comparison below.
98+
// To use the original `reconnectURL` elsewhere, use `err.data.reconnectURL`.
99+
reconnectURL: err.data?.reconnectURL
100+
? removeQueryArgs( err.data.reconnectURL, 'code' )
101+
: undefined,
96102
} ) ),
97103
( errorA, errorB ) =>
98104
errorA.message === errorB.message &&

assets/js/components/ReportError.test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,59 @@ describe( 'ReportError', () => {
571571
expect( invalidateResolutionSpy ).toHaveBeenCalledTimes( 4 );
572572
} );
573573

574+
it( 'should not list error descriptions with the same `reconnectURL`s', async () => {
575+
const { container, waitForRegistry } = render(
576+
<ReportError
577+
moduleSlug={ moduleName }
578+
error={ [
579+
{
580+
code: 'test_error',
581+
message: 'Test error message',
582+
data: {
583+
reason: '',
584+
reconnectURL: 'https://example.com/page?code=1',
585+
status: 401,
586+
},
587+
},
588+
{
589+
code: 'test_error',
590+
message: 'Test error message',
591+
data: {
592+
reason: '',
593+
reconnectURL: 'https://example.com/page?code=2',
594+
status: 401,
595+
},
596+
},
597+
{
598+
code: 'test_error',
599+
message: 'Test error message 2',
600+
data: {
601+
reason: '',
602+
reconnectURL: 'https://example.com/page2?code=1',
603+
status: 401,
604+
},
605+
},
606+
] }
607+
/>,
608+
{
609+
registry,
610+
}
611+
);
612+
613+
await waitForRegistry();
614+
615+
const errorDescriptionElement = container.querySelectorAll(
616+
'.googlesitekit-cta__description'
617+
);
618+
619+
// Verify the child element count for the error description element is two.
620+
// However, the passed error array has three repetitive error objects.
621+
// The second error is not listed because it has the same `message` and `reconnectURL`
622+
// as the first one. Note that the `code` query parameter in the `reconnectURL` is
623+
// ignored for comparison, as it is expected to be different for each URL.
624+
expect( errorDescriptionElement[ 0 ].childElementCount ).toBe( 2 );
625+
} );
626+
574627
it( 'should render `Get help` link without prefix text on non-retryable error', async () => {
575628
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
576629
{

assets/js/components/SelectionPanel/SelectionPanelFooter.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ import { Button, SpinnerButton } from 'googlesitekit-components';
4242
import { safelySort } from '@/js/util';
4343
import { MODULES_ANALYTICS_4 } from '@/js/modules/analytics-4/datastore/constants';
4444
import PreviewBlock from '@/js/components/PreviewBlock';
45-
import Notice from '@/js/components/Notice';
4645

4746
export default function SelectionPanelFooter( {
4847
savedItemSlugs = [],
4948
selectedItemSlugs = [],
5049
saveSettings = () => {},
51-
itemLimitError,
5250
minSelectedItemCount = 0,
5351
maxSelectedItemCount = 0,
5452
isBusy,
@@ -150,14 +148,7 @@ export default function SelectionPanelFooter( {
150148
return (
151149
<footer className="googlesitekit-selection-panel-footer">
152150
<div className="googlesitekit-selection-panel-footer__content">
153-
{ haveSettingsChanged && itemLimitError ? (
154-
<Notice
155-
type={ Notice.TYPES.ERROR }
156-
description={ itemLimitError }
157-
/>
158-
) : (
159-
itemCountElement
160-
) }
151+
{ itemCountElement }
161152
<div className="googlesitekit-selection-panel-footer__actions">
162153
<Button
163154
onClick={ onCancelClick }
@@ -188,7 +179,6 @@ SelectionPanelFooter.propTypes = {
188179
savedItemSlugs: PropTypes.array,
189180
selectedItemSlugs: PropTypes.array,
190181
saveSettings: PropTypes.func,
191-
itemLimitError: PropTypes.string,
192182
minSelectedItemCount: PropTypes.number,
193183
maxSelectedItemCount: PropTypes.number,
194184
isBusy: PropTypes.bool,

assets/js/components/setup/__snapshots__/ModuleSetup.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ exports[`ModuleSetup Analytics 4 initial setup flow should match the snapshot 1`
257257
for="googlesitekit-select-17"
258258
style=""
259259
>
260-
Web Data Stream
260+
Web data stream
261261
</label>
262262
</div>
263263
<div
@@ -708,7 +708,7 @@ exports[`ModuleSetup Analytics 4 not initial setup flow should match the snapsho
708708
for="googlesitekit-select-35"
709709
style=""
710710
>
711-
Web Data Stream
711+
Web data stream
712712
</label>
713713
</div>
714714
<div

0 commit comments

Comments
 (0)