|
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"; |
2 | 8 | import type { Page } from "playwright"; |
3 | 9 | import { |
4 | 10 | TAGFOLDER_PLUGIN_ID, |
@@ -77,33 +83,51 @@ async function verifyPhoneLayout(testSession: TagFolderTestSession): Promise<voi |
77 | 83 | await tagInput.press("Enter"); |
78 | 84 | } |
79 | 85 |
|
| 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 | + |
80 | 114 | const layout = await modal.evaluate((element) => { |
81 | | - const close = element.querySelector<HTMLElement>(".modal-close-button"); |
82 | 115 | const tagShell = element.querySelector<HTMLElement>(".tag-input-shell"); |
83 | 116 | 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"); |
86 | 118 | const modalRect = element.getBoundingClientRect(); |
87 | | - const closeRect = close.getBoundingClientRect(); |
88 | 119 | const shellRect = tagShell.getBoundingClientRect(); |
89 | | - const noteRect = noteInput.getBoundingClientRect(); |
90 | 120 | const shellStyle = getComputedStyle(tagShell); |
91 | 121 | const inputHeight = Number.parseFloat(shellStyle.getPropertyValue("--input-height")); |
92 | 122 | const shellRadius = Number.parseFloat(shellStyle.borderTopLeftRadius); |
93 | | - const safeAreaTop = 47; |
94 | 123 | return { |
95 | | - modalClearsSafeArea: modalRect.top >= safeAreaTop - 1, |
96 | | - closeClearsSafeArea: closeRect.top >= safeAreaTop, |
97 | | - closeHasTouchTarget: closeRect.width >= 44 && closeRect.height >= 44, |
98 | 124 | tagsStayInsideModal: shellRect.left >= modalRect.left && shellRect.right <= modalRect.right, |
99 | | - tagsDoNotScrollHorizontally: tagShell.scrollWidth <= tagShell.clientWidth, |
100 | 125 | tagAreaPrioritisesNotes: tagChips.clientHeight <= Math.min(inputHeight * 1.5, innerHeight * 0.15) + 1, |
101 | 126 | tagFieldUsesCompactRadius: shellRadius <= 12, |
102 | | - noteInputRemainsVisible: noteRect.bottom <= innerHeight, |
103 | 127 | }; |
104 | 128 | }); |
105 | 129 | 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)}`); |
107 | 131 | } |
108 | 132 | await tagInput.press("Escape"); |
109 | 133 | } finally { |
|
0 commit comments