Skip to content

Commit 80b277e

Browse files
committed
refactor: simplify landing page DOM structure
Simplify the landing page markup by removing single-child wrappers and moving layout classes onto the surviving elements where needed. Add responsive visual snapshots for the major landing page sections at desktop, tablet, and mobile widths so the refactor has a stable regression baseline.
1 parent f3ea0c6 commit 80b277e

21 files changed

Lines changed: 240 additions & 129 deletions

__tests__/LandingPage_.test.res

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
open ReactRouter
22
open Vitest
33

4+
@module("vitest")
5+
external testWithTimeout: (string, unit => promise<unit>, int) => unit = "test"
6+
47
let expectedExample = `module Button = {
58
@react.component
69
let make = (~count) => {
@@ -15,6 +18,118 @@ let expectedExample = `module Button = {
1518
}
1619
}`
1720

21+
let renderSection = async (~width, ~height, ~testId, component) => {
22+
await viewport(width, height)
23+
24+
let screen = await render(
25+
<MemoryRouter initialEntries=["/"]>
26+
<div dataTestId=testId> component </div>
27+
</MemoryRouter>,
28+
)
29+
30+
let wrapper = await screen->getByTestId(testId)
31+
await element(wrapper)->toBeVisible
32+
wrapper
33+
}
34+
35+
let snapshotResponsive = async (~testId, ~screenshotBase, component) => {
36+
let desktop = await renderSection(
37+
~width=1440,
38+
~height=900,
39+
~testId={`${testId}-desktop`},
40+
component(),
41+
)
42+
await element(desktop)->toMatchScreenshot(`${screenshotBase}-desktop`)
43+
44+
let tablet = await renderSection(
45+
~width=900,
46+
~height=900,
47+
~testId={`${testId}-tablet`},
48+
component(),
49+
)
50+
await element(tablet)->toMatchScreenshot(`${screenshotBase}-tablet`)
51+
52+
let mobile = await renderSection(
53+
~width=600,
54+
~height=1200,
55+
~testId={`${testId}-mobile`},
56+
component(),
57+
)
58+
await element(mobile)->toMatchScreenshot(`${screenshotBase}-mobile`)
59+
}
60+
61+
testWithTimeout(
62+
"landing intro snapshots",
63+
async () => {
64+
await snapshotResponsive(
65+
~testId="landing-intro-test-wrapper",
66+
~screenshotBase="landing-page-intro",
67+
LandingPage.introForTest,
68+
)
69+
},
70+
30000,
71+
)
72+
73+
testWithTimeout(
74+
"landing playground hero snapshots",
75+
async () => {
76+
await snapshotResponsive(
77+
~testId="landing-playground-hero-test-wrapper",
78+
~screenshotBase="landing-page-playground-hero",
79+
LandingPage.playgroundHeroForTest,
80+
)
81+
},
82+
30000,
83+
)
84+
85+
testWithTimeout(
86+
"landing quick install snapshots",
87+
async () => {
88+
await snapshotResponsive(
89+
~testId="landing-quick-install-test-wrapper",
90+
~screenshotBase="landing-page-quick-install",
91+
LandingPage.quickInstallForTest,
92+
)
93+
},
94+
30000,
95+
)
96+
97+
testWithTimeout(
98+
"landing other selling points snapshots",
99+
async () => {
100+
await snapshotResponsive(
101+
~testId="landing-other-selling-points-test-wrapper",
102+
~screenshotBase="landing-page-other-selling-points",
103+
LandingPage.otherSellingPointsForTest,
104+
)
105+
},
106+
30000,
107+
)
108+
109+
testWithTimeout(
110+
"landing trusted by snapshots",
111+
async () => {
112+
await snapshotResponsive(
113+
~testId="landing-trusted-by-test-wrapper",
114+
~screenshotBase="landing-page-trusted-by",
115+
LandingPage.trustedByForTest,
116+
)
117+
},
118+
30000,
119+
)
120+
121+
testWithTimeout(
122+
"landing curated resources snapshots",
123+
async () => {
124+
await snapshotResponsive(
125+
~testId="landing-curated-resources-test-wrapper",
126+
~screenshotBase="landing-page-curated-resources",
127+
LandingPage.curatedResourcesForTest,
128+
)
129+
},
130+
30000,
131+
)
132+
18133
test(
19134
"landing page playground link uses compressed code that the playground can decode",
20135
async () => {
67.6 KB
Loading
48.1 KB
Loading
56.6 KB
Loading
67.5 KB
Loading
39.1 KB
Loading
66.3 KB
Loading
391 KB
Loading
130 KB
Loading
334 KB
Loading

0 commit comments

Comments
 (0)