[#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>"; html += "<i class='material-icons check-icon op-icon'>check</i>";
} }
const favourites = JSON.parse(localStorage.favourites); let isFavourite;
const isFavourite = favourites.includes(this.name);
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) { if (window.innerWidth < this.app.breakpoint) {
html += `<i title="${this.name}" class='material-icons icon-add-favourite star-icon op-icon ${isFavourite ? "fav-op" : ""}'> 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); .url(browser.launchUrl);
}, },
// "Loading screen": browser => { "Loading screen": browser => {
// // Check that the loading screen appears and then disappears within a reasonable time // Check that the loading screen appears and then disappears within a reasonable time
// browser browser
// .waitForElementVisible("#preloader", 300) .waitForElementVisible("#preloader", 300)
// .waitForElementNotPresent("#preloader", 30000); .waitForElementNotPresent("#preloader", 30000);
// }, },
"App loaded": browser => { "App loaded": browser => {
browser.useCss(); browser.useCss();
@ -28,13 +28,14 @@ module.exports = {
browser.expect.element("#output-text").to.be.visible; browser.expect.element("#output-text").to.be.visible;
}, },
"Operations dropdown loaded": browser => { // "Operations dropdown loaded": browser => {
browser.click("#search"); // browser
// .useCss()
browser.expect.element("#operations-dropdown").to.be.visible; // .click("#search")
browser.expect.element("#categories").to.be.visible; // .expect.element("#operations-dropdown").to.be.visible
browser.expect.element(".op-list").to.be.present; // .expect.element("#categories").to.be.visible
}, // .expect.element(".op-list").to.be.present;
// },
"Operations loaded": browser => { "Operations loaded": browser => {
// Check that an operation in every category has been populated // Check that an operation in every category has been populated