Skip to content

Commit af22148

Browse files
committed
test: adopt shared mobile layout assertions
1 parent 39a7afb commit af22148

4 files changed

Lines changed: 46 additions & 22 deletions

File tree

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@types/node": "^22.20.1",
3131
"@typescript-eslint/parser": "^8.48.1",
3232
"@vitest/coverage-v8": "^4.1.9",
33-
"@vrtmrz/obsidian-test-session": "0.1.0",
33+
"@vrtmrz/obsidian-test-session": "0.2.0",
3434
"esbuild": "^0.28.1",
3535
"esbuild-svelte": "^0.9.3",
3636
"eslint": "^9.39.1",

test/e2e-obsidian/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This local-only suite installs the built TagFolder plug-in into an isolated vault and profile through `@vrtmrz/obsidian-test-session`. It is not part of the default CI gate.
44

5-
The new-note scenario selects a seeded template through the real Obsidian picker, verifies its secondary path description, creates a note through TagFolder, and checks the resulting Vault content. The note-lookup scenario drives the real TagFolder commands and Svelte dialogue, adds positive and excluded tags through the keyboard, changes field focus, opens the selected note, and verifies similar-note initialisation. Neither scenario uses scripted UI or Vault responses.
5+
The new-note scenario selects a seeded template through the real Obsidian picker, verifies its secondary path description, creates a note through TagFolder, and checks the resulting Vault content. The note-lookup scenario drives the real TagFolder commands and Svelte dialogue, adds positive and excluded tags through the keyboard, changes field focus, opens the selected note, and verifies similar-note initialisation. At a fixed phone viewport, it also uses the public test-session layout assertions to check the title and Close control against supplied safe-area insets, require a 44 CSS-pixel Close touch target, prevent horizontal overflow in the tag field, and keep the note field inside the viewport. TagFolder retains its plug-in-specific checks for tag wrapping, field shape, and the space reserved for note results. Neither scenario uses scripted UI or Vault responses.
66

77
The suite is currently validated on Linux only. Its explicit preparation command downloads the official Obsidian 1.12.7 AppImage into the ignored `_testdata/obsidian` cache and extracts the matching `obsidian-cli`. Repeated runs reuse the cached download and extraction. Set `OBSIDIAN_BINARY` and `OBSIDIAN_CLI` when using executables outside the shared discovery paths.
88

test/e2e-obsidian/note-lookup.mts

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { withObsidianPage } from "@vrtmrz/obsidian-test-session";
1+
import {
2+
assertLocatorHasMinimumTouchTarget,
3+
assertLocatorWithinSafeArea,
4+
assertLocatorWithinViewport,
5+
assertNoHorizontalOverflow,
6+
withObsidianPage,
7+
} from "@vrtmrz/obsidian-test-session";
28
import type { Page } from "playwright";
39
import {
410
TAGFOLDER_PLUGIN_ID,
@@ -77,33 +83,51 @@ async function verifyPhoneLayout(testSession: TagFolderTestSession): Promise<voi
7783
await tagInput.press("Enter");
7884
}
7985

86+
const safeAreaInsets = {
87+
top: 47,
88+
right: 0,
89+
bottom: 34,
90+
left: 0,
91+
};
92+
const modalTitle = modal.locator(".modal-title");
93+
const closeButton = modal.locator(".modal-close-button");
94+
const tagShell = modal.locator(".tag-input-shell");
95+
const noteInput = modal.locator("#tagfolder-note-lookup-note-input");
96+
await assertLocatorWithinSafeArea(page, modalTitle, {
97+
label: "note lookup title",
98+
safeAreaInsets,
99+
});
100+
await assertLocatorWithinSafeArea(page, closeButton, {
101+
label: "note lookup close button",
102+
safeAreaInsets,
103+
});
104+
await assertLocatorHasMinimumTouchTarget(page, closeButton, {
105+
label: "note lookup close button",
106+
});
107+
await assertNoHorizontalOverflow(page, tagShell, {
108+
label: "note lookup tag field",
109+
});
110+
await assertLocatorWithinViewport(page, noteInput, {
111+
label: "note lookup note field",
112+
});
113+
80114
const layout = await modal.evaluate((element) => {
81-
const close = element.querySelector<HTMLElement>(".modal-close-button");
82115
const tagShell = element.querySelector<HTMLElement>(".tag-input-shell");
83116
const tagChips = element.querySelector<HTMLElement>(".tag-chips");
84-
const noteInput = element.querySelector<HTMLElement>("#tagfolder-note-lookup-note-input");
85-
if (!close || !tagShell || !tagChips || !noteInput) throw new Error("Phone layout elements were unavailable");
117+
if (!tagShell || !tagChips) throw new Error("Phone layout elements were unavailable");
86118
const modalRect = element.getBoundingClientRect();
87-
const closeRect = close.getBoundingClientRect();
88119
const shellRect = tagShell.getBoundingClientRect();
89-
const noteRect = noteInput.getBoundingClientRect();
90120
const shellStyle = getComputedStyle(tagShell);
91121
const inputHeight = Number.parseFloat(shellStyle.getPropertyValue("--input-height"));
92122
const shellRadius = Number.parseFloat(shellStyle.borderTopLeftRadius);
93-
const safeAreaTop = 47;
94123
return {
95-
modalClearsSafeArea: modalRect.top >= safeAreaTop - 1,
96-
closeClearsSafeArea: closeRect.top >= safeAreaTop,
97-
closeHasTouchTarget: closeRect.width >= 44 && closeRect.height >= 44,
98124
tagsStayInsideModal: shellRect.left >= modalRect.left && shellRect.right <= modalRect.right,
99-
tagsDoNotScrollHorizontally: tagShell.scrollWidth <= tagShell.clientWidth,
100125
tagAreaPrioritisesNotes: tagChips.clientHeight <= Math.min(inputHeight * 1.5, innerHeight * 0.15) + 1,
101126
tagFieldUsesCompactRadius: shellRadius <= 12,
102-
noteInputRemainsVisible: noteRect.bottom <= innerHeight,
103127
};
104128
});
105129
if (!Object.values(layout).every(Boolean)) {
106-
throw new Error(`Phone layout did not respect safe areas and tag bounds: ${JSON.stringify(layout)}`);
130+
throw new Error(`Phone layout did not preserve TagFolder-specific tag proportions and bounds: ${JSON.stringify(layout)}`);
107131
}
108132
await tagInput.press("Escape");
109133
} finally {

0 commit comments

Comments
 (0)