From 924f811d9f1de406c8b61650a1e2d1ddb412ed47 Mon Sep 17 00:00:00 2001 From: "Gabor.Ottlik" Date: Wed, 21 Nov 2018 16:53:59 +0000 Subject: [PATCH 1/4] Fix pa11y snaphost creation --- dotfiles/.pa11yci.js | 12 +++++++++--- package.json | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dotfiles/.pa11yci.js b/dotfiles/.pa11yci.js index f566575..4c7ec17 100644 --- a/dotfiles/.pa11yci.js +++ b/dotfiles/.pa11yci.js @@ -1,5 +1,8 @@ const extend = require('node.extend'); const querystring = require('querystring'); +const { URL } = require('url'); +const path = require('path'); +const mkdirp = require('mkdirp'); const defaultViewPortSize = { width: 1280, @@ -152,8 +155,8 @@ for (let viewport of viewports) { const resultUrl = extend(true, {viewport: viewport}, url); if (process.env.TEST_URL.includes('local')) { - - const path = resultUrl.url.substring(resultUrl.url.lastIndexOf('/')); + const pathname = new URL(resultUrl.url).pathname; + const screenshotName = pathname.substring(1).replace(/\//g, '_'); let appFlags = 'no-flags'; @@ -162,7 +165,10 @@ for (let viewport of viewports) { appFlags = flags.substring(0, flags.indexOf(DEFAULT_FLAGS) - 1); } - resultUrl.screenCapture = `./pa11y_screenCapture/${viewport.width}x${viewport.height}/${appFlags}/${path || 'root'}.png`; + const folderName = `/pa11y_screenCapture/${viewport.width}x${viewport.height}-${appFlags}`; + + mkdirp.sync(path.join(process.cwd(), folderName)); + resultUrl.screenCapture = `.${folderName}/${screenshotName || 'root'}.png`; } diff --git a/package.json b/package.json index e50920b..1b296c4 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "husky": "^0.14.3", "jsonfile": "^4.0.0", "lintspaces-cli": "^0.6.0", + "node-mkdirp": "0.0.1", "npm-prepublish": "^1.2.3", "postcss-sass": "^0.2.0", "stylelint": "^8.4.0", From e6bf7dfc6ecf02c9fb9e2658d742e8db5d33c852 Mon Sep 17 00:00:00 2001 From: "Gabor.Ottlik" Date: Wed, 21 Nov 2018 16:55:21 +0000 Subject: [PATCH 2/4] Fix to recognise PA11Y_WAIT --- dotfiles/.pa11yci.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/.pa11yci.js b/dotfiles/.pa11yci.js index 4c7ec17..1601f13 100644 --- a/dotfiles/.pa11yci.js +++ b/dotfiles/.pa11yci.js @@ -51,7 +51,7 @@ const config = { 'FT-Flags': DEFAULT_FLAGS }, timeout: 50000, - wait: 300 || process.env.PA11Y_WAIT, + wait: process.env.PA11Y_WAIT || 300, hideElements: 'iframe[src*=google],iframe[src*=proxy]', rules: ['Principle1.Guideline1_3.1_3_1_AAA'] }, From cfe6c0d31d63466c993ccacf91d473c3301cdc11 Mon Sep 17 00:00:00 2001 From: "Gabor.Ottlik" Date: Thu, 22 Nov 2018 11:19:15 +0000 Subject: [PATCH 3/4] Add Pa11y env variable documentation --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7ff5d41..e6db6a1 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,16 @@ Multiple user types can be specified in the TEST_USER_TYPES variable. If you set `TEST_USER_TYPES` environment variable to `premium,standard`, these variables will be populated in the `.env` file: `PREMIUM_FTSession`, `PREMIUM_FTSession_s`, `STANDARD_FTSession`, `STANDARD_FTSession_s` +### Pa11y environment variables + +| | | +|---|---| +| `PA11Y_WAIT` | The time to wait before running tests in milliseconds | +| `PA11Y_ROUTE_EXCEPTIONS` | api_key for the lambda | +| `PA11Y_ROUTE_HEADERS` | user types to get the tokens for (options: `premium`, `standard`, `expired`) | +| `PA11Y_HIDE` | A CSS selector to hide elements from testing, selectors can be comma separated | +| `PA11Y_VIEWPORTS` | Set viewports for puppeteer (`w1024h768,w375h667`) | + ## Bootstrapping Curious how the bootstrapping bit at top of the `Makefile` works? Here's the annotated code: From 3b8bedaad4be2224cf6ed0c6c545f5bb63907a90 Mon Sep 17 00:00:00 2001 From: "Gabor.Ottlik" Date: Thu, 22 Nov 2018 15:30:07 +0000 Subject: [PATCH 4/4] Change imported package and change route --- dotfiles/.pa11yci.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dotfiles/.pa11yci.js b/dotfiles/.pa11yci.js index 1601f13..f650d22 100644 --- a/dotfiles/.pa11yci.js +++ b/dotfiles/.pa11yci.js @@ -165,7 +165,7 @@ for (let viewport of viewports) { appFlags = flags.substring(0, flags.indexOf(DEFAULT_FLAGS) - 1); } - const folderName = `/pa11y_screenCapture/${viewport.width}x${viewport.height}-${appFlags}`; + const folderName = `/pa11y_screenCapture/${viewport.width}x${viewport.height}/${appFlags}`; mkdirp.sync(path.join(process.cwd(), folderName)); resultUrl.screenCapture = `.${folderName}/${screenshotName || 'root'}.png`; diff --git a/package.json b/package.json index 1b296c4..54794ea 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "husky": "^0.14.3", "jsonfile": "^4.0.0", "lintspaces-cli": "^0.6.0", - "node-mkdirp": "0.0.1", + "mkdirp": "^0.5.1", "npm-prepublish": "^1.2.3", "postcss-sass": "^0.2.0", "stylelint": "^8.4.0",