diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/frontend/terraform/components/states_table_spec.js | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/frontend/terraform/components/states_table_spec.js')
-rw-r--r-- | spec/frontend/terraform/components/states_table_spec.js | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/spec/frontend/terraform/components/states_table_spec.js b/spec/frontend/terraform/components/states_table_spec.js index 7a8cb19971e..f2b7bc00e5b 100644 --- a/spec/frontend/terraform/components/states_table_spec.js +++ b/spec/frontend/terraform/components/states_table_spec.js @@ -1,13 +1,14 @@ import { GlIcon, GlTooltip } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import { useFakeDate } from 'helpers/fake_date'; +import StateActions from '~/terraform/components/states_table_actions.vue'; import StatesTable from '~/terraform/components/states_table.vue'; describe('StatesTable', () => { let wrapper; useFakeDate([2020, 10, 15]); - const propsData = { + const defaultProps = { states: [ { name: 'state-1', @@ -37,6 +38,19 @@ describe('StatesTable', () => { createdByUser: { name: 'user-3', }, + job: { + detailedStatus: { + detailsPath: '/job-path-3', + group: 'failed', + icon: 'status_failed', + label: 'failed', + text: 'failed', + }, + pipeline: { + id: 'gid://gitlab/Ci::Pipeline/3', + path: '/pipeline-path-3', + }, + }, }, }, { @@ -47,14 +61,33 @@ describe('StatesTable', () => { latestVersion: { updatedAt: '2020-10-09T00:00:00Z', createdByUser: null, + job: { + detailedStatus: { + detailsPath: '/job-path-4', + group: 'passed', + icon: 'status_success', + label: 'passed', + text: 'passed', + }, + pipeline: { + id: 'gid://gitlab/Ci::Pipeline/4', + path: '/pipeline-path-4', + }, + }, }, }, ], }; - beforeEach(() => { + const createComponent = (propsData = defaultProps) => { wrapper = mount(StatesTable, { propsData }); return wrapper.vm.$nextTick(); + }; + + const findActions = () => wrapper.findAll(StateActions); + + beforeEach(() => { + return createComponent(); }); afterEach(() => { @@ -99,4 +132,38 @@ describe('StatesTable', () => { expect(state.text()).toMatchInterpolatedText(updateTime); }); + + it.each` + pipelineText | toolTipAdded | lineNumber + ${''} | ${false} | ${0} + ${''} | ${false} | ${1} + ${'#3 failed Job status'} | ${true} | ${2} + ${'#4 passed Job status'} | ${true} | ${3} + `( + 'displays the pipeline information for line "$lineNumber"', + ({ pipelineText, toolTipAdded, lineNumber }) => { + const states = wrapper.findAll('[data-testid="terraform-states-table-pipeline"]'); + const state = states.at(lineNumber); + + expect(state.find(GlTooltip).exists()).toBe(toolTipAdded); + expect(state.text()).toMatchInterpolatedText(pipelineText); + }, + ); + + it('displays no actions dropdown', () => { + expect(findActions().length).toEqual(0); + }); + + describe('when user is a terraform administrator', () => { + beforeEach(() => { + return createComponent({ + terraformAdmin: true, + ...defaultProps, + }); + }); + + it('displays an actions dropdown for each state', () => { + expect(findActions().length).toEqual(defaultProps.states.length); + }); + }); }); |