Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwritter committed Jul 14, 2022
1 parent acedfe1 commit 03cc6ce
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ 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);

const { templatesOrderById } = await getTemplatesState();

const firstTemplate = getTemplateElementById(templatesOrderById[0]);

const utils = within(firstTemplate);
utils = within(firstTemplate);

await fixture.events.hover(firstTemplate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions packages/dashboard/src/karma/apiProviderFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 03cc6ce

Please sign in to comment.