[docs] KeepHerSafeApps: Round trip on the tablet, the page between Android's bars, review, gaps closed, lessons

This commit is contained in:
2026-11-17 22:22:36 +01:00
parent e262b8f295
commit d5f37b3149
13 changed files with 243 additions and 32 deletions
+31 -13
View File
@@ -95,10 +95,7 @@ async function secondVisit(page: Page): Promise<void> {
await expect(page.getByRole('img', { name: /^The rose/ })).toBeVisible({ timeout: 20_000 });
const numbers = page.getByRole('button', { name: en.rose.numbers });
await expect(async () => {
if ((await numbers.getAttribute('aria-expanded')) !== 'true') {
await numbers.focus();
await numbers.press('Enter');
}
if ((await numbers.getAttribute('aria-expanded')) !== 'true') await press(numbers);
await expect(numbers).toHaveAttribute('aria-expanded', 'true', { timeout: 1_000 });
}).toPass({ timeout: 15_000 });
await expect(page.locator('#rose-numbers')).toContainText(`${en.rose.daysOfCare}1`);
@@ -106,9 +103,22 @@ async function secondVisit(page: Page): Promise<void> {
report['afterRestart'] = 'still watered: 1 day of care, the care log kept';
}
/**
* Presses a button from the keyboard. On the tablet a pointer click waits for the button to stop
* moving, and the planet keeps it moving (review); Enter is a real activation, as for a keyboard player.
*/
async function press(button: ReturnType<Page['getByRole']>): Promise<void> {
await button.focus();
await button.press('Enter');
}
/** Opens *Keep her safe* and checks the app's own words (keep-her-safe-apps.md A1). */
async function openKeepSafe(page: Page): Promise<void> {
await page.getByRole('button', { name: en.rose.safe.title }).click();
const title = page.getByRole('button', { name: en.rose.safe.title });
await expect(async () => {
if ((await title.getAttribute('aria-expanded')) !== 'true') await press(title);
await expect(title).toHaveAttribute('aria-expanded', 'true', { timeout: 1_000 });
}).toPass({ timeout: 15_000 });
await expect(page.getByText(en.rose.safe.app)).toBeVisible();
for (const browserWords of [en.rose.safe.mayClear, en.rose.safe.unknown, en.rose.safe.kept, en.rose.safe.ask]) {
await expect(page.getByText(browserWords)).toHaveCount(0);
@@ -120,7 +130,7 @@ async function openKeepSafe(page: Page): Promise<void> {
async function desktopSave(page: Page): Promise<void> {
await openKeepSafe(page);
const download = page.waitForEvent('download', { timeout: 10_000 });
await page.getByRole('button', { name: en.rose.safe.save }).click();
await press(page.getByRole('button', { name: en.rose.safe.save }));
const d = await download;
report['saveToFile'] = `a download started: ${d.suggestedFilename()} (cancelled by the check)`;
await d.cancel();
@@ -144,18 +154,24 @@ function screenNodes(adb: (...args: string[]) => string): UiNode[] {
return nodes;
}
/** Taps the first node on Android's own screen that matches, waiting up to `ms` for it. */
/**
* Taps the first node on Android's own screen that matches, waiting up to `ms` for it. Only once
* it stands still: a system screen slides in, and a tap read from the first frame landed where the
* file had been a moment before (keep-her-safe-apps review).
*/
async function tapSystem(adb: (...args: string[]) => string, match: (n: UiNode) => boolean, what: string, ms = 20_000): Promise<void> {
const until = Date.now() + ms;
let last: UiNode | undefined;
while (Date.now() < until) {
const node = screenNodes(adb).find(match);
if (node) {
if (node && last && node.cx === last.cx && node.cy === last.cy) {
adb('shell', 'input', 'tap', String(node.cx), String(node.cy));
return;
}
last = node;
await new Promise((r) => setTimeout(r, 700));
}
throw new Error(`Android's screen never showed ${what}`);
throw new Error(`Android's screen never showed ${what}, still`);
}
/**
@@ -174,14 +190,16 @@ async function androidRoundTrip(page: Page, adb: (...args: string[]) => string):
const existed = before.split(/\s+/).includes(name);
if (existed) throw new Error(`/sdcard/Download/${name} is already on the tablet; the check will not overwrite a file it did not make`);
try {
await page.getByRole('button', { name: en.rose.safe.save }).click();
await press(page.getByRole('button', { name: en.rose.safe.save }));
await tapSystem(adb, (n) => /^save$/i.test(n.text), "the save screen's Save button");
await expect(page.getByText(en.rose.safe.saved)).toBeVisible({ timeout: 15_000 });
await expect(page.locator('.safe [role="status"]')).toHaveText(en.rose.safe.saved, { timeout: 15_000 });
report['saveToFile'] = `Android's save screen; the garden said: ${en.rose.safe.saved}`;
await page.locator('input[type="file"]').click({ force: true });
await tapSystem(adb, (n) => n.text === name || n.desc.includes(name), `the file ${name} in the picker`);
await expect(page.getByText(en.rose.safe.alreadyHere)).toBeVisible({ timeout: 15_000 });
// By its own text only: a card's preview button is described as "Preview the file …" and comes first.
await tapSystem(adb, (n) => n.text === name, `the file ${name} in the picker`);
// Read from Keep her safe's own status line: it may be below the fold on a small screen.
await expect(page.locator('.safe [role="status"]')).toHaveText(en.rose.safe.alreadyHere, { timeout: 15_000 });
report['bringBack'] = `chose ${name} in Android's picker; the garden said: ${en.rose.safe.alreadyHere}`;
} finally {
const after = adb('shell', 'ls', '/sdcard/Download/').split(/\s+/);