Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

test: titles beside a page back button keep one spacing (#704, #764)

Duarte Santosa408d6d69f62
diff --git a/frontend/src/views/subscreen-header.test.js b/frontend/src/views/subscreen-header.test.js
new file mode 100644
index 000000000..a2c8c63b4
--- /dev/null
+++ b/frontend/src/views/subscreen-header.test.js
@@ -0,0 +1,27 @@
+// Pages off a tab put the round back button beside a 34 px title, and the title sits the same
+// 12 px from it on every one of them (#704, #764). Each page lays its header out inline, so this
+// reads the source: the block right after the chevron is the title, at marginInlineStart 12,
+// with no font size of its own.
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+
+const PAGES = ['Admin', 'History', 'CheckIn', 'Measurements', 'CoachSetup', 'Muscles', 'ProgressPhotos', 'StructuralBalance']
+
+const titleAfterBack = name => {
+ const src = readFileSync(fileURLToPath(new URL(`./${name}.jsx`, import.meta.url)), 'utf8')
+ const at = src.indexOf('<Icon name="chevronLeft" /></button>')
+ expect(at, `${name} has a back chevron`).toBeGreaterThan(-1)
+ return src.slice(at, src.indexOf('</h1>', at))
+}
+
+describe('the title beside a page back button', () => {
+ for (const name of PAGES) {
+ it(`${name}: 12 px from the button, at the shared title size`, () => {
+ const head = titleAfterBack(name)
+ expect(head).toMatch(/<div style=\{\{ flex: 1, marginInlineStart: 12 \}\}>/)
+ expect(head).not.toMatch(/marginLeft/)
+ expect(head).not.toMatch(/<h1 style=\{\{[^}]*fontSize/)
+ })
+ }
+})