Skip to content

Commit

Permalink
Tooling: end to end integration tests with playwright (#132)
Browse files Browse the repository at this point in the history
* Adding playwright tests
* Added package-lock.json
* Loading from fixed URL
* Allowing override of the test URL
* Updated theme switcher checks
  • Loading branch information
zetxek authored Jan 5, 2025
1 parent d94ec92 commit 8f91bb4
Show file tree
Hide file tree
Showing 7 changed files with 1,301 additions and 15 deletions.
52 changes: 40 additions & 12 deletions .github/workflows/test-example-site.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Workflow to verify that the exampleSite runs ok
name: Dry-run example site
name: Test example site

on:
# Runs on pull requests targeting the default branch
Expand All @@ -11,7 +11,7 @@ on:

jobs:
# Build job
build:
build-and-test:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.136.2
Expand All @@ -21,19 +21,47 @@ jobs:
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Setup hugo site
run: hugo new site theme-test

- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
path: theme-test/themes/adritian-free-hugo-theme

- name: Run demo site
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Build and serve demo site
run: |
cd theme-test
npm i -D postcss postcss-cli autoprefixer
cd themes/adritian-free-hugo-theme/exampleSite
## run example site
hugo build --themesDir ../..
cd exampleSite
hugo server --themesDir ../.. --buildDrafts --buildFuture --bind 0.0.0.0 &
sleep 10
- name: Run Playwright tests
run: npm run test:e2e

- name: Debug directory structure
run: |
pwd
echo "Current directory contents:"
ls -la
echo "Playwright report directory:"
ls -la playwright-report || echo "playwright-report not found"
echo "Test results directory:"
ls -la test-results || echo "test-results not found"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-results
path: |
${{ github.workspace }}/playwright-report
${{ github.workspace }}/test-results
retention-days: 30
1 change: 0 additions & 1 deletion .github/workflows/update-demo-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jobs:
if [ -n "$PR_EXISTS" ]; then
echo "PR Exists. Updating pull-request..."
gh pr view
echo "✅ Pull-request created - done! "
# Else, we create it
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ Thumbs.db
npm-debug.log
node_modules
builds
package-lock.json


Loading

0 comments on commit 8f91bb4

Please sign in to comment.