Commit 9459303b authored by Mike Greiling's avatar Mike Greiling

Merge branch '33270-fix-jest-failing-in-foss' into 'master'

Replace snapshot testing with regular assertions

Closes #33270

See merge request gitlab-org/gitlab!18037
parents cf8ba6b1 793cafe3
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Commit pipeline status component when polling is not successful renders not found CI icon without loader 1`] = `
<div
class="ci-status-link"
>
<a>
<ciicon-stub
aria-label="Pipeline: not found"
cssclasses=""
data-container="body"
data-original-title="Pipeline: not found"
size="24"
status="[object Object]"
title=""
/>
</a>
</div>
`;
exports[`Commit pipeline status component when polling is successful renders CI icon without loader 1`] = `
<div
class="ci-status-link"
>
<a
href="/frontend-fixtures/pipelines-project/pipelines/47"
>
<ciicon-stub
aria-label="Pipeline: pending"
cssclasses=""
data-container="body"
data-original-title="Pipeline: pending"
size="24"
status="[object Object]"
title=""
/>
</a>
</div>
`;
...@@ -2,6 +2,7 @@ import Visibility from 'visibilityjs'; ...@@ -2,6 +2,7 @@ import Visibility from 'visibilityjs';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
import flash from '~/flash'; import flash from '~/flash';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue'; import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { getJSONFixture } from '../helpers/fixtures'; import { getJSONFixture } from '../helpers/fixtures';
...@@ -36,6 +37,10 @@ describe('Commit pipeline status component', () => { ...@@ -36,6 +37,10 @@ describe('Commit pipeline status component', () => {
}); });
}; };
const findLoader = () => wrapper.find(GlLoadingIcon);
const findLink = () => wrapper.find('a');
const findCiIcon = () => findLink().find(CiIcon);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null; wrapper = null;
...@@ -111,14 +116,14 @@ describe('Commit pipeline status component', () => { ...@@ -111,14 +116,14 @@ describe('Commit pipeline status component', () => {
it('shows the loading icon at start', () => { it('shows the loading icon at start', () => {
createComponent(); createComponent();
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); expect(findLoader().exists()).toBe(true);
pollConfig.successCallback({ pollConfig.successCallback({
data: { pipelines: [] }, data: { pipelines: [] },
}); });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(findLoader().exists()).toBe(false);
}); });
}); });
...@@ -130,8 +135,17 @@ describe('Commit pipeline status component', () => { ...@@ -130,8 +135,17 @@ describe('Commit pipeline status component', () => {
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}); });
it('renders CI icon without loader', () => { it('does not render loader', () => {
expect(wrapper.element).toMatchSnapshot(); expect(findLoader().exists()).toBe(false);
});
it('renders link with href', () => {
expect(findLink().attributes('href')).toEqual(mockCiStatus.details_path);
});
it('renders CI icon', () => {
expect(findCiIcon().attributes('data-original-title')).toEqual('Pipeline: pending');
expect(findCiIcon().props('status')).toEqual(mockCiStatus);
}); });
}); });
...@@ -140,8 +154,21 @@ describe('Commit pipeline status component', () => { ...@@ -140,8 +154,21 @@ describe('Commit pipeline status component', () => {
pollConfig.errorCallback(); pollConfig.errorCallback();
}); });
it('renders not found CI icon without loader', () => { it('does not render loader', () => {
expect(wrapper.element).toMatchSnapshot(); expect(findLoader().exists()).toBe(false);
});
it('renders link with href', () => {
expect(findLink().attributes('href')).toBeUndefined();
});
it('renders not found CI icon', () => {
expect(findCiIcon().attributes('data-original-title')).toEqual('Pipeline: not found');
expect(findCiIcon().props('status')).toEqual({
text: 'not found',
icon: 'status_notfound',
group: 'notfound',
});
}); });
it('displays flash error message', () => { it('displays flash error message', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment