From b9c9069db8533016df2ad7b1110e48fe7dfeb2a2 Mon Sep 17 00:00:00 2001 From: splincode Date: Thu, 25 Jan 2024 15:39:43 +0300 Subject: [PATCH] ci: add prerender e2e asserts --- .cspell.json | 3 ++- .github/workflows/e2e.yml | 2 +- .github/workflows/snapshots.yml | 25 ++++++---------------- projects/demo-playwright/tests/ssg.spec.ts | 19 ++++++++++++++++ 4 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 projects/demo-playwright/tests/ssg.spec.ts diff --git a/.cspell.json b/.cspell.json index c64489db6c77..6cfa955bd98f 100644 --- a/.cspell.json +++ b/.cspell.json @@ -44,7 +44,8 @@ "contenttop", "contentbottom", "requestfailed", - "requestfinished" + "requestfinished", + "prerendered" ], "ignoreRegExpList": ["\\(https?://.*?\\)", "\\/{1}.+\\/{1}", "\\%2F.+", "\\%2C.+", "\\ɵ.+", "\\ыва.+"], "overrides": [ diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c09076a685f8..12c2017027e6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -17,7 +17,7 @@ jobs: - uses: taiga-family/ci/actions/setup/node@v1.50.8 - 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/save@v4.0.0 diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml index 8d5e921cbc56..e6b70b5c0780 100644 --- a/.github/workflows/snapshots.yml +++ b/.github/workflows/snapshots.yml @@ -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/checkout@v1.50.8 - uses: taiga-family/ci/actions/setup/variables@v1.50.8 - uses: taiga-family/ci/actions/setup/node@v1.50.8 - - 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/git-publish-subdir-action@v2.6.0 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/checkout@v1.50.8 - - uses: taiga-family/ci/actions/setup/variables@v1.50.8 - - uses: taiga-family/ci/actions/setup/node@v1.50.8 - 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/git-publish-subdir-action@v2.6.0 env: REPO: self diff --git a/projects/demo-playwright/tests/ssg.spec.ts b/projects/demo-playwright/tests/ssg.spec.ts new file mode 100644 index 000000000000..ac559ad70565 --- /dev/null +++ b/projects/demo-playwright/tests/ssg.spec.ts @@ -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); + } + }); +});