Skip to content

Commit 52874bf

Browse files
committed
test(harmonyos): pin gesture-viewport invalidation hooks
Assert that backHarmony, homeHarmony, and appSwitcherHarmony call invalidateHarmonyGestureViewport, and that openHarmonyApp/closeHarmonyApp do so on their success paths, so deleting the hook call sites can no longer leave the suite green.
1 parent 575a8ad commit 52874bf

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/platforms/harmonyos/__tests__/app-lifecycle.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ vi.mock('../../../utils/exec.ts', async (importOriginal) => {
77
return { ...actual, runCmd: vi.fn() };
88
});
99

10+
const { invalidateHarmonyGestureViewport } = vi.hoisted(() => ({
11+
invalidateHarmonyGestureViewport: vi.fn(),
12+
}));
13+
14+
vi.mock('../snapshot.ts', async (importOriginal) => ({
15+
...(await importOriginal<typeof import('../snapshot.ts')>()),
16+
invalidateHarmonyGestureViewport,
17+
}));
18+
1019
import {
1120
closeHarmonyApp,
1221
listHarmonyApps,
@@ -32,6 +41,7 @@ const DEVICE = {
3241
beforeEach(() => {
3342
vi.useRealTimers();
3443
mockRunCmd.mockReset();
44+
invalidateHarmonyGestureViewport.mockReset();
3545
});
3646

3747
afterEach(() => {
@@ -146,6 +156,7 @@ test('HarmonyOS lifecycle commands use HDC bundle and ability primitives', async
146156
['-t', 'harmony-1', 'shell', 'aa', 'force-stop', 'com.example.application'],
147157
],
148158
);
159+
assert.deepEqual(invalidateHarmonyGestureViewport.mock.calls, [[DEVICE], [DEVICE]]);
149160
});
150161

151162
test('HarmonyOS app listing filters user-installed bundles through Bundle Manager metadata', async () => {

src/platforms/harmonyos/__tests__/input-actions.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ test('HarmonyOS input primitives use the documented uiInput command names', asyn
7575
],
7676
);
7777
assert.deepEqual(sleep.mock.calls, [[25], [50]]);
78+
assert.deepEqual(invalidateHarmonyGestureViewport.mock.calls, [[DEVICE], [DEVICE], [DEVICE]]);
7879
});
7980

8081
test('HarmonyOS scroll derives a viewport-aware swipe plan', async () => {

0 commit comments

Comments
 (0)