Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/vrt/approve-latest-build.sh

This file was deleted.

21 changes: 9 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ concurrency:
cancel-in-progress: true

jobs:
playwright:
example:
name: ${{ matrix.example }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
example: [playwright]
defaults:
run:
shell: bash
working-directory: playwright
working-directory: ${{ matrix.example }}
env:
VRT_APIURL: http://localhost:4200
VRT_APIKEY: DEFAULTUSERAPIKEYTOBECHANGED
VRT_PROJECT: Default project
VRT_BRANCHNAME: master
VRT_ENABLESOFTASSERT: "true"
steps:
- uses: actions/checkout@v7
- name: Start Visual Regression Tracker
Expand All @@ -37,11 +41,4 @@ jobs:
- run: pwsh bin/Debug/net10.0/playwright.ps1 install --with-deps --only-shell chromium
- name: Wait for Visual Regression Tracker
run: timeout 180 bash -c 'until curl -s -o /dev/null http://localhost:4200; do sleep 2; done'
- name: First run fails, the screenshot has no baseline yet
run: |
if dotnet test --no-build | tee first-run.log; then exit 1; fi
grep -q 'No baseline' first-run.log
- name: Approve the new baseline
run: ../.github/vrt/approve-latest-build.sh
- name: Second run passes against the approved baseline
run: dotnet test --no-build
- run: dotnet test --no-build --output detailed
5 changes: 1 addition & 4 deletions playwright/HomePageTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using VisualRegressionTracker;

public class HomePageTests
{
[Test]
public async Task HomePageMatchesBaseline()
public async Task TrackHomePage()
{
await using var context = await TestSession.Browser.NewContextAsync();
var page = await context.NewPageAsync();
Expand All @@ -17,6 +15,5 @@ public async Task HomePageMatchesBaseline()
viewport: $"{page.ViewportSize!.Width}x{page.ViewportSize.Height}");

TestContext.Out.WriteLine($"{result.Status}: {result.Url}");
Assert.That(result.Status, Is.AnyOf(TestRunStatus.Ok, TestRunStatus.Approved, TestRunStatus.AutoApproved));
}
}
11 changes: 6 additions & 5 deletions playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
## Run

```sh
dotnet test
dotnet test --output detailed
```

## What to expect

- First run: the test fails with `No baseline` and a link to the test run. The VRT UI shows a build with one `New` test run, "Home page".
- Approve it in the UI. It becomes the baseline for the branch.
- Next runs pass while the page looks the same (`Ok`). When it changes, the test fails with `Difference found` and the build shows an `Unresolved` test run with the diff. Approve the change to make it the new baseline, or reject it.
`enableSoftAssert` is on, as in the other examples: the SDK writes a failed check to stderr instead of throwing, so the test passes and prints the status and a link to the test run.

`New` and `Unresolved` fail the test; `Ok`, `Approved` and `AutoApproved` pass. With `enableSoftAssert`, the SDK writes the failure to stderr instead of throwing, and the status assertion in the test fails it.
- First run: `New`, with `No baseline` on stderr. The VRT UI shows a build with one new test run, "Home page". Approve it to make it the baseline for the branch.
- Next runs: `Ok` while the page looks the same. When it changes, `Unresolved`, with `Difference found` on stderr, and the build shows the diff to approve or reject.

Set `enableSoftAssert` to `false` to make `New` and `Unresolved` fail the test.
2 changes: 1 addition & 1 deletion playwright/vrt.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"apiKey": "DEFAULTUSERAPIKEYTOBECHANGED",
"project": "Default project",
"branchName": "master",
"enableSoftAssert": false
"enableSoftAssert": true
}
Loading