Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d8f74cb
Create published-screenshots
amarilda611 Jun 1, 2025
d66f40b
Delete published-screenshots
amarilda611 Jun 1, 2025
bb95f3c
Create .gitkeep
amarilda611 Jun 1, 2025
cddf92e
Update example.spec.js
amarilda611 Jun 1, 2025
98aca7f
Create .gitignore
amarilda611 Jun 1, 2025
1d9d9ae
Update playwright.yml
amarilda611 Jun 1, 2025
c6cff76
Update playwright.yml
amarilda611 Jun 1, 2025
a312f38
Update playwright.yml
amarilda611 Jun 1, 2025
61b4578
Update playwright.yml
amarilda611 Jun 1, 2025
f25f00d
Docs: Publish Playwright screenshots for PR #82 [skip ci]
github-actions[bot] Jun 1, 2025
223d1df
Update playwright.yml
amarilda611 Jun 1, 2025
8f24ec7
Update playwright.yml
amarilda611 Jun 1, 2025
f3cde19
Update playwright.yml
amarilda611 Jun 3, 2025
5a1684d
Update playwright.yml
amarilda611 Jun 10, 2025
3c56246
Update example.spec.js
amarilda611 Jun 13, 2025
e9ba776
Update playwright.yml
amarilda611 Jun 13, 2025
04f3c49
Update example.spec.js
amarilda611 Jun 13, 2025
4cf6f0d
Update playwright.yml
amarilda611 Jun 13, 2025
842a81d
Update playwright.yml
amarilda611 Jun 13, 2025
56b6c9c
Update playwright.yml
amarilda611 Jun 13, 2025
0c52e5e
Update playwright.yml
amarilda611 Jun 13, 2025
0a7f235
Update playwright.yml
amarilda611 Jun 13, 2025
b38735c
Update playwright.yml
amarilda611 Jun 15, 2025
32115ab
Update playwright.yml
amarilda611 Jun 15, 2025
b32f909
Update playwright.yml
amarilda611 Jun 15, 2025
faa6cf9
Update playwright.yml
amarilda611 Jun 15, 2025
1077279
Update playwright.yml
amarilda611 Jun 15, 2025
c8e1a10
Update playwright.yml
amarilda611 Jun 15, 2025
53c64b3
Update playwright.config.js
amarilda611 Jun 15, 2025
8f38e11
Update playwright.yml
amarilda611 Jun 15, 2025
8b91826
Update playwright.config.js
amarilda611 Jun 15, 2025
4100ed6
Update playwright.yml
amarilda611 Jun 15, 2025
6761349
Update playwright.yml
amarilda611 Jun 15, 2025
c7eb28b
Update playwright.config.js
amarilda611 Jun 15, 2025
e2edaea
Update playwright.config.js
amarilda611 Jun 15, 2025
0690cec
Update playwright.yml
amarilda611 Jun 15, 2025
9ca36a1
Update playwright.config.js
amarilda611 Jun 15, 2025
cd72dc5
Update playwright.yml
amarilda611 Jun 15, 2025
1f42352
Update playwright.config.js
amarilda611 Jun 15, 2025
eeee5ff
Update playwright.yml
amarilda611 Jun 15, 2025
d800730
Update playwright.yml
amarilda611 Jun 15, 2025
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
95 changes: 83 additions & 12 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ on:
jobs:
test:
runs-on: ubuntu-latest

permissions:
contents: read
contents: write
pull-requests: write

steps:
Expand All @@ -20,7 +19,9 @@ jobs:
#---------------------------------------------------
- name: Checkout code
uses: actions/checkout@v3
with: { fetch-depth: 0 }
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

#---------------------------------------------------
# 1 – reviewdog CLI
Expand All @@ -47,6 +48,7 @@ jobs:
-level=warning
else
echo "No Prettier issues found."
Ends if
fi

#---------------------------------------------------
Expand All @@ -71,6 +73,71 @@ jobs:
- name: Run Playwright tests
run: npx playwright test

# --- START OF NEW STEPS FOR SCREENSHOT PUBLISHING ---

# Prepare the directory for PR-specific screenshots on GitHub Pages
- name: Prepare PR Screenshots for GitHub Pages
if: github.event_name == 'pull_request'
run: |
PR_DIR="docs/pr/${{ github.event.pull_request.number }}/screenshots"
mkdir -p "$PR_DIR"
cp published-screenshots/*.png "$PR_DIR/"
echo "Copied screenshots to $PR_DIR/"
ls -lh "$PR_DIR/" # For debugging, shows what was copied

# Commit and Push PR Screenshots to GitHub Pages
- name: Commit and Push PR Screenshots to GitHub Pages
if: github.event_name == 'pull_request'
uses: EndBug/add-and-commit@v9
with:
add: 'docs/pr/${{ github.event.pull_request.number }}/screenshots/'
message: 'Docs: Publish Playwright screenshots for PR #${{ github.event.pull_request.number }} [skip ci]'
default_author: github_actions
push: true

# Generate Markdown for screenshots with their public URLs
- name: Generate Screenshot Markdown for PR Comment
id: generate_screenshot_markdown
if: github.event_name == 'pull_request'
run: |
REPO_OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1)
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
PR_NUMBER="${{ github.event.pull_request.number }}"
PR_SCREENSHOTS_LOCAL_DIR="docs/pr/${PR_NUMBER}/screenshots"

GITHUB_PAGES_BASE_URL="https://digitalproductinnovationanddevelopment.github.io/Code-Reviews-of-GUI-Tests/pr/${PR_NUMBER}/screenshots/"

IMAGE_MARKDOWN=""
# Check if the directory exists and contains PNG files
if [ -d "$PR_SCREENSHOTS_LOCAL_DIR" ]; then
# Get all PNG filenames into a bash array in the current shell context
# 'shopt -s nullglob' ensures the glob expands to nothing if no files match
shopt -s nullglob
declare -a IMG_FILES=("$PR_SCREENSHOTS_LOCAL_DIR"/*.png)
shopt -u nullglob # disable nullglob after use

if [ ${#IMG_FILES[@]} -gt 0 ]; then
echo "Found ${#IMG_FILES[@]} screenshot(s) for markdown generation:"
for img_path in "${IMG_FILES[@]}"; do
img_name=$(basename "$img_path")
img_url="${GITHUB_PAGES_BASE_URL}${img_name}"
IMAGE_MARKDOWN+="![${img_name}](${img_url})\n\n"
echo "- $img_name" # Debugging: show which file is being processed
done
else
echo "No PNG files found in $PR_SCREENSHOTS_LOCAL_DIR for markdown generation."
fi
else
echo "Warning: Directory '$PR_SCREENSHOTS_LOCAL_DIR' does not exist for Markdown generation."
fi

echo "pr_screenshots_markdown<<EOF" >> $GITHUB_OUTPUT
echo "$IMAGE_MARKDOWN" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash # Ensure bash is used for array and shopt features

# --- END OF NEW STEPS FOR SCREENSHOT PUBLISHING ---

#---------------------------------------------------
# 6 – Upload HTML report
#---------------------------------------------------
Expand All @@ -90,7 +157,7 @@ jobs:
REPORT=metrics.json
TOTAL=$(jq '[..|objects|select(has("status"))] | length' "$REPORT")
PASSED=$(jq '[..|objects|select(.status?=="expected")] | length' "$REPORT")
FAILED=$(jq '[..|objects|select(.status?=="failed")] | length' "$REPORT")
FAILED=$(jq '[..|objects|select(.status?=="failed")] | length' "$REPORT")
SKIPPED=$(jq '[..|objects|select(.status?=="skipped")] | length' "$REPORT")
DURATION=$(jq '.stats.duration*1000|floor' "$REPORT")
PASS_RATE=$(awk "BEGIN{printf \"%.2f\", ($TOTAL==0)?0:($PASSED/$TOTAL)*100}")
Expand Down Expand Up @@ -120,8 +187,6 @@ jobs:
head -n 20 eslint-tests.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT



#---------------------------------------------------
# 9 – Generate Suite→Spec Mermaid chart (flowchart.png)
#---------------------------------------------------
Expand Down Expand Up @@ -168,7 +233,7 @@ jobs:

ls -lh flowchart.png

- name: Show flowchart.mmd for debugging
- name: Show flowchart.mmd for debugging
run: cat flowchart.mmd

- name: Upload test-flow chart
Expand All @@ -186,20 +251,26 @@ jobs:
with:
message: |
## Playwright Test Metrics
*Total:* **${{ steps.summary.outputs.total }}**
*Passed:* **${{ steps.summary.outputs.passed }}**
*Failed:* **${{ steps.summary.outputs.failed }}**
*Total:* **${{ steps.summary.outputs.total }}**
*Passed:* **${{ steps.summary.outputs.passed }}**
*Failed:* **${{ steps.summary.outputs.failed }}**
*Skipped:* **${{ steps.summary.outputs.skipped }}**

Duration: **${{ steps.summary.outputs.duration }} ms**
Duration: **${{ steps.summary.outputs.duration }} ms**
Pass Rate: **${{ steps.summary.outputs.passrate }} %**

## ESLint (GUI tests)
```
${{ steps.lint_summary.outputs.summary }}
```

## Test-Flow Chart
## Test-Flow Chart
# Note: The flowchart.png is uploaded as an artifact. To embed it directly like screenshots,
# you would also need to copy it into the 'published-screenshots' directory in step 9,
# and then reference it using the PR-specific GitHub Pages URL.
Artifact: **test-flow-chart → flowchart.png**

## Playwright Screenshots for this PR
${{ steps.generate_screenshot_markdown.outputs.pr_screenshots_markdown }}

_Full run details:_ [link](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore generated screenshots
published-screenshots/

# You might also want to ignore Node.js dependencies
node_modules/

# And Playwright test results/reports
playwright-report/
Binary file added docs/pr/82/screenshots/example-domain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pr/82/screenshots/navigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions published-screenshots/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 7 additions & 4 deletions tests/example.spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// tests/example.spec.js
const { test, expect } = require('@playwright/test');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
const { test, expect } = require('@playwright/test');
const { test, expect } = require("@playwright/test");


test.describe('Playwright Basic Workflow Tests', () => {
test('should load example.com and verify title', async ({ page }) => {
await page.goto('https://example.com');
Comment on lines 4 to 6
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
test.describe('Playwright Basic Workflow Tests', () => {
test('should load example.com and verify title', async ({ page }) => {
await page.goto('https://example.com');
test.describe("Playwright Basic Workflow Tests", () => {
test("should load example.com and verify title", async ({ page }) => {
await page.goto("https://example.com");

await expect(page).toHaveTitle(/Example Domain/);
await page.screenshot({ path: 'playwright-report/example-domain.png' });
// **CHANGE THIS LINE:** Use process.env.PLAYWRIGHT_SCREENSHOT_DIR
await page.screenshot({ path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || 'published-screenshots'}/example-domain.png` });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.screenshot({ path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || 'published-screenshots'}/example-domain.png` });
await page.screenshot({
path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || "published-screenshots"}/example-domain.png`,
});

});

test('should find and click the More information link', async ({ page }) => {
await page.goto('https://example.com');
await page.click('text=More information');
Comment on lines 12 to 14
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
test('should find and click the More information link', async ({ page }) => {
await page.goto('https://example.com');
await page.click('text=More information');
test("should find and click the More information link", async ({ page }) => {
await page.goto("https://example.com");
await page.click("text=More information");

await expect(page).toHaveURL(/iana.org/);
await page.screenshot({ path: 'playwright-report/navigation.png' });
// **CHANGE THIS LINE:** Use process.env.PLAYWRIGHT_SCREENSHOT_DIR
await page.screenshot({ path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || 'published-screenshots'}/navigation.png` });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.screenshot({ path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || 'published-screenshots'}/navigation.png` });
await page.screenshot({
path: `${process.env.PLAYWRIGHT_SCREENSHOT_DIR || "published-screenshots"}/navigation.png`,
});

});
});
});
Loading