-
Notifications
You must be signed in to change notification settings - Fork 32
feat(advanced): PER-8195 — advanced example for io.percy:percy-java-selenium #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c5b4198
feat(advanced): PER-8195 Phase 1 stub — matrix.yml + README
Shivanshu-07 75ea0b5
feat(advanced): PER-8195 Phase 1 — add advanced example for io.percy:…
Shivanshu-07 e91cb1e
fix(ci): run advanced job like the basic job; drop unpublished shared…
Shivanshu-07 75dbf3e
fix(ci): add advanced/package.json so make finds node_modules/.bin/pe…
Shivanshu-07 ebe5e7b
fix(advanced): serve TodoMVC from src/main/resources so seed finds .n…
Shivanshu-07 6e07908
ci: limit GITHUB_TOKEN to read-only permissions (PER-8195)
Shivanshu-07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| target/ | ||
| *.class | ||
| advanced-requests.json | ||
| node_modules/ | ||
| *.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # PER-8195 — advanced example global config for io.percy:percy-java-selenium. | ||
| # Per-snapshot Map options in AdvancedTest override these. | ||
|
|
||
| version: 2 | ||
|
|
||
| snapshot: | ||
| widths: [375, 1280] | ||
| min-height: 1024 | ||
| percy-css: | | ||
| .new-todo::placeholder { color: #999 !important; } | ||
|
|
||
| discovery: | ||
| allowed-hostnames: | ||
| - localhost | ||
| network-idle-timeout: 500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| NPM=node_modules/.bin | ||
|
|
||
| $(NPM): | ||
| npm install --no-save @percy/cli@^1.31.13 | ||
|
|
||
| .PHONY: install clean test test-advanced test-advanced-ci | ||
|
|
||
| install: $(NPM) | ||
|
|
||
| clean: | ||
| rm -rf target node_modules advanced-requests.json | ||
|
|
||
| # Local run against a real PERCY_TOKEN. | ||
| test test-advanced: install | ||
| $(NPM)/percy exec -- mvn test | ||
|
|
||
| # CI run in --testing mode + capture requests file. | ||
| test-advanced-ci: install | ||
| PERCY_TOKEN=fake_token $(NPM)/percy exec --testing -- bash -c '\ | ||
| mvn test; \ | ||
| ec=$$?; \ | ||
| curl -fsS http://localhost:5338/test/requests > advanced-requests.json || true; \ | ||
| exit $$ec' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Advanced Percy + Selenium-Java example | ||
|
|
||
| This directory exercises the full applicable Percy SDK feature surface for `io.percy:percy-java-selenium`. See the basic example at the repo root for the minimum integration. | ||
|
|
||
| ## What this example covers | ||
|
|
||
| A JUnit 5 suite (`src/test/java/io/percy/examplepercyjavaselenium/advanced/AdvancedTest.java`) where each `@Test` exercises one row of the [Percy SDK Advanced Feature Matrix](../../../docs/advanced-example-feature-matrix.md) using the SDK's typed overloads (`snapshot(name, widths, minHeight, enableJavaScript, percyCSS, scope)`) and the `Map<String, Object> options` overload for everything else (responsive, readiness, labels, testCase, devicePixelRatio, browsers, regions, sync). | ||
|
|
||
| Global SDK config — readiness preset, default widths, percyCSS, discovery — lives in `.percy.yml`. | ||
|
|
||
| ## Run locally | ||
|
|
||
| ```bash | ||
| cd advanced | ||
| make install # installs @percy/cli into node_modules | ||
| export PERCY_TOKEN="<your token>" # do NOT commit this | ||
| make test | ||
| ``` | ||
|
|
||
| To run without a real token (CI assertion mode): | ||
|
|
||
| ```bash | ||
| make test-advanced-ci # uses --testing + PERCY_TOKEN=fake_token + captures /test/requests | ||
| ``` | ||
|
|
||
| The CI variant asserts every matrix row appears in the captured POST bodies at the local `/test/requests` endpoint. No real Percy build is created. | ||
|
|
||
| ## Coverage matrix | ||
|
|
||
| States: `Covered` / `N/A — <reason>` / `Planned` / `Deprecated`. Source of truth is [`matrix.yml`](./matrix.yml). | ||
|
|
||
| | Feature | State | Test | | ||
| |---|---|---| | ||
| | widths (typed overload) | Covered | `exercisesWidthsOverload` | | ||
| | minHeight (typed overload) | Covered | `exercisesMinHeightOverload` | | ||
| | enableJavaScript (typed overload) | Covered | `exercisesEnableJavaScriptOverload` | | ||
| | percyCSS (typed overload) | Covered | `exercisesPercyCssOverload` | | ||
| | scope (typed overload) | Covered | `exercisesScopeOverload` | | ||
| | responsiveSnapshotCapture (Map options) | Covered | `exercisesMapOptionsResponsiveAndReadiness` | | ||
| | readiness preset (Map options) | Covered | `exercisesMapOptionsResponsiveAndReadiness` | | ||
| | labels (Map options) | Covered | `exercisesMapOptionsLabelsAndTestCase` | | ||
| | testCase (Map options) | Covered | `exercisesMapOptionsLabelsAndTestCase` | | ||
| | devicePixelRatio (Map options) | Covered | `exercisesMapOptionsDevicePixelRatio` | | ||
| | browsers override (Map options) | Covered | `exercisesMapOptionsBrowsers` | | ||
| | regions (Map options) | Covered | `exercisesMapOptionsRegions` | | ||
| | sync mode (Map options) | Covered | `exercisesMapOptionsSync` | | ||
| | Map<String, Object> options overload | Covered | seven `exercisesMapOptions*` tests | | ||
| | `.percy.yml` global config | Covered | `.percy.yml` consumed at build start | | ||
| | environment info reporting | Covered | automatic via SDK client info | | ||
| | PERCY_SERVER_ADDRESS via env | Covered | CI advanced job picks up `PERCY_SERVER_ADDRESS` | | ||
| | `Percy.createRegion` static helper | Planned | — | | ||
| | `domTransformation` (Map options) | Planned | — | | ||
| | `discovery` per-snapshot | N/A | discovery is per-build only | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # PER-8195 Phase 1 — Java-Selenium matrix-row mapping. | ||
| # Test code: src/test/java/io/percy/examplepercyjavaselenium/advanced/AdvancedTest.java | ||
|
|
||
| sdk: java-selenium | ||
| package: io.percy:percy-java-selenium | ||
| language: java | ||
| sdk_min_version: '2.1.2' | ||
| cli_min_version: '1.31.13' | ||
|
|
||
| rows: | ||
| # Typed-overload signatures. | ||
| - id: widths | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesWidthsOverload' | ||
| - id: min_height | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMinHeightOverload' | ||
| - id: enable_javascript | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesEnableJavaScriptOverload' | ||
| - id: percy_css | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesPercyCssOverload' | ||
| - id: scope | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesScopeOverload' | ||
|
|
||
| # Map-based options overload. | ||
| - id: responsive_snapshot_capture | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsResponsiveAndReadiness' | ||
| - id: readiness_preset | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsResponsiveAndReadiness' | ||
| - id: labels | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsLabelsAndTestCase' | ||
| - id: test_case | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsLabelsAndTestCase' | ||
| - id: device_pixel_ratio | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsDevicePixelRatio' | ||
| - id: browsers | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsBrowsers' | ||
| - id: regions | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsRegions' | ||
| - id: sync | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptionsSync' | ||
| - id: map_options_overload | ||
| state: covered | ||
| test: 'AdvancedTest > exercisesMapOptions* (7 tests use the Map<String,Object> overload)' | ||
|
|
||
| - id: create_region_helper | ||
| state: planned | ||
| test: 'use of Percy.createRegion static helper to build region — TBD' | ||
| - id: dom_transformation | ||
| state: planned | ||
| test: 'AdvancedTest > exercisesDomTransformation (via Map options)' | ||
|
|
||
| - id: discovery | ||
| state: n_a | ||
| reason: 'discovery is per-build, not per-snapshot in this SDK.' | ||
|
|
||
| - id: env_percy_server_address | ||
| state: covered | ||
| test: 'CI: advanced job sets PERCY_SERVER_ADDRESS via env' | ||
| - id: percy_yml_global_config | ||
| state: covered | ||
| test: 'global config consumed via .percy.yml' | ||
| - id: environment_info_reporting | ||
| state: covered | ||
| test: 'automatic via io.percy:percy-java-selenium client info' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "example-percy-java-selenium-advanced", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Advanced Percy example — local @percy/cli so the Makefile's node_modules/.bin/percy resolves (PER-8195).", | ||
| "devDependencies": { | ||
| "@percy/cli": "^1.31.13" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <?xml version="1.0"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>io.percy.examplepercyjavaselenium</groupId> | ||
| <artifactId>example-percy-java-selenium-advanced</artifactId> | ||
| <packaging>jar</packaging> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <name>example-percy-java-selenium-advanced</name> | ||
| <properties> | ||
| <junit.jupiter.version>5.9.1</junit.jupiter.version> | ||
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <version>${junit.jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>${junit.jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.seleniumhq.selenium</groupId> | ||
| <artifactId>selenium-java</artifactId> | ||
| <version>4.36.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.seleniumhq.selenium</groupId> | ||
| <artifactId>selenium-chrome-driver</artifactId> | ||
| <version>4.36.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.percy</groupId> | ||
| <artifactId>percy-java-selenium</artifactId> | ||
| <version>2.1.2</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.22.2</version> | ||
| <configuration> | ||
| <useSystemClassLoader>false</useSystemClassLoader> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.