corona-warn-app / cwa-website

Corona-Warn-App website. The CWA development ended on May 31, 2023. You still can warn other users until April 30, 2023. More information:
https://coronawarn.app/en/faq/#ramp_down
Apache License 2.0
522 stars 225 forks source link

New script `test:links` for web hyperlink checking #3411

Closed MikeMcC399 closed 1 year ago

MikeMcC399 commented 1 year ago

This PR adds a new script test:links which runs the cypress/e2e/hybrid/check_links.cy.js test locally.

This makes it easier for a contributor to check external links in the website to be published on https://www.coronawarn.app/ before submitting a PR or after making changes to it.

Other tests can already be run using npm run test:short. The full set of tests can be run using npm test (which is an alias for npm run test).

Due to the dependency of this test on external websites, which may or may not be working correctly when the test is run, and on the run time of approx. 15 - 25 minutes, the workflow check in .github/workflows/test-check_links.yml is not triggered by pull request. Instead it runs once a week or if triggered manually.

To run the test locally, execute:

npm run test:links

(Note, there is another test (npm run checklinks) which checks Markdown files which are published only to https://github.com/corona-warn-app/cwa-website. The name test:links above is aligned to the other Cypress tests.)

I plan to add this to some changed README documentation soon.


Internal Tracking ID: EXPOSUREAPP-14860

MikeMcC399 commented 1 year ago

Log of test run:

$ npm run test:links

> corona-warn-app-landingpage@1.4.0 test:links
> run-s build test:checklinks:phase2

> corona-warn-app-landingpage@1.4.0 build
> gulp build --production

PRODUCTION:  true
[17:23:43] Using gulpfile ~\github\cwa-website\gulpfile.mjs
[17:23:43] Starting 'build'...
[17:23:43] Starting 'clean'...
[17:23:43] Finished 'clean' after 39 ms
[17:23:43] Starting 'cleanBlogs'...
[17:23:43] Finished 'cleanBlogs' after 34 ms
[17:23:43] Starting 'cleanScienceBlogs'...
[17:23:43] Finished 'cleanScienceBlogs' after 3.59 ms
[17:23:43] Starting 'buildBlogFiles'...
[17:23:43] Finished 'buildBlogFiles' after 585 ms
[17:23:43] Starting 'buildScienceBlogFiles'...
[17:23:44] Finished 'buildScienceBlogFiles' after 363 ms
[17:23:44] Starting 'analyseData'...
[17:23:44] Finished 'analyseData' after 698 ms
[17:23:44] Starting 'cwaaJs'...
[17:23:52] asset cwaa.js 824 KiB [emitted] [minimized] [big] (name: cwaa) 2 related assets

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  cwaa.js (824 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  cwaa (824 KiB)
      cwaa.js

WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

webpack 5.75.0 compiled with 3 warnings
[17:23:52] Finished 'cwaaJs' after 7.99 s
[17:23:52] Starting 'javascript'...
[17:24:00] assets by chunk 368 KiB (id hint: vendors)
  asset 120.js 195 KiB [emitted] [minimized] (id hint: vendors) 2 related assets
  asset 392.js 152 KiB [emitted] [minimized] (id hint: vendors) 1 related asset
  asset 856.js 21.2 KiB [emitted] [minimized] (id hint: vendors) 2 related assets
asset eventregistration.js 976 KiB [emitted] [minimized] [big] (name: eventregistration) 2 related assets
asset app.js 229 KiB [emitted] [minimized] (name: app) 2 related assets
asset screenshots.js 90.5 KiB [emitted] [minimized] (name: screenshots) 2 related assets

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  eventregistration.js (976 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  eventregistration (976 KiB)
      eventregistration.js

webpack 5.75.0 compiled with 2 warnings
[17:24:00] Finished 'javascript' after 7.32 s
[17:24:00] Starting 'pages'...
[17:24:00] Starting 'images_minify'...
[17:24:00] Starting 'copy'...
[17:24:00] Starting 'copyFAQs'...
[17:24:00] Starting 'copyFAQRedirects'...
[17:24:00] Starting 'copyFAQsDuplicate'...
[17:24:00] Starting 'copyBlogEntries'...
folder created: ./public/.well-known
[17:24:00] Finished 'copyFAQs' after 580 ms
[17:24:00] Finished 'copyFAQsDuplicate' after 581 ms
[17:24:00] Finished 'copyBlogEntries' after 668 ms
[17:24:01] Finished 'copyFAQRedirects' after 1.48 s
[17:24:03] gulp-imagemin: Minified 18 images (saved 1.05 MB - 35.2%)
[17:24:03] Finished 'images_minify' after 3.54 s
[17:24:04] Finished 'pages' after 3.92 s
[17:24:44] Finished 'copy' after 44 s
[17:24:44] Starting 'images_webp'...
[17:24:56] Finished 'images_webp' after 12 s
[17:24:56] Starting 'sass'...
[17:24:58] Finished 'sass' after 1.86 s
[17:24:58] Starting 'build_sitemap'...
[17:24:58] Finished 'build_sitemap' after 463 ms
[17:24:58] Starting 'createFaqRedirects'...
[17:24:59] Finished 'createFaqRedirects' after 628 ms
[17:24:59] Starting 'replaceVersionNumbers'...
[17:25:00] Finished 'replaceVersionNumbers' after 1.75 s
[17:25:00] Starting 'deleteTmpFiles'...
[17:25:00] Finished 'deleteTmpFiles' after 4.93 ms
[17:25:00] Starting 'AddEnglishSpecifier'...
[17:25:03] Finished 'AddEnglishSpecifier' after 2.67 s
[17:25:03] Finished 'build' after 1.33 min

> corona-warn-app-landingpage@1.4.0 test:checklinks:phase2
> start-server-and-test start-server http://localhost:8000 cypress:run:checklinks

1: starting server using command "npm run start-server"
and when url "[ 'http://localhost:8000' ]" is responding with HTTP status code 200
running tests using command "npm run cypress:run:checklinks"

> corona-warn-app-landingpage@1.4.0 start-server
> gulp start-server

PRODUCTION:  true
[17:25:07] Using gulpfile ~\github\cwa-website\gulpfile.mjs
[17:25:07] Starting 'start-server'...
[17:25:07] Starting 'server'...
[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:8000
    External: http://192.168.202.1:8000
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------
[Browsersync] Serving files from: ./public
[17:25:07] Finished 'server' after 182 ms
[17:25:07] Starting 'watch'...
[17:25:07] Finished 'watch' after 26 ms
[17:25:07] Finished 'start-server' after 211 ms

> corona-warn-app-landingpage@1.4.0 cypress:run:checklinks
> cypress run -s 'cypress/e2e/hybrid/check_links.cy.js' --e2e --browser chrome --headless

Couldn't find tsconfig.json. tsconfig-paths will be skipped

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        10.11.0                                                                        │
  │ Browser:        Chrome 110 (headless)                                                          │
  │ Node Version:   v18.14.1 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          1 found (check_links.cy.js)                                                    │
  │ Searched:       C:\Users\mikem\github\cwa-website\cypress\e2e\hybrid\check_links.cy.js         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  check_links.cy.js                                                               (1 of 1)
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating

  Check for broken links
    √ Check if txt results exist (29ms)
    √ "/de" - Check for broken links (23992ms)
    √ "/en" - Check for broken links (15647ms)
    √ "/de/eventregistration/" - Check for broken links (1955ms)
    √ "/en/eventregistration/" - Check for broken links (1599ms)
    √ "/de/community/" - Check for broken links (2454ms)
    √ "/en/community/" - Check for broken links (2082ms)
    √ "/de/analysis/" - Check for broken links (5439ms)
    √ "/en/analysis/" - Check for broken links (4136ms)
    √ "/de/blog/archiv/" - Check for broken links (30925ms)
    √ "/en/blog/archive/" - Check for broken links (11498ms)
    √ "/de/screenshots/" - Check for broken links (19924ms)
    √ "/en/screenshots/" - Check for broken links (19777ms)
    √ "/de/faq/" - Check for broken links (2148ms)
    √ "/de/faq/results/" - Check for broken links (86145ms)
    √ "/en/faq/" - Check for broken links (2526ms)
    √ "/en/faq/results/" - Check for broken links (77901ms)
    √ "/de/rat-partner/" - Check for broken links (5377ms)
    √ "/en/rat-partner/" - Check for broken links (3527ms)
    √ "/de/privacy/" - Check for broken links (12599ms)
    √ "/en/privacy/" - Check for broken links (12219ms)
    √ "/de/terms-of-use/" - Check for broken links (2237ms)
    √ "/en/terms-of-use/" - Check for broken links (1414ms)
    √ "/de/event-qr-code-guide/" - Check for broken links (1095ms)
    √ "/en/event-qr-code-guide/" - Check for broken links (963ms)
    √ "/de/blog/" - Check for broken links (4163ms)
    √ "/en/blog/" - Check for broken links (3270ms)
    √ "/de/science/" - Check for broken links (1320ms)
    √ "/en/science/" - Check for broken links (1395ms)
    √ "/de/simple-language/" - Check for broken links (2152ms)
    √ "/en/simple-language/" - Check for broken links (880ms)
    √ "/de/sign-language/" - Check for broken links (1555ms)
    √ "/en/sign-language/" - Check for broken links (1278ms)
    √ "/de/sitemap/" - Check for broken links (3265ms)
    √ "/en/sitemap/" - Check for broken links (2844ms)

  Check for broken links on entries
    √ "/de/blog/" entries - Check for broken links (69076ms)
    √ "/en/blog/" entries - Check for broken links (62684ms)
    √ "/de/science/" entries - Check for broken links (54448ms)
    √ "/en/science/" entries - Check for broken links (52761ms)

  39 passing (10m)

  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        39                                                                               │
  │ Passing:      39                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     10 minutes, 8 seconds                                                            │
  │ Spec Ran:     check_links.cy.js                                                                │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

====================================================================================================

  (Run Finished)

       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  check_links.cy.js                        10:08       39       39        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        10:08       39       39        -        -        -
MikeMcC399 commented 1 year ago

All tests are successful! Ready for review.

MikeMcC399 commented 1 year ago

@larswmh

Thank you for cross-checking and merging!

Now that all other tests run automatically, if we move the general documentation for testing from README into a separate document, this manual test npm run test:links is the only test which needs to be described in the README. I am working on new documentation the moment.

MikeMcC399 commented 1 year ago

I ran the test from the updated master branch after the PR merge and it failed when it checked:

https://apps.apple.com/de/app/116117-app/id1465237675

I repeated the test and it was successful, so I will add a troubleshooting section to the new documentation I am writing to give some hints about what to do when the test fails.