Skip to content

Commit bdb3ad4

Browse files
committed
test(appium): assume log view in all demos
1 parent e6aaa96 commit bdb3ad4

2 files changed

Lines changed: 12 additions & 26 deletions

File tree

‎appium/tests/helpers/app.ts‎

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,6 @@ export async function tapNotification(title: string, timeoutMs = 30_000) {
449449
}
450450
}
451451

452-
export async function hasLogView(): Promise<boolean> {
453-
return $(byTestIdSelector('log_view'))
454-
.isExisting()
455-
.catch(() => false);
456-
}
457-
458452
/**
459453
* Text of the demo's log entries, oldest first. Native Android only sees
460454
* entries on screen, so counts can miss older matches that scrolled away.
@@ -502,24 +496,21 @@ async function latestUserChange(externalId: string | null) {
502496
/**
503497
* Wait for a login/logout to settle: the demo logs a "User changed" for `externalId` (null = anonymous),
504498
* then the backend has that user. Settling first avoids racing the SDK's user switch on the next call
505-
* (e.g. a fast logout then login on iOS never fires the user observer). Demos without that log
506-
* just get `timeoutMs` as a grace period.
499+
* (e.g. a fast logout then login on iOS never fires the user observer).
507500
*/
508501
export async function waitForIdentityChange(
509502
{ externalId }: { externalId: string | null },
510503
timeoutMs = 10_000,
511504
) {
512-
let onesignalId: string | undefined;
513-
await driver
514-
.waitUntil(async () => Boolean((onesignalId = await latestUserChange(externalId))), {
505+
let onesignalId = '';
506+
await driver.waitUntil(
507+
async () => Boolean((onesignalId = (await latestUserChange(externalId)) ?? '')),
508+
{
515509
timeout: timeoutMs,
516510
interval: 500,
517-
})
518-
.catch(() => undefined);
519-
if (!onesignalId) {
520-
console.info(`No "User changed" log for external_id ${externalId ?? 'null'}`);
521-
return undefined;
522-
}
511+
timeoutMsg: `No "User changed" log for external_id ${externalId ?? 'null'}`,
512+
},
513+
);
523514
await waitForBackendUser(onesignalId, externalId);
524515
return onesignalId;
525516
}
@@ -686,10 +677,10 @@ export async function checkNotification(opts: {
686677

687678
const displayLog = ['Notification foregroundWillDisplay:', opts.title];
688679
const clickLog = ['Notification click:', opts.title];
689-
const logged = await hasLogView();
690-
const [displaysBefore, clicksBefore] = logged
691-
? await Promise.all([countLogMessages(...displayLog), countLogMessages(...clickLog)])
692-
: [0, 0];
680+
const [displaysBefore, clicksBefore] = await Promise.all([
681+
countLogMessages(...displayLog),
682+
countLogMessages(...clickLog),
683+
]);
693684

694685
await button.click();
695686
await waitForNotification({
@@ -698,8 +689,6 @@ export async function checkNotification(opts: {
698689
expectImage: opts.expectImage,
699690
});
700691

701-
// Demos without the log view can't report JS events yet.
702-
if (!logged) return;
703692
await expectOneNewLog(displayLog, displaysBefore);
704693
await expectOneNewLog(clickLog, clicksBefore);
705694
}

‎appium/tests/specs/13_notification_click.spec.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
returnToApp,
88
killApp,
99
backgroundApp,
10-
hasLogView,
1110
expectOneNewLog,
1211
} from '../helpers/app.js';
1312
import {
@@ -63,8 +62,6 @@ async function getBrowserAddress(): Promise<string> {
6362
/** The JS click listener must fire exactly once for the tapped notification. */
6463
async function expectSingleClickEvent(notificationId: string) {
6564
await returnToApp();
66-
// Demos without the log view can't report JS events yet.
67-
if (!(await hasLogView())) return;
6865
await expectOneNewLog([`Notification click: ${notificationId}`]);
6966
}
7067

0 commit comments

Comments
 (0)