Skip to content

Commit 4dc0afa

Browse files
committed
Test fix
1 parent 999cd71 commit 4dc0afa

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

injected/integration-test/duckplayer-mobile.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ test.describe('Reporting exceptions', () => {
152152
test('initial setup error', async ({ page }, workerInfo) => {
153153
const overlays = DuckplayerOverlays.create(page, workerInfo);
154154
await overlays.withRemoteConfig({ locale: 'en' });
155-
await overlays.initialSetupError();
155+
await overlays.messagingError();
156156
await overlays.gotoPlayerPage();
157-
await overlays.didSendInitialSetupErrorException();
157+
await overlays.didSendMessagingException();
158158
});
159159
});

injected/integration-test/duckplayer.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ test.describe('Reporting exceptions', () => {
374374
test('initial setup error', async ({ page }, workerInfo) => {
375375
const overlays = DuckplayerOverlays.create(page, workerInfo);
376376
await overlays.withRemoteConfig({ locale: 'en' });
377-
await overlays.initialSetupError();
377+
await overlays.messagingError();
378378
await overlays.gotoPlayerPage();
379-
await overlays.didSendInitialSetupErrorException();
379+
await overlays.didSendMessagingException();
380380
});
381381
});

injected/integration-test/page-objects/duckplayer-overlays.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ export class DuckplayerOverlays {
305305
});
306306
}
307307

308-
async initialSetupError() {
308+
/**
309+
* Simulates a messaging error by passing an empty initialSetup object
310+
*/
311+
async messagingError() {
309312
await this.build.switch({
310313
android: async () => {
311314
await this.collector.updateMockResponse({
@@ -520,20 +523,20 @@ export class DuckplayerOverlays {
520523
]);
521524
}
522525

523-
async didSendInitialSetupErrorException() {
526+
async didSendMessagingException() {
524527
await this.build.switch({
525528
android: async () => {
526529
// Android produces a TypeError due to how its messaging lib is wired up
527530
await this.didSendException('TypeError', "Cannot read properties of undefined (reading 'privatePlayerMode')");
528531
},
529532
apple: async () => {
530-
await this.didSendException('InitialSetupError', 'Error: an unknown error occurred');
533+
await this.didSendException('MessagingError', 'an unknown error occurred');
531534
},
532535
'apple-isolated': async () => {
533-
await this.didSendException('InitialSetupError', 'Error: an unknown error occurred', 'contentScopeScriptsIsolated');
536+
await this.didSendException('MessagingError', 'an unknown error occurred', 'contentScopeScriptsIsolated');
534537
},
535538
windows: async () => {
536-
await this.didSendException('InitialSetupError', 'Error: unknown error');
539+
await this.didSendException('MessagingError', 'unknown error');
537540
},
538541
});
539542
}

special-pages/pages/duckplayer/integration-tests/duck-player.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,16 @@ export class DuckPlayerPage {
145145
this.mocks.defaultResponses(clone);
146146
}
147147

148-
initialSetupError() {
148+
/**
149+
* Simulates a messaging error by passing an empty initialSetup object
150+
*/
151+
messagingError() {
149152
const clone = structuredClone(this.defaults);
150153

151154
this.build.switch({
152155
android: () => {
153156
// @ts-expect-error - this is a test
154-
clone.initialSetup = {
155-
locale: 'en',
156-
env: 'development',
157-
platform: this.platform.name === 'windows' ? undefined : { name: this.platform.name },
158-
};
157+
clone.initialSetup = {};
159158
this.mocks.defaultResponses(clone);
160159
},
161160
apple: () => {
@@ -592,17 +591,17 @@ export class DuckPlayerPage {
592591
return this.didSendReportMetric({ metricName: 'exception', params: { kind, message } });
593592
}
594593

595-
async didSendInitialSetupErrorException() {
594+
async didSendMessagingException() {
596595
await this.build.switch({
597596
android: async () => {
598597
// Android produces a TypeError due to how its messaging lib is wired up
599598
await this.didSendException('TypeError', "undefined is not an object (evaluating 'init2.settings.pip')");
600599
},
601600
apple: async () => {
602-
await this.didSendException('InitialSetupError', 'Max attempts reached: Error: an unknown error occurred');
601+
await this.didSendException('MessagingError', 'an unknown error occurred');
603602
},
604603
windows: async () => {
605-
await this.didSendException('InitialSetupError', 'Max attempts reached: Error: unknown error');
604+
await this.didSendException('MessagingError', 'unknown error');
606605
},
607606
});
608607
}

special-pages/pages/duckplayer/integration-tests/duckplayer.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ test.describe('reporting exceptions', () => {
344344
test('initial setup error', async ({ page }, workerInfo) => {
345345
const duckplayer = DuckPlayerPage.create(page, workerInfo);
346346
// load as normal
347-
duckplayer.initialSetupError();
347+
duckplayer.messagingError();
348348
await duckplayer.openWithVideoID();
349-
await duckplayer.didSendInitialSetupErrorException();
349+
await duckplayer.didSendMessagingException();
350350
});
351351
});
352352

special-pages/pages/duckplayer/src/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { initStorage } from './storage.js';
66
import '../../../shared/live-reload.js';
77
import {
88
ReportMetric,
9-
EXCEPTION_KIND_GENERIC_ERROR,
10-
EXCEPTION_KIND_INITIAL_SETUP_ERROR,
119
EXCEPTION_KIND_MESSAGING_ERROR,
1210
} from '../../../shared/report-metric.js';
1311

@@ -46,7 +44,7 @@ export class DuckplayerPage {
4644
try {
4745
return await this.messaging.request('initialSetup');
4846
} catch (e) {
49-
this.metrics.reportException({ message: e?.message, kind: EXCEPTION_KIND_INITIAL_SETUP_ERROR });
47+
this.metrics.reportException({ message: e?.message, kind: EXCEPTION_KIND_MESSAGING_ERROR });
5048
throw e;
5149
}
5250
}
@@ -197,13 +195,11 @@ const duckplayerPage = new DuckplayerPage(messaging, import.meta.injectName);
197195
const telemetry = new Telemetry(messaging);
198196

199197
init(duckplayerPage, telemetry, baseEnvironment).catch((e) => {
200-
// messages.
201198
console.error(e);
202-
const message = typeof e?.message === 'string' ? e.message : 'unknown error';
203-
const kind = typeof e?.name === 'string' ? e.name : EXCEPTION_KIND_GENERIC_ERROR;
204-
duckplayerPage.metrics.reportException({ message, kind });
199+
duckplayerPage.metrics.reportExceptionWithError(e);
205200

206201
// TODO: Remove this event once all native platforms are responding to 'reportMetric: exception'
202+
const message = typeof e?.message === 'string' ? e.message : 'unknown error';
207203
duckplayerPage.reportInitException({ message });
208204
});
209205

0 commit comments

Comments
 (0)