diff options
Diffstat (limited to 'spec/frontend/issuables_list/components')
3 files changed, 47 insertions, 27 deletions
diff --git a/spec/frontend/issuables_list/components/__snapshots__/issuables_list_app_spec.js.snap b/spec/frontend/issuables_list/components/__snapshots__/issuables_list_app_spec.js.snap index 3e445319746..c327b7de827 100644 --- a/spec/frontend/issuables_list/components/__snapshots__/issuables_list_app_spec.js.snap +++ b/spec/frontend/issuables_list/components/__snapshots__/issuables_list_app_spec.js.snap @@ -2,7 +2,6 @@ exports[`Issuables list component with empty issues response with all state should display a catch-all if there are no issues to show 1`] = ` <gl-empty-state-stub - description="The Issue Tracker is the place to add things that need to be improved or solved in a project. You can register or sign in to create issues for this project." svgpath="/emptySvg" title="There are no issues to show" /> diff --git a/spec/frontend/issuables_list/components/issuable_spec.js b/spec/frontend/issuables_list/components/issuable_spec.js index 87868b7eeff..6ede46a602a 100644 --- a/spec/frontend/issuables_list/components/issuable_spec.js +++ b/spec/frontend/issuables_list/components/issuable_spec.js @@ -76,8 +76,9 @@ describe('Issuable component', () => { }); const checkExists = findFn => () => findFn().exists(); - const hasConfidentialIcon = () => - wrapper.findAll(GlIcon).wrappers.some(iconWrapper => iconWrapper.props('name') === 'eye-slash'); + const hasIcon = (iconName, iconWrapper = wrapper) => + iconWrapper.findAll(GlIcon).wrappers.some(icon => icon.props('name') === iconName); + const hasConfidentialIcon = () => hasIcon('eye-slash'); const findTaskStatus = () => wrapper.find('.task-status'); const findOpenedAgoContainer = () => wrapper.find('[data-testid="openedByMessage"]'); const findAuthor = () => wrapper.find({ ref: 'openedAgoByContainer' }); @@ -85,18 +86,20 @@ describe('Issuable component', () => { const findMilestoneTooltip = () => findMilestone().attributes('title'); const findDueDate = () => wrapper.find('.js-due-date'); const findLabels = () => wrapper.findAll(GlLabel); - const findWeight = () => wrapper.find('.js-weight'); + const findWeight = () => wrapper.find('[data-testid="weight"]'); const findAssignees = () => wrapper.find(IssueAssignees); - const findMergeRequestsCount = () => wrapper.find('.js-merge-requests'); - const findUpvotes = () => wrapper.find('.js-upvotes'); - const findDownvotes = () => wrapper.find('.js-downvotes'); - const findNotes = () => wrapper.find('.js-notes'); + const findBlockingIssuesCount = () => wrapper.find('[data-testid="blocking-issues"]'); + const findMergeRequestsCount = () => wrapper.find('[data-testid="merge-requests"]'); + const findUpvotes = () => wrapper.find('[data-testid="upvotes"]'); + const findDownvotes = () => wrapper.find('[data-testid="downvotes"]'); + const findNotes = () => wrapper.find('[data-testid="notes-count"]'); const findBulkCheckbox = () => wrapper.find('input.selected-issuable'); const findScopedLabels = () => findLabels().filter(w => isScopedLabel({ title: w.text() })); const findUnscopedLabels = () => findLabels().filter(w => !isScopedLabel({ title: w.text() })); const findIssuableTitle = () => wrapper.find('[data-testid="issuable-title"]'); const findIssuableStatus = () => wrapper.find('[data-testid="issuable-status"]'); const containsJiraLogo = () => wrapper.contains('[data-testid="jira-logo"]'); + const findHealthStatus = () => wrapper.find('.health-status'); describe('when mounted', () => { it('initializes user popovers', () => { @@ -181,6 +184,7 @@ describe('Issuable component', () => { ${'due date'} | ${checkExists(findDueDate)} ${'labels'} | ${checkExists(findLabels)} ${'weight'} | ${checkExists(findWeight)} + ${'blocking issues count'} | ${checkExists(findBlockingIssuesCount)} ${'merge request count'} | ${checkExists(findMergeRequestsCount)} ${'upvotes'} | ${checkExists(findUpvotes)} ${'downvotes'} | ${checkExists(findDownvotes)} @@ -286,11 +290,7 @@ describe('Issuable component', () => { it('renders milestone', () => { expect(findMilestone().exists()).toBe(true); - expect( - findMilestone() - .find('.fa-clock-o') - .exists(), - ).toBe(true); + expect(hasIcon('clock', findMilestone())).toBe(true); expect(findMilestone().text()).toEqual(TEST_MILESTONE.title); }); @@ -430,11 +430,12 @@ describe('Issuable component', () => { }); describe.each` - desc | key | finder - ${'with merge requests count'} | ${'merge_requests_count'} | ${findMergeRequestsCount} - ${'with upvote count'} | ${'upvotes'} | ${findUpvotes} - ${'with downvote count'} | ${'downvotes'} | ${findDownvotes} - ${'with notes count'} | ${'user_notes_count'} | ${findNotes} + desc | key | finder + ${'with blocking issues count'} | ${'blocking_issues_count'} | ${findBlockingIssuesCount} + ${'with merge requests count'} | ${'merge_requests_count'} | ${findMergeRequestsCount} + ${'with upvote count'} | ${'upvotes'} | ${findUpvotes} + ${'with downvote count'} | ${'downvotes'} | ${findDownvotes} + ${'with notes count'} | ${'user_notes_count'} | ${findNotes} `('$desc', ({ key, finder }) => { beforeEach(() => { issuable[key] = TEST_META_COUNT; @@ -442,7 +443,7 @@ describe('Issuable component', () => { factory({ issuable }); }); - it('renders merge requests count', () => { + it('renders correct count', () => { expect(finder().exists()).toBe(true); expect(finder().text()).toBe(TEST_META_COUNT.toString()); expect(finder().classes('no-comments')).toBe(false); @@ -474,4 +475,19 @@ describe('Issuable component', () => { }); }); }); + + if (IS_EE) { + describe('with health status', () => { + it('renders health status tag', () => { + factory({ issuable }); + expect(findHealthStatus().exists()).toBe(true); + }); + + it('does not render when health status is absent', () => { + issuable.health_status = null; + factory({ issuable }); + expect(findHealthStatus().exists()).toBe(false); + }); + }); + } }); diff --git a/spec/frontend/issuables_list/components/issuables_list_app_spec.js b/spec/frontend/issuables_list/components/issuables_list_app_spec.js index 9f4995a54ee..65b87ddf6a6 100644 --- a/spec/frontend/issuables_list/components/issuables_list_app_spec.js +++ b/spec/frontend/issuables_list/components/issuables_list_app_spec.js @@ -4,14 +4,14 @@ import { shallowMount } from '@vue/test-utils'; import { GlEmptyState, GlPagination, GlSkeletonLoading } from '@gitlab/ui'; import waitForPromises from 'helpers/wait_for_promises'; import { TEST_HOST } from 'helpers/test_constants'; -import flash from '~/flash'; +import { deprecatedCreateFlash as flash } from '~/flash'; import IssuablesListApp from '~/issuables_list/components/issuables_list_app.vue'; import Issuable from '~/issuables_list/components/issuable.vue'; import FilteredSearchBar from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue'; import issueablesEventBus from '~/issuables_list/eventhub'; import { PAGE_SIZE, PAGE_SIZE_MANUAL, RELATIVE_POSITION } from '~/issuables_list/constants'; -jest.mock('~/flash', () => jest.fn()); +jest.mock('~/flash'); jest.mock('~/issuables_list/eventhub'); jest.mock('~/lib/utils/common_utils', () => ({ ...jest.requireActual('~/lib/utils/common_utils'), @@ -21,7 +21,7 @@ jest.mock('~/lib/utils/common_utils', () => ({ const TEST_LOCATION = `${TEST_HOST}/issues`; const TEST_ENDPOINT = '/issues'; const TEST_CREATE_ISSUES_PATH = '/createIssue'; -const TEST_EMPTY_SVG_PATH = '/emptySvg'; +const TEST_SVG_PATH = '/emptySvg'; const setUrl = query => { window.location.href = `${TEST_LOCATION}${query}`; @@ -48,11 +48,15 @@ describe('Issuables list component', () => { }; const factory = (props = { sortKey: 'priority' }) => { + const emptyStateMeta = { + createIssuePath: TEST_CREATE_ISSUES_PATH, + svgPath: TEST_SVG_PATH, + }; + wrapper = shallowMount(IssuablesListApp, { propsData: { endpoint: TEST_ENDPOINT, - createIssuePath: TEST_CREATE_ISSUES_PATH, - emptySvgPath: TEST_EMPTY_SVG_PATH, + emptyStateMeta, ...props, }, }); @@ -117,9 +121,10 @@ describe('Issuables list component', () => { expect(wrapper.vm).toMatchObject({ // Props canBulkEdit: false, - createIssuePath: TEST_CREATE_ISSUES_PATH, - emptySvgPath: TEST_EMPTY_SVG_PATH, - + emptyStateMeta: { + createIssuePath: TEST_CREATE_ISSUES_PATH, + svgPath: TEST_SVG_PATH, + }, // Data filters: { state: 'opened', |