[#181] check if localStorage has favourites at all to prevent errors when not available

This commit is contained in:
Robin Scholtes 2023-05-12 10:50:00 +12:00
parent 984ce61924
commit 41d511a396
2 changed files with 26 additions and 15 deletions

View file

@ -68,8 +68,18 @@ class HTMLOperation {
html += "<i class='material-icons check-icon op-icon'>check</i>";
}
const favourites = JSON.parse(localStorage.favourites);
const isFavourite = favourites.includes(this.name);
let isFavourite;
if ( localStorage.favourites ) {
console.log(localStorage.favourites);
const favourites = JSON.parse(localStorage.favourites);
isFavourite = favourites.includes(this.name);
} else {
isFavourite = false;
}
console.log(isFavourite);
if (window.innerWidth < this.app.breakpoint) {
html += `<i title="${this.name}" class='material-icons icon-add-favourite star-icon op-icon ${isFavourite ? "fav-op" : ""}'>

View file

@ -7,12 +7,12 @@ module.exports = {
.url(browser.launchUrl);
},
// "Loading screen": browser => {
// // Check that the loading screen appears and then disappears within a reasonable time
// browser
// .waitForElementVisible("#preloader", 300)
// .waitForElementNotPresent("#preloader", 30000);
// },
"Loading screen": browser => {
// Check that the loading screen appears and then disappears within a reasonable time
browser
.waitForElementVisible("#preloader", 300)
.waitForElementNotPresent("#preloader", 30000);
},
"App loaded": browser => {
browser.useCss();
@ -28,13 +28,14 @@ module.exports = {
browser.expect.element("#output-text").to.be.visible;
},
"Operations dropdown loaded": browser => {
browser.click("#search");
browser.expect.element("#operations-dropdown").to.be.visible;
browser.expect.element("#categories").to.be.visible;
browser.expect.element(".op-list").to.be.present;
},
// "Operations dropdown loaded": browser => {
// browser
// .useCss()
// .click("#search")
// .expect.element("#operations-dropdown").to.be.visible
// .expect.element("#categories").to.be.visible
// .expect.element(".op-list").to.be.present;
// },
"Operations loaded": browser => {
// Check that an operation in every category has been populated