pagean 8.0.1 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2022 Aaron Goldenthal
3
+ Copyright (c) 2019 - 2023 Aaron Goldenthal
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -118,7 +118,8 @@ The broken link test checks for broken links on the page. It checks any `<a>` ta
118
118
 
119
119
  - For links within the page, this test checks for existence of the element on the page, passing if the element exists and failing otherwise (and passing for cases that are always valid, e.g. `#` or `#top` for the current page). It does not check the visibility of the element. Failing tests return a response of "#element Not Found" (where `#element` identifies the specific element).
120
120
  - For links to other pages, the test tries to most efficiently confirm whether the target link is valid. It first makes a `HEAD` request for that URL and checks the response. If an erroneous response is returned (>= 400 with no execution error) and not code 429 (Too Many Requests), the request is retried with a `GET` request. The test passes for HTTP responses < 400 and fails otherwise (if HTTP response is >= 400 or another error occurs).
121
- - This can result in false failure indications, specifically for `file://` links (`404` or `ECONNREFUSED`) or where the browser passes a domain identity with the request (page loads when tested, but `401` response for links to that page). For these cases, or other false failures, the test configuration allows a boolean `checkWithBrowser` option that will instead check links by loading the target in the browser (via `puppeteer`). Note this can increase test execution time, in some cases substantially, due to the time to open a new browser tab and plus load the page and all assets.
121
+ - This can result in false failure indications, specifically for `file:` links (`404` or `ECONNREFUSED`) or where the browser passes a domain identity with the request (page loads when tested, but `401` response for links to that page). For these cases, or other false failures, the test configuration allows a boolean `checkWithBrowser` option that will instead check links by loading the target in the browser (via `puppeteer`). Note this can increase test execution time, in some cases substantially, due to the time to open a new browser tab and plus load the page and all assets.
122
+ - Note that `file:` links can only be tested with the `checkWithBrowser` option.
122
123
  - If the link to another page includes a hash it is removed prior to checking. The test in this case is confirming a valid link, not that the element exists, which is only done for the current page.
123
124
  - The test configuration allows an `ignoredLinks` array listing link URLs to ignore for this test. Note this only applies to links to other pages, not links within the page, which are always checked.
124
125
  - To optimize performance, link test results are cached and those links are not re-tested for the entire test run (across all tested URLs). The test configuration allows a boolean `ignoreDuplicates` option that can be set to `false` to bypass this behavior and re-test all links. The results for any failed links are included in the reports in any case.
@@ -142,6 +143,8 @@ For any failing test, the `data` array in the test report includes the original
142
143
  ]
143
144
  ```
144
145
 
146
+ Note: This test will check all links on the page, and does not respect mechanisms inteded to limit web crawlers such as `robots.txt` or `noindex` tags.
147
+
145
148
  ## Reports
146
149
 
147
150
  Based on the `reporters` configuration, Pagean results may be displayed in the console and saved in two reports in the project root directory (any or all of the three):
@@ -254,6 +257,10 @@ Provided with the Pagean project are Docker images configured to run the tests.
254
257
 
255
258
  **Note:** Any images in the `gitlab-ci-utils/pagean/tmp` repository are temporary images used during the build process and may be deleted at any point.
256
259
 
260
+ ### Puppeteer Cache Location
261
+
262
+ In [Puppeteer v19](https://github.com/puppeteer/puppeteer/releases/tag/v19.0.0) the default cache location for installing the Chrome binary was changed from within the project's `node_modules` folder to `~/.cache/puppeteer`. To simplify execution in a container, the `PUPPETEER_CACHE_DIR` environment variable is set to install the Chrome binaries in `/home/pptruser/.cache/puppeteer` during container build, so setting to another value before execution can cause errors where Puppeteer cannot find the Chrome binary.
263
+
257
264
  ## GitLab CI Configuration
258
265
 
259
266
  The following is an example job from a .gitlab-ci.yml file to use this image to run Pagean against another project in GitLab CI:
package/index.js CHANGED
@@ -60,7 +60,7 @@ const executeAllTests = async (config) => {
60
60
 
61
61
  if (testResults.summary.failed > 0) {
62
62
  // For test harness want process to exit with error code
63
- // eslint-disable-next-line unicorn/no-process-exit, no-process-exit, no-magic-numbers -- exit code
63
+ // eslint-disable-next-line unicorn/no-process-exit, no-magic-numbers -- exit code
64
64
  process.exit(2);
65
65
  }
66
66
  };
@@ -21,9 +21,13 @@ const externalFilePath = 'pagean-external-scripts';
21
21
  * @static
22
22
  */
23
23
  const shouldSaveFile = (script, page) => {
24
+ const validProtocols = ['http:', 'https:'];
24
25
  const scriptUrl = new URL(script);
25
26
  const pageUrl = new URL(page);
26
- return scriptUrl.host !== pageUrl.host;
27
+ return (
28
+ scriptUrl.host !== pageUrl.host &&
29
+ validProtocols.includes(scriptUrl.protocol)
30
+ );
27
31
  };
28
32
 
29
33
  /**
package/lib/link-utils.js CHANGED
@@ -135,6 +135,10 @@ const checkExternalPageLinkBrowser = async (page, link) => {
135
135
  */
136
136
  // eslint-disable-next-line sonarjs/cognitive-complexity -- Allow less than 10
137
137
  const checkExternalPageLink = async (page, link, useGet = false) => {
138
+ if (link.startsWith('file:')) {
139
+ return 'Cannot check "file:" URLs';
140
+ }
141
+
138
142
  // Get user-agent from page so axios uses the same value for requesting links
139
143
  const userAgent = await page.evaluate('navigator.userAgent');
140
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagean",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Pagean is a web page analysis tool designed to automate tests requiring web pages to be loaded in a browser window (e.g. horizontal scrollbar, console errors)",
5
5
  "bin": {
6
6
  "pagean": "./bin/pagean.js",
@@ -51,28 +51,28 @@
51
51
  },
52
52
  "homepage": "https://gitlab.com/gitlab-ci-utils/pagean",
53
53
  "devDependencies": {
54
- "@aarongoldenthal/eslint-config-standard": "^17.0.1",
55
- "@aarongoldenthal/stylelint-config-standard": "^11.2.1",
54
+ "@aarongoldenthal/eslint-config-standard": "^20.0.0",
55
+ "@aarongoldenthal/stylelint-config-standard": "^12.0.1",
56
56
  "bin-tester": "^3.0.0",
57
- "eslint": "^8.26.0",
58
- "jest": "^29.2.2",
59
- "jest-junit": "^14.0.1",
60
- "markdownlint-cli": "^0.32.2",
61
- "prettier": "^2.7.1",
57
+ "eslint": "^8.33.0",
58
+ "jest": "^29.4.1",
59
+ "jest-junit": "^15.0.0",
60
+ "markdownlint-cli": "^0.33.0",
61
+ "prettier": "^2.8.3",
62
62
  "strip-ansi": "^6.0.1",
63
- "stylelint": "^14.14.1"
63
+ "stylelint": "^14.16.1"
64
64
  },
65
65
  "dependencies": {
66
- "ajv": "^8.11.0",
66
+ "ajv": "^8.12.0",
67
67
  "ajv-errors": "^3.0.0",
68
- "axios": "^1.1.3",
68
+ "axios": "^1.3.1",
69
69
  "ci-logger": "^5.1.0",
70
- "commander": "^9.4.1",
70
+ "commander": "^10.0.0",
71
71
  "handlebars": "^4.7.7",
72
72
  "htmlhint": "^1.1.4",
73
73
  "kleur": "^4.1.5",
74
74
  "normalize-url": "^6.1.0",
75
75
  "protocolify": "^3.0.0",
76
- "puppeteer": "^19.2.2"
76
+ "puppeteer": "^19.6.3"
77
77
  }
78
78
  }