Skip to content

Commit eb3ca30

Browse files
authored
fix: normalize maestro loading ellipsis (#648)
1 parent 5d2b2ed commit eb3ca30

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/compat/maestro/__tests__/runtime-assertions.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,33 @@ test('invokeMaestroAssertVisible uses snapshot resolution for short iOS assertio
158158
assert.deepEqual(calls, [['snapshot', []]]);
159159
});
160160

161+
test('invokeMaestroAssertVisible treats an elapsed ellipsis loading gate as already past loading', async () => {
162+
vi.spyOn(Date, 'now').mockReturnValueOnce(0).mockReturnValueOnce(0).mockReturnValueOnce(250);
163+
164+
const response = await invokeMaestroAssertVisible({
165+
baseReq: {
166+
token: 't',
167+
session: 's',
168+
flags: {
169+
platform: 'ios',
170+
maestro: { allowAlreadyPastLoading: true },
171+
},
172+
},
173+
positionals: ['label="Loading…" || text="Loading…" || id="Loading…"', '1000'],
174+
invoke: async (): Promise<DaemonResponse> => ({
175+
ok: true,
176+
data: snapshot([node('Dashboard')]),
177+
}),
178+
});
179+
180+
assert.equal(response.ok, true);
181+
if (response.ok) {
182+
assert.ok(response.data);
183+
assert.equal(response.data.alreadyPastLoading, true);
184+
assert.equal(response.data.waitedMs, 250);
185+
}
186+
});
187+
161188
test('invokeMaestroAssertVisible dismisses React Native overlays during snapshot assertions', async () => {
162189
const calls: Array<[string, string[] | undefined]> = [];
163190
let snapshots = 0;

src/compat/maestro/runtime-assertions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,12 @@ function normalizeLoadingText(value: string | null | undefined): string {
373373
value
374374
?.trim()
375375
.toLowerCase()
376-
.replace(/\.\.\./g, '...') ?? ''
376+
.replace(/\u2026/g, '...') ?? ''
377377
);
378378
}
379379

380380
function isLoadingText(value: string): boolean {
381-
return value === 'loading' || value === 'loading...' || value === 'loading…';
381+
return value === 'loading' || value === 'loading...';
382382
}
383383

384384
function visibleAssertionResponse(

0 commit comments

Comments
 (0)