From 3d3155fce82c8dce2200e1ae83af36c9e591226c Mon Sep 17 00:00:00 2001 From: pyphilia Date: Thu, 8 Sep 2022 16:33:36 +0200 Subject: [PATCH 1/2] fix: fix undefined favorite item list --- src/utils/member.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/member.js b/src/utils/member.js index 5316447fa..514a15949 100644 --- a/src/utils/member.js +++ b/src/utils/member.js @@ -1,4 +1,5 @@ import { validate } from 'uuid'; +import { List } from 'immutable'; export const isMemberIdValid = (memberId) => validate(memberId?.trim()); @@ -7,4 +8,4 @@ export const getMemberById = (members, id) => export const getMemberAvatar = (extra) => extra?.avatar; -export const getFavoriteItems = (extra) => extra?.favoriteItems; +export const getFavoriteItems = (extra) => extra?.favoriteItems || List(); From a56e86da0c2d42b6a02a53aa88f6d242d8d46d3e Mon Sep 17 00:00:00 2001 From: pyphilia Date: Thu, 8 Sep 2022 16:57:27 +0200 Subject: [PATCH 2/2] refactor: add test for empty favorite items --- .../integration/item/favorite/favoriteItem.spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cypress/integration/item/favorite/favoriteItem.spec.js b/cypress/integration/item/favorite/favoriteItem.spec.js index 294190a97..f8f59f571 100644 --- a/cypress/integration/item/favorite/favoriteItem.spec.js +++ b/cypress/integration/item/favorite/favoriteItem.spec.js @@ -7,6 +7,7 @@ import { buildItemMenuButtonId, buildItemMenu, NAVIGATION_ROOT_ID, + FAVORITE_ITEMS_ID, } from '../../../../src/config/selectors'; import { buildMemberWithFavorites, @@ -25,6 +26,19 @@ const toggleFavoriteButton = (itemId) => { const favoriteItems = [SAMPLE_ITEMS.items[1].id, SAMPLE_ITEMS.items[2].id]; describe('Favorite Item', () => { + describe('Member has no favorite items', () => { + beforeEach(() => { + cy.setUpApi({ + ...SAMPLE_ITEMS, + }); + cy.visit(FAVORITE_ITEMS_PATH); + }); + + it('Show empty table', () => { + cy.get(`#${FAVORITE_ITEMS_ID}`).should('exist'); + }); + }); + describe('Member has several valid favorite items', () => { beforeEach(() => { cy.setUpApi({