Skip to content

Commit b58ca49

Browse files
authored
fix: e2e tests long reboot and timezone (#1281)
* Adds browser wait after rebooting app after adding remote server fails. Gets device timezone to check for date. * Increases time for waiting when removing a remote server fails.
1 parent c5e996c commit b58ca49

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

tests/e2e/specs/remote-archive/add-remote-success-and-removal.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import {expect} from '@wdio/globals';
22
import {describe, it} from 'mocha';
33
import {byResourceId, byText, byTextMatches} from '../../utils/selectors';
4-
import {getTodayFormattedDate} from '../../utils/date';
4+
import {getDeviceTimezone, getFormattedDate} from '../../utils/date';
55
import {output} from '../../utils/naming';
66

77
let archiveAdded = false;
88
let cleanupNeeded = false;
9+
let deviceTimezone: string;
910

1011
describe('Remote Archive - Add Success Flow', () => {
12+
before(async () => {
13+
deviceTimezone = await getDeviceTimezone();
14+
});
1115
it('navigates to Remote Archive screen', async () => {
1216
await expect($(byTextMatches('Remote Archive \\| OFF'))).toBeDisplayed();
1317
await $(byText('View Details')).click();
@@ -51,6 +55,7 @@ describe('Remote Archive - Add Success Flow', () => {
5155
console.warn('🛑 Remote Archive addition failed — restarting app');
5256
await driver.terminateApp('com.comapeo.rc');
5357
await driver.activateApp('com.comapeo.rc');
58+
await driver.pause(15000);
5459
return;
5560
}
5661
await expect($(byText('Remote Archive Added'))).toBeDisplayed();
@@ -61,7 +66,7 @@ describe('Remote Archive - Add Success Flow', () => {
6166
await expect($(byResourceId('RA.archive-name'))).toHaveText(
6267
output.remoteServer,
6368
);
64-
const today = getTodayFormattedDate();
69+
const today = getFormattedDate(deviceTimezone);
6570
await expect($(byText(today))).toBeDisplayed();
6671
await expect($(byTextMatches('Remove Server'))).toBeDisplayed();
6772
});
@@ -104,7 +109,7 @@ describe('Remote Archive - Add Success Flow', () => {
104109
console.warn('🛑 Remote Archive removal failed — restarting app');
105110
await driver.terminateApp('com.comapeo.rc');
106111
await driver.activateApp('com.comapeo.rc');
107-
await driver.pause(1000);
112+
await driver.pause(15000);
108113
return;
109114
}
110115

tests/e2e/utils/date.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
export function getTodayFormattedDate(): string {
1+
export function getFormattedDate(timezone: string): string {
22
return new Date().toLocaleDateString('en-US', {
3-
timeZone: 'America/New_York',
3+
timeZone: timezone,
44
year: 'numeric',
55
month: 'short',
66
day: '2-digit',
77
});
88
}
9+
10+
type DeviceInfo = {
11+
timezone?: string;
12+
[key: string]: any;
13+
};
14+
15+
export async function getDeviceTimezone(): Promise<string> {
16+
const deviceInfo = (await driver.execute('mobile:deviceInfo')) as DeviceInfo;
17+
18+
return deviceInfo.timezone ?? 'UTC';
19+
}

0 commit comments

Comments
 (0)