-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from ember-a11y/drewlee/options
Provide conditional usage for 'setupMiddlewareReporter'
- Loading branch information
Showing
10 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const ENABLE_A11Y_MIDDLEWARE_REPORTER = false; | ||
export const ENABLE_A11Y_AUDIT = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ENABLE_A11Y_MIDDLEWARE_REPORTER } from './cli-options'; | ||
|
||
/** | ||
* Utility to determine whether to use the middleware reporter. This functionality is | ||
* enabled by the presence of the `enableA11yMiddlewareReporter` query parameter passed | ||
* to the test suite or the `ENABLE_A11Y_MIDDLEWARE_REPORTER` environmental variable. | ||
*/ | ||
export function useMiddlewareReporter() { | ||
const url = new URL(window.location.href, document.baseURI); | ||
|
||
return ( | ||
ENABLE_A11Y_MIDDLEWARE_REPORTER || | ||
url.searchParams.get('enableA11yMiddlewareReporter') !== null | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const Filter = require('broccoli-persistent-filter'); | ||
|
||
const enableMiddlewareReporter = | ||
process.env.ENABLE_A11Y_MIDDLEWARE_REPORTER === 'true'; | ||
const enableA11yAudit = process.env.ENABLE_A11Y_AUDIT === 'true'; | ||
|
||
const replacementToken = '$1 true'; | ||
|
||
class CliOptionsFilter extends Filter { | ||
constructor() { | ||
super(...arguments); | ||
} | ||
|
||
/** | ||
* If `ENABLE_A11Y_MIDDLEWARE_REPORTER=true` or `ENABLE_A11Y_AUDIT=true` environmental | ||
* variables are specified, overwrite the corresponding values in `test-support/cli-options` | ||
* at build-time to make them accessible in the browser environment. | ||
* @override | ||
*/ | ||
processString(contents) { | ||
if (enableMiddlewareReporter) { | ||
contents = contents.replace( | ||
/(ENABLE_A11Y_MIDDLEWARE_REPORTER = )false/, | ||
replacementToken | ||
); | ||
} | ||
|
||
if (enableA11yAudit) { | ||
contents = contents.replace( | ||
/(ENABLE_A11Y_AUDIT = )false/, | ||
replacementToken | ||
); | ||
} | ||
|
||
return contents; | ||
} | ||
} | ||
|
||
module.exports = CliOptionsFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters