Skip to content

Commit dad7ab3

Browse files
authored
feat: regenerate README screenshots from the functional tests (#190)
* feat: regenerate README screenshots from the functional tests Adds a refreshReadmeScreenshots task that reruns the functional suite and copies each mapped test's screenshots into docs/images, and commits the refreshed images. The previous set dated from December 2022 and predates the remember-me checkbox and the consent Deny button. * test: shrink the pinned viewport to 640x400 and regenerate the images GitHub scales README images down to its column width but never up, so the 1280x720 captures rendered at ~69% while carrying mostly whitespace. At 640x400 they render 1:1 and the form fills a meaningful share of the frame.
1 parent cc45518 commit dad7ab3

10 files changed

Lines changed: 37 additions & 3 deletions

File tree

1.16 KB
Loading
2.13 KB
Loading
-930 Bytes
Loading
2.15 KB
Loading
2.43 KB
Loading
-1.13 KB
Loading
2.21 KB
Loading
-211 Bytes
Loading

reference-app/build.gradle.kts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ tasks.withType<JavaCompile> {
4747
}
4848
}
4949

50+
// The images embedded in the README are the screenshots the functional tests capture on every
51+
// run. This task republishes them into docs/images so they can be regenerated on purpose instead
52+
// of drifting (the previous set dated from 2022). Keys are docs/images/<flow> directory names,
53+
// values the producing test's screenshot directory under build/test-results/screenshots.
54+
val readmeScreenshotFlows =
55+
mapOf(
56+
"full-oauth-flow-oidc" to "completeFullOAuthFlowUsingUIToLogin",
57+
"remember-me" to "skipConsentScreenOnSecondLoginWhenRememberMeIsUsed",
58+
)
59+
60+
tasks.register("refreshReadmeScreenshots") {
61+
group = "documentation"
62+
description = "Reruns the functional tests and copies their screenshots into docs/images."
63+
dependsOn(tasks.test)
64+
val screenshotsDir = layout.buildDirectory.dir("test-results/screenshots")
65+
val docsImagesDir =
66+
rootProject.layout.projectDirectory
67+
.dir("docs/images")
68+
.asFile
69+
doLast {
70+
readmeScreenshotFlows.forEach { (flow, testName) ->
71+
val source = screenshotsDir.get().dir(testName).asFile
72+
require(source.isDirectory && !source.listFiles().isNullOrEmpty()) {
73+
"No screenshots at $source — did the test get renamed without updating this mapping?"
74+
}
75+
val target = docsImagesDir.resolve(flow)
76+
target.deleteRecursively()
77+
source.copyRecursively(target)
78+
}
79+
}
80+
}
81+
5082
// A way to run Playwright CLI commands using the Java source dependency.
5183
// Particularly useful from within a CI context (see ./.github/workflows.gradle.yml).
5284
// https://playwright.dev/docs/cli#install-system-dependencies

reference-app/src/test/java/com/ardetrick/oryhydrareference/OryHydraReferenceApplicationFunctionalTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ void stopTestEnvironment() {
123123
oryHydraContainer.stop();
124124
}
125125

126-
// Every screenshot these tests capture is destined for the docs, so the viewport is pinned
127-
// rather than left at Playwright's default — a Playwright upgrade must not resize the images.
126+
// Every screenshot these tests capture is destined for the docs, so the viewport is pinned —
127+
// a Playwright upgrade must not resize the images. 640x400 rather than the 1280x720 default
128+
// because GitHub scales README images down to its ~880px column but never up: captures
129+
// narrower than the column render 1:1, and the unstyled pages carry less dead space.
128130
private Page newPage() {
129-
return browser.newPage(new Browser.NewPageOptions().setViewportSize(1280, 720));
131+
return browser.newPage(new Browser.NewPageOptions().setViewportSize(640, 400));
130132
}
131133

132134
@BeforeEach

0 commit comments

Comments
 (0)