Skip to content

Commit c4d8717

Browse files
lamATnginxmaximusmith529
authored andcommitted
Added new UI smoke tests (#382)
* Tests: Added new UI smoke tests * Tests: Fix issue where consent pops up after click event * Tests: Fix tests + biome * Tests: Add test for tabs * Tests: Add webkit + add comment for geolocation * Tests: Fix header test on webkit * Tests: Make test less flaky
1 parent ea03101 commit c4d8717

26 files changed

+291
-143
lines changed

.github/workflows/playwright.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Testing for visual regression on old theme
1+
name: Running Playwright test on UI
22

33
# Run the workflow when code is pushed or when a pull request is created
44
on:
@@ -25,19 +25,16 @@ jobs:
2525
- name: Install dependencies and playwright browsers
2626
run: cd tests && npm ci && npx playwright install --with-deps
2727
- name: Run Playwright tests
28-
id: test-visual
28+
id: test-ui
2929
run: |
3030
make tests | tee output.log
31-
if grep -q -e "Error: A snapshot doesn't exist at" -e "Screenshot comparison failed" output.log; then
32-
echo "Playwright tests failed due to a snapshot issue."
33-
exit 1
34-
elif grep -q "failed" output.log; then
35-
echo "Playwright tests failed due to a non-snapshot issue."
31+
if grep -q "failed" output.log; then
32+
echo "Playwright tests failed. Please view the Playwright report to see full error."
3633
exit 1
3734
fi
3835
- uses: actions/upload-artifact@v4
3936
id: artifact-upload
40-
if: ${{ !cancelled() && failure() && steps.test-visual.conclusion == 'failure' }}
37+
if: ${{ !cancelled() && failure() && steps.test-ui.conclusion == 'failure' }}
4138
with:
4239
name: playwright-report
4340
path: tests/playwright-report/
@@ -47,10 +44,9 @@ jobs:
4744
if: ${{ failure() }}
4845
with:
4946
script: |
50-
const body = `### <span aria-hidden="true">❌</span> Playwright visual snapshot differences were detected.
47+
const body = `### <span aria-hidden="true">❌</span> Playwright differences were detected.
5148
52-
View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }})
53-
**To approve the snapshot changes and update the snapshots, please comment:** /approve-snapshots`;
49+
View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }})`;
5450
5551
await github.rest.issues.createComment({
5652
issue_number: context.issue.number,

.github/workflows/update-screenshot.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ WRITE_FLAG := --write
55
list help::
66
$(info Available Make targets:)
77
@echo "<COMMON>"
8-
@echo " list | help: Print these available make targets"
8+
@echo " list | help: Print these available make targets"
99
@echo "<LINTING AND FORMATTING>"
1010
@echo " biome-format: Runs the biome formatter."
1111
@echo " biome-lint: Runs the biome linter."
1212
@echo " biome-all: Runs both the lint and formatting commands."
1313
@echo " build-example-site: Builds hugo exampleSite."
14-
@echo " (Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))"
14+
@echo "(Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))"
1515
@echo "<PRE-COMMIT>"
1616
@echo " setup-pre-commit: Sets up pre-commit (assuming it is installed)"
1717
@echo "<PLAYWRIGHT TESTS>"
18-
@echo " tests: Runs playwright against the old theme."
19-
@echo " tests-update-screenshots: Runs playwright against the old theme."
18+
@echo " tests: Runs playwright against the new theme."
19+
@echo " tests-update-screenshots: Runs playwright against the new theme."
2020

2121
.PHONY: biome-format biome-lint biome-all setup-pre-commit tests build-example-site
2222
FLAG :=

exampleSite/content/test-product/tab-group/tab-group.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ weight: 200
66

77
## tab-group
88

9+
<div data-testid="tabs-test__basic">
910
{{<tabs name="common_steps_for_nginx_oss_and_plus">}}
1011

1112
{{%tab name="Call Outs"%}}
@@ -65,6 +66,7 @@ nginx -s reload
6566

6667

6768
{{</tabs>}}
69+
</div>
6870

6971

7072
## Much nested tab group

exampleSite/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module github.com/nginxinc/docs
22

33
go 1.23
44

5-
require github.com/nginxinc/nginx-hugo-theme v0.41.27 // indirect
5+
require github.com/nginxinc/nginx-hugo-theme v1.0.4 // indirect
66

77
replace github.com/nginxinc/nginx-hugo-theme => ../

layouts/404.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ define "main"}}
22

3-
<div class="content no-sidebar">
4-
<div class="not-found-container">
3+
<div class="content no-sidebar" data-testid="content">
4+
<div class="not-found-container" data-testid="not-found-container">
55
<h1 class="info-header">
66
HTTP 404 - Page not found
77
</h1>

layouts/_default/baseof.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
<input type="checkbox" id="search-standalone-header-panel" class="search-standalone-header-panel" hidden/>
4545
<input type="checkbox" id="sidebar-panel" class="sidebar-panel" hidden/>
4646
<div class="grid-container">
47-
<aside class="sidebar">
47+
<aside class="sidebar" data-testid="sidebar">
4848
{{ partial "sidebar-v2.html" . }}
4949
</aside>
5050

51-
<header class="header">
51+
<header class="header" data-testid="header">
5252
{{ block "header" . }}{{end}}
5353
</header>
5454

5555
{{ block "main" . }}{{ end }}
5656

57-
<footer class="footer">
57+
<footer class="footer" data-testid="footer">
5858
{{ block "footer-v2" . }}
5959
{{ partial "footer-v2.html" . }}
6060
{{ end }}

layouts/_default/list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ define "main" }}
22

3-
<main class="content" role="main">
3+
<main class="content" role="main" data-testid="content">
44
<div data-cms-edit="content" class="text-content list-page">
55
<div class="breadcrumb-layout">
66
{{ if not .IsHome }}
@@ -30,7 +30,7 @@ <h1>{{ .Title }}</h1>
3030

3131
<h2> In this section </h2>
3232
<div class="card-section">
33-
<div class="card-section-content card-grid">
33+
<div class="card-section-content card-grid" data-testid="header-search-dropdown">
3434
{{ range .Pages.ByWeight }}
3535
<a href="{{ .Permalink }}" alt="{{ .Title }}" class="card" data-grid="first-two-thirds">
3636
<div class="card-container">

layouts/_default/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<main class="content">
2+
<main class="content" data-testid="content">
33
<!-- Replace icons -->
44
{{ $content := partial "icon-replacement.html" (dict "content" .Content) }}
55

layouts/partials/api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--Use wide page layout for the API reference pages-->
22
<div class="nginx-docs-api-container">
3-
<div id="api-component" class="content">
3+
<div id="api-component" class="content" data-testid="content">
44
{{ .Content}}
55
</div>
66
</div>

0 commit comments

Comments
 (0)