Files
gnezim 60e2149072 Add comprehensive e2e test suites for Tasks 16-25
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.
2026-04-05 19:25:03 +03:00

149 lines
3.2 KiB
JavaScript

const React = require('react');
const Search = require('./Search');
const Map = require('./Map');
const CurrentLocation = require('./CurrentLocation');
const LocationList = require('./LocationList');
const App = React.createClass({
getInitialState() {
// Extract the favorite locations from local storage
let favorites = [];
if (localStorage.favorites) {
favorites = JSON.parse(localStorage.favorites);
}
// Nobody would get mad if we center it on Paris by default
return {
favorites: favorites,
currentAddress: 'Paris, France',
mapCoordinates: {
lat: 48.856614,
lng: 2.3522219
}
};
},
toggleFavorite(address) {
if (this.isAddressInFavorites(address)) {
this.removeFromFavorites(address);
} else {
this.addToFavorites(address);
}
},
addToFavorites(address) {
const favorites = this.state.favorites;
favorites.push({
address: address,
timestamp: Date.now()
});
this.setState({
favorites: favorites
});
localStorage.favorites = JSON.stringify(favorites);
},
removeFromFavorites(address) {
const favorites = this.state.favorites;
let index = -1;
for (let i = 0; i < favorites.length; i++) {
if (favorites[i].address == address) {
index = i;
break;
}
}
// If it was found, remove it from the favorites array
if (index !== -1) {
favorites.splice(index, 1);
this.setState({
favorites: favorites
});
localStorage.favorites = JSON.stringify(favorites);
}
},
isAddressInFavorites(address) {
const favorites = this.state.favorites;
for (let i = 0; i < favorites.length; i++) {
if (favorites[i].address == address) {
return true;
}
}
return false;
},
searchForAddress(address) {
const self = this;
// We will use GMaps' geocode functionality,
// which is built on top of the Google Maps API
GMaps.geocode({
address: address,
callback: function (results, status) {
if (status !== 'OK') return;
const latlng = results[0].geometry.location;
self.setState({
currentAddress: results[0].formatted_address,
mapCoordinates: {
lat: latlng.lat(),
lng: latlng.lng()
}
});
setTimeout(function () {
console.log('gmapResponded');
}, 1000);
}
});
},
componentDidMount() {
const that = this;
setTimeout(function () {
that.searchForAddress('San Francisco');
}, 2000);
},
render() {
return (
<div>
<h1>Your Google Maps Locations</h1>
<Search onSearch={this.searchForAddress}/>
<Map lat={this.state.mapCoordinates.lat} lng={this.state.mapCoordinates.lng}/>
<CurrentLocation address={this.state.currentAddress}
favorite={this.isAddressInFavorites(this.state.currentAddress)}
onFavoriteToggle={this.toggleFavorite}/>
<LocationList locations={this.state.favorites} activeLocationAddress={this.state.currentAddress}
onClick={this.searchForAddress}/>
</div>
);
}
});
module.exports = App;