From 03cc6ced4f4ec013f755aa8d053924049a3ee0cf Mon Sep 17 00:00:00 2001 From: mwritter Date: Thu, 14 Jul 2022 10:18:58 -0400 Subject: [PATCH] Fixed tests --- .../karma/exploreTemplates.karma.js | 7 ++++--- .../templateDetails/karma/templateDetails.karma.js | 9 +++++---- .../app/views/myStories/karma/myStories.karma.js | 8 +++++--- packages/dashboard/src/karma/apiProviderFixture.js | 14 +++++++++++--- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/packages/dashboard/src/app/views/exploreTemplates/karma/exploreTemplates.karma.js b/packages/dashboard/src/app/views/exploreTemplates/karma/exploreTemplates.karma.js index 9f6c551f9fa8..a00887c5cba6 100644 --- a/packages/dashboard/src/app/views/exploreTemplates/karma/exploreTemplates.karma.js +++ b/packages/dashboard/src/app/views/exploreTemplates/karma/exploreTemplates.karma.js @@ -41,9 +41,10 @@ describe('Grid view', () => { }); function navigateToExploreTemplates() { - const exploreTemplatesMenuItem = fixture.screen.queryByRole('link', { - name: /^Explore Templates/, - }); + const navigation = fixture.screen.queryByRole('navigation'); + const utils = within(navigation); + + const exploreTemplatesMenuItem = utils.getByText(/^Explore Templates/); return fixture.events.click(exploreTemplatesMenuItem); } diff --git a/packages/dashboard/src/app/views/exploreTemplates/modal/templateDetails/karma/templateDetails.karma.js b/packages/dashboard/src/app/views/exploreTemplates/modal/templateDetails/karma/templateDetails.karma.js index ce61446b8cba..87be4abb6dbc 100644 --- a/packages/dashboard/src/app/views/exploreTemplates/modal/templateDetails/karma/templateDetails.karma.js +++ b/packages/dashboard/src/app/views/exploreTemplates/modal/templateDetails/karma/templateDetails.karma.js @@ -41,9 +41,10 @@ describe('See template details modal', () => { }); async function navigateToFirstTemplate() { - const exploreTemplatesMenuItem = fixture.screen.queryByRole('link', { - name: /^Explore Templates/, - }); + const navigation = fixture.screen.queryByRole('navigation'); + let utils = within(navigation); + + const exploreTemplatesMenuItem = utils.getByText(/^Explore Templates/); await fixture.events.click(exploreTemplatesMenuItem); @@ -51,7 +52,7 @@ describe('See template details modal', () => { const firstTemplate = getTemplateElementById(templatesOrderById[0]); - const utils = within(firstTemplate); + utils = within(firstTemplate); await fixture.events.hover(firstTemplate); diff --git a/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js b/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js index dcd8c4787651..d09d423bfdf0 100644 --- a/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js +++ b/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js @@ -118,9 +118,11 @@ describe('CUJ: Creator can view their stories in grid view', () => { }); it('should navigate to Explore Templates', async () => { - const exploreTemplatesMenuItem = fixture.screen.queryByRole('link', { - name: /^Explore Templates/, - }); + const navigation = fixture.screen.queryByRole('navigation'); + const utils = within(navigation); + + const exploreTemplatesMenuItem = utils.getByText(/^Explore Templates/); + expect(exploreTemplatesMenuItem).toBeTruthy(); await fixture.events.click(exploreTemplatesMenuItem); diff --git a/packages/dashboard/src/karma/apiProviderFixture.js b/packages/dashboard/src/karma/apiProviderFixture.js index 63ae68a37529..923c4655c4a7 100644 --- a/packages/dashboard/src/karma/apiProviderFixture.js +++ b/packages/dashboard/src/karma/apiProviderFixture.js @@ -31,7 +31,7 @@ import formattedStoriesArray from '../dataUtils/formattedStoriesArray'; import formattedTaxonomiesArray from '../dataUtils/formattedTaxonomiesArray'; import formattedTaxonomyTermsObject from '../dataUtils/formattedTaxonomyTermsObject'; import formattedTemplatesArray from '../dataUtils/formattedTemplatesArray'; -import { STORY_SORT_OPTIONS } from '../constants/stories'; +import { STORY_SORT_OPTIONS, DEFAULT_FILTERS } from '../constants/stories'; import { groupTemplatesByTag } from '../testUtils'; /* eslint-disable jasmine/no-unsafe-spy */ @@ -145,8 +145,16 @@ function getStoriesState() { function fetchStories({ sort, filters }, currentState) { const storiesState = currentState ? { ...currentState } : getStoriesState(); - const { author, web_story_category, search = '', status } = filters; - const { orderby, order } = sort; + const { + author, + web_story_category, + search = '', + status = DEFAULT_FILTERS.filters.status, + } = filters; + const { + orderby = DEFAULT_FILTERS.sort.orderby, + order = DEFAULT_FILTERS.sort.order, + } = sort; const statuses = status.split(','); storiesState.storiesOrderById = Object.values(storiesState.stories)