Skip to content

Commit

Permalink
ci: add prerender e2e asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Jan 25, 2024
1 parent 7c176af commit 7e2c5df
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"contenttop",
"contentbottom",
"requestfailed",
"requestfinished"
"requestfinished",
"prerendered"
],
"ignoreRegExpList": ["\\(https?://.*?\\)", "\\/{1}.+\\/{1}", "\\%2F.+", "\\%2C.+", "\\ɵ.+", "\\ыва.+"],
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: taiga-family/ci/actions/setup/[email protected]

- name: Building demo-app of git-branch without cache
run: npx nx build demo
run: npx nx prerender demo

- name: Upload cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/[email protected]
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,26 @@ on:
description: update main snapshots

jobs:
snapshots-next:
if: ${{ !contains(github.head_ref || github.ref_name, 'release/') }}
name: next
snapshots:
runs-on: ubuntu-latest
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- run: npx nx build demo --output-path ${{ env.DIST_NEXT }}
- run: tree ${{ env.DIST_NEXT }} -P '*.html'
- run: npx nx prerender demo
- run: tree ${{ env.DIST }} -P '*.html'

- name: Publish next snapshots
if: ${{ !contains(github.head_ref || github.ref_name, 'release/') }}
uses: s0/[email protected]
env:
REPO: self
FOLDER: ${{ env.DIST_NEXT }}
FOLDER: ${{ env.DIST }}
BRANCH: snapshots/demo/next/${{ github.head_ref || github.ref_name }}
GITHUB_TOKEN: ${{ secrets.TAIGA_FAMILY_BOT_PAT }}

snapshots-production:
if: ${{ contains(github.head_ref || github.ref_name, 'release/') || github.event.inputs.updateMain == 'true' }}
name: production
runs-on: ubuntu-latest
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
id: nodejs-workspace

- run: npx nx prerender demo
- run: tree ${{ env.DIST }} -P '*.html'
- name: Publish production snapshots
if: ${{ contains(github.head_ref || github.ref_name, 'release/') || github.event.inputs.updateMain == 'true' }}
uses: s0/[email protected]
env:
REPO: self
Expand Down
19 changes: 19 additions & 0 deletions projects/demo-playwright/tests/ssg.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {expect, test} from '@playwright/test';

test.describe('SSG', () => {
test('has prerendered components by Angular Universal', async ({page}) => {
const response = await page.goto('/');
const body = (await response?.text()) ?? '';
const prerendered = await page.evaluate(
body =>
new DOMParser()
.parseFromString(body, 'text/html')
.body.querySelector('app')?.children.length ?? 0,
body,
);

if (process.env.CI) {
expect(prerendered).toBeGreaterThan(0);

Check failure on line 16 in projects/demo-playwright/tests/ssg.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (8 of 8)

[chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal

1) [chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal ──── Error: expect(received).toBeGreaterThan(expected) Expected: > 0 Received: 0 14 | 15 | if (process.env.CI) { > 16 | expect(prerendered).toBeGreaterThan(0); | ^ 17 | } 18 | }); 19 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/ssg.spec.ts:16:33

Check failure on line 16 in projects/demo-playwright/tests/ssg.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (8 of 8)

[chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal

1) [chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal ──── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBeGreaterThan(expected) Expected: > 0 Received: 0 14 | 15 | if (process.env.CI) { > 16 | expect(prerendered).toBeGreaterThan(0); | ^ 17 | } 18 | }); 19 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/ssg.spec.ts:16:33

Check failure on line 16 in projects/demo-playwright/tests/ssg.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (8 of 8)

[chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal

1) [chromium] › tests/ssg.spec.ts:4:9 › SSG › has prerendered components by Angular Universal ──── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBeGreaterThan(expected) Expected: > 0 Received: 0 14 | 15 | if (process.env.CI) { > 16 | expect(prerendered).toBeGreaterThan(0); | ^ 17 | } 18 | }); 19 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/ssg.spec.ts:16:33
}
});
});

0 comments on commit 7e2c5df

Please sign in to comment.