60e2149072
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date) - Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class - Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting - Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states - Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions - Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares) - Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline - Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements - Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations - Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary - Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds All tests follow AAA pattern and use data-testid selectors matching Angular version. Total: 245 tests across 10 feature suites.
104 lines
3.8 KiB
JavaScript
104 lines
3.8 KiB
JavaScript
'use strict';
|
|
module.exports = (target) => {
|
|
return target.evaluate(() => {
|
|
if (window._backstopTools) {
|
|
return false;
|
|
}
|
|
|
|
window._backstopTools = {
|
|
hasLogged: function (str) {
|
|
return new RegExp(str).test(window._backstopTools._consoleLogger);
|
|
},
|
|
startConsoleLogger: function () {
|
|
if (typeof window._backstopTools._consoleLogger !== 'string') {
|
|
window._backstopTools._consoleLogger = '';
|
|
}
|
|
const log = window.console.log.bind(console);
|
|
window.console.log = function () {
|
|
window._backstopTools._consoleLogger += Array.from(arguments).join('\n');
|
|
log.apply(this, arguments);
|
|
};
|
|
},
|
|
/**
|
|
* Take an array of selector names and return and array of *all* matching selectors.
|
|
* For each selector name, If more than 1 selector is matched, proceeding matches are
|
|
* tagged with an additional `__n` class.
|
|
*
|
|
* @return {[string]} [array of expanded selectors]
|
|
* @param selectors
|
|
*/
|
|
expandSelectors: function (selectors) {
|
|
if (!Array.isArray(selectors)) {
|
|
selectors = selectors.split(',');
|
|
}
|
|
return selectors.reduce(function (acc, selector) {
|
|
if (selector === 'body' || selector === 'viewport') {
|
|
return acc.concat([selector]);
|
|
}
|
|
if (selector === 'document') {
|
|
return acc.concat(['document']);
|
|
}
|
|
const qResult = document.querySelectorAll(selector);
|
|
|
|
// pass-through any selectors that don't match any DOM elements
|
|
if (!qResult.length) {
|
|
return acc.concat(selector);
|
|
}
|
|
|
|
const expandedSelector = [].slice.call(qResult)
|
|
.map(function (element, expandedIndex) {
|
|
if (element.classList.contains('__86d')) {
|
|
return '';
|
|
}
|
|
if (!expandedIndex) {
|
|
// only first element is used for screenshots -- even if multiple instances exist.
|
|
// therefore index 0 does not need extended qualification.
|
|
return selector;
|
|
}
|
|
// create index partial
|
|
const indexPartial = '__n' + expandedIndex;
|
|
// update all matching selectors with additional indexPartial class
|
|
element.classList.add(indexPartial);
|
|
// return array of fully-qualified classnames
|
|
return selector + '.' + indexPartial;
|
|
});
|
|
// concat arrays of fully-qualified classnames
|
|
return acc.concat(expandedSelector);
|
|
}, []).filter(function (selector) {
|
|
return selector !== '';
|
|
});
|
|
},
|
|
/**
|
|
* is the selector element visible?
|
|
* @param {[type]} selector [a css selector str]
|
|
* @return {Boolean} [is it visible? true or false]
|
|
*/
|
|
isVisible: function (selector) {
|
|
if (selector === 'body' || selector === 'document' || selector === 'viewport') {
|
|
return true;
|
|
} else if (window._backstopTools.exists(selector)) {
|
|
const element = document.querySelector(selector);
|
|
const style = window.getComputedStyle(element);
|
|
return (style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0');
|
|
}
|
|
return false;
|
|
},
|
|
/**
|
|
* does the selector element exist?
|
|
* @param {[type]} selector [a css selector str]
|
|
* @return {[type]} [returns count of found matches -- 0 for no matches]
|
|
*/
|
|
exists: function (selector) {
|
|
if (selector === 'body' || selector === 'document' || selector === 'viewport') {
|
|
return 1;
|
|
}
|
|
return document.querySelectorAll(selector).length;
|
|
}
|
|
};
|
|
|
|
window._backstopTools.startConsoleLogger();
|
|
console.info('BackstopTools have been installed.');
|
|
return true;
|
|
});
|
|
};
|