Skip to content

Commit 30e5b04

Browse files
Address review comments.
1 parent 9d93bc8 commit 30e5b04

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

assets/js/components/ReportError.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ export default function ReportError( { moduleSlug, error } ) {
9494
...err,
9595
message: getMessage( err ),
9696
// The `code` parameter contains a session ID which can vary
97-
// between requests, so we ignore it when comparing.
97+
// between requests, so we ignore it for comparison below.
98+
// To use the original `reconnectURL` elsewhere, use `err.data.reconnectURL`.
9899
reconnectURL: err.data?.reconnectURL
99-
? removeQueryArgs( err.data?.reconnectURL, 'code' )
100+
? removeQueryArgs( err.data.reconnectURL, 'code' )
100101
: undefined,
101102
} ) ),
102103
( errorA, errorB ) =>

assets/js/components/ReportError.test.js

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

574-
it( 'it should not list error descriptions with the same `reconnectURL`s', async () => {
575-
const { container } = render(
574+
it( 'should not list error descriptions with the same `reconnectURL`s', async () => {
575+
const { container, waitForRegistry } = render(
576576
<ReportError
577577
moduleSlug={ moduleName }
578578
error={ [
@@ -610,9 +610,18 @@ describe( 'ReportError', () => {
610610
}
611611
);
612612

613-
expect( container.querySelectorAll( 'p' ).length ).toBe( 2 );
613+
await waitForRegistry();
614614

615-
await act( waitForDefaultTimeouts );
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 );
616625
} );
617626

618627
it( 'should render `Get help` link without prefix text on non-retryable error', async () => {

0 commit comments

Comments
 (0)