2022-04-04 11:22:00 +05:30
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
2020-07-28 23:09:34 +05:30
|
|
|
import PipelineUrlComponent from '~/pipelines/components/pipelines_list/pipeline_url.vue';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { mockPipeline, mockPipelineBranch, mockPipelineTag } from './mock_data';
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const projectPath = 'test/test';
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('Pipeline Url Component', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
const findTableCell = () => wrapper.findByTestId('pipeline-url-table-cell');
|
|
|
|
const findPipelineUrlLink = () => wrapper.findByTestId('pipeline-url-link');
|
|
|
|
const findRefName = () => wrapper.findByTestId('merge-request-ref');
|
|
|
|
const findCommitShortSha = () => wrapper.findByTestId('commit-short-sha');
|
|
|
|
const findCommitIcon = () => wrapper.findByTestId('commit-icon');
|
|
|
|
const findCommitIconType = () => wrapper.findByTestId('commit-icon-type');
|
|
|
|
|
|
|
|
const findCommitTitleContainer = () => wrapper.findByTestId('commit-title-container');
|
|
|
|
const findCommitTitle = (commitWrapper) => commitWrapper.find('[data-testid="commit-title"]');
|
|
|
|
|
|
|
|
const defaultProps = mockPipeline(projectPath);
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
const createComponent = (props) => {
|
2022-04-04 11:22:00 +05:30
|
|
|
wrapper = shallowMountExtended(PipelineUrlComponent, {
|
2020-07-28 23:09:34 +05:30
|
|
|
propsData: { ...defaultProps, ...props },
|
2021-02-22 17:27:13 +05:30
|
|
|
provide: {
|
2021-04-17 20:07:23 +05:30
|
|
|
targetProjectFullPath: projectPath,
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
2020-07-28 23:09:34 +05:30
|
|
|
wrapper = null;
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it('should render pipeline url table cell', () => {
|
|
|
|
createComponent();
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findTableCell().exists()).toBe(true);
|
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it('should render a link the provided path and id', () => {
|
|
|
|
createComponent();
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findPipelineUrlLink().attributes('href')).toBe('foo');
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findPipelineUrlLink().text()).toBe('#1');
|
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it('should render the commit title, commit reference and commit-short-sha', () => {
|
|
|
|
createComponent({}, true);
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
const commitWrapper = findCommitTitleContainer();
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findCommitTitle(commitWrapper).exists()).toBe(true);
|
|
|
|
expect(findRefName().exists()).toBe(true);
|
|
|
|
expect(findCommitShortSha().exists()).toBe(true);
|
2021-03-11 19:13:27 +05:30
|
|
|
});
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it('should render commit icon tooltip', () => {
|
|
|
|
createComponent({}, true);
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findCommitIcon().attributes('title')).toBe('Commit');
|
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it.each`
|
|
|
|
pipeline | expectedTitle
|
|
|
|
${mockPipelineTag()} | ${'Tag'}
|
|
|
|
${mockPipelineBranch()} | ${'Branch'}
|
|
|
|
${mockPipeline()} | ${'Merge Request'}
|
|
|
|
`('should render tooltip $expectedTitle for commit icon type', ({ pipeline, expectedTitle }) => {
|
|
|
|
createComponent(pipeline, true);
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(findCommitIconType().attributes('title')).toBe(expectedTitle);
|
2021-03-11 19:13:27 +05:30
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|