Skip to content

Commit

Permalink
Rename config.js to configDesktop.js and fix linting errors
Browse files Browse the repository at this point in the history
* Rename config.js to follow the conventions set by other configs.
* Revises reference and screenshot desktop folder names as well
* Edit tsconfig to check all config files
* Fix configEcho linting errors as a result of the preceding point
* Change configMobile test-screenshot-location to `test-screenshots-mobile` to
	follow conventions
  • Loading branch information
Nick Ray committed Jun 10, 2022
1 parent b6091ea commit 9760be6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config.js → configDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ module.exports = {
scenarios,
paths: {
// eslint-disable-next-line camelcase
bitmaps_reference: 'report/reference-screenshots',
bitmaps_reference: 'report/reference-screenshots-desktop',
// eslint-disable-next-line camelcase
bitmaps_test: 'report/test-screenshots',
bitmaps_test: 'report/test-screenshots-desktop',
// eslint-disable-next-line camelcase
engine_scripts: 'src/engine-scripts',
// eslint-disable-next-line camelcase
Expand Down
30 changes: 21 additions & 9 deletions configEcho.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
const config = require( './config.js' );
const configDesktop = require( './configDesktop.js' );

const BASE_URL = process.env.MW_SERVER;

/**
* @typedef {Object} BaseScenario
* @property {string} label
* @property {string} path
* @property {string[]} hashtags
*/

/**
* @callback BaseScenarioCallback
* @param {BaseScenario} baseScenario
*/

/**
* Be careful when expanding the list of tests here.
* Each scenario represents 8 scenarios:
* - Vector skin (mobile + tablet + desktop + desktop wide)
* - Vector 2022 skin (mobile + tablet + desktop + desktop wide)
* - Minerva skin (mobile + tablet + desktop + desktop wide)
*/
const baseScenarios = [
const baseScenarios = /** @type {BaseScenario[]} */ ( [
{
label: 'Echo smoke test with 0 notifications',
path: '/wiki/Test',
Expand Down Expand Up @@ -39,15 +51,15 @@ const baseScenarios = [
path: '/wiki/Test',
hashtags: [ '#echo-drawer' ]
}
];
] );

/**
* Creates a list of tests with the given query string and hashtags.
*
* @param {Array} hashtags additional hashtags
* @param {string[]} hashtags additional hashtags
* @param {string} queryString to add to URL.
* @param {Object} additionalConfig
* @return {Array} of scenarios.
* @return {BaseScenarioCallback} of scenarios.
*/
const makeScenarios = ( hashtags, queryString, additionalConfig = {} ) => {
return ( test ) => {
Expand All @@ -66,8 +78,8 @@ const makeScenarios = ( hashtags, queryString, additionalConfig = {} ) => {
/**
* Expands the list of tests so there is one for mobile and one for desktop.
*
* @param {Array} tests
* @return {Array}
* @param {BaseScenario[]} tests
* @return {import("backstopjs").Scenario[]}
*/
const makeMobileAndDesktopScenarios = ( tests ) => {
return tests.map(
Expand Down Expand Up @@ -101,9 +113,9 @@ const makeMobileAndDesktopScenarios = ( tests ) => {

const scenarios = makeMobileAndDesktopScenarios( baseScenarios );

module.exports = Object.assign( {}, config, {
module.exports = Object.assign( {}, configDesktop, {
scenarios,
paths: Object.assign( {}, config.paths, {
paths: Object.assign( {}, configDesktop.paths, {
// eslint-disable-next-line camelcase
bitmaps_reference: 'report/reference-screenshots-echo',
// eslint-disable-next-line camelcase
Expand Down
8 changes: 4 additions & 4 deletions configMobile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = require( './config.js' );
const configDesktop = require( './configDesktop.js' );

const BASE_URL = process.env.MW_SERVER;
const tests = [
Expand Down Expand Up @@ -32,13 +32,13 @@ const scenarios = tests.map( ( test ) => {
} );
} );

module.exports = Object.assign( {}, config, {
module.exports = Object.assign( {}, configDesktop, {
scenarios,
paths: Object.assign( {}, config.paths, {
paths: Object.assign( {}, configDesktop.paths, {
// eslint-disable-next-line camelcase
bitmaps_reference: 'report/reference-screenshots-mobile',
// eslint-disable-next-line camelcase
bitmaps_test: 'report/test-screenshots',
bitmaps_test: 'report/test-screenshots-mobile',
// eslint-disable-next-line camelcase
html_report: 'report/mobile'
} )
Expand Down
2 changes: 1 addition & 1 deletion pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const getGroupConfig = ( groupName ) => {
case 'echo':
return 'configEcho.js';
case 'desktop':
return 'config.js';
return 'configDesktop.js';
case 'mobile':
return 'configMobile.js';
default:
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": [
"src",
"config.js"
"config*.js"
],
"exclude": [
"src/engine-scripts",
Expand Down

0 comments on commit 9760be6

Please sign in to comment.