diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-16 03:09:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-16 03:09:09 +0300 |
commit | 72179bac11e9c18ea623e30594d6d427ef63db36 (patch) | |
tree | 601bc4fbb0a6c30ac866f11f278d80f920440c11 /spec/frontend/pipelines | |
parent | 9922389a501dfde79037426fa6d09144ee5f7e1a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines')
-rw-r--r-- | spec/frontend/pipelines/pipelines_table_row_spec.js | 239 | ||||
-rw-r--r-- | spec/frontend/pipelines/pipelines_table_spec.js | 56 |
2 files changed, 5 insertions, 290 deletions
diff --git a/spec/frontend/pipelines/pipelines_table_row_spec.js b/spec/frontend/pipelines/pipelines_table_row_spec.js deleted file mode 100644 index 68d46575081..00000000000 --- a/spec/frontend/pipelines/pipelines_table_row_spec.js +++ /dev/null @@ -1,239 +0,0 @@ -import { mount } from '@vue/test-utils'; -import waitForPromises from 'helpers/wait_for_promises'; -import PipelinesTableRowComponent from '~/pipelines/components/pipelines_list/pipelines_table_row.vue'; -import eventHub from '~/pipelines/event_hub'; - -describe('Pipelines Table Row', () => { - const jsonFixtureName = 'pipelines/pipelines.json'; - - const createWrapper = (pipeline) => - mount(PipelinesTableRowComponent, { - propsData: { - pipeline, - viewType: 'root', - }, - }); - - let wrapper; - let pipeline; - let pipelineWithoutAuthor; - let pipelineWithoutCommit; - - beforeEach(() => { - const { pipelines } = getJSONFixture(jsonFixtureName); - - pipeline = pipelines.find((p) => p.user !== null && p.commit !== null); - pipelineWithoutAuthor = pipelines.find((p) => p.user === null && p.commit !== null); - pipelineWithoutCommit = pipelines.find((p) => p.user === null && p.commit === null); - }); - - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - - it('should render a table row', () => { - wrapper = createWrapper(pipeline); - - expect(wrapper.attributes('class')).toContain('gl-responsive-table-row'); - }); - - describe('status column', () => { - beforeEach(() => { - wrapper = createWrapper(pipeline); - }); - - it('should render a pipeline link', () => { - expect(wrapper.find('.table-section.commit-link a').attributes('href')).toEqual( - pipeline.path, - ); - }); - - it('should render status text', () => { - expect(wrapper.find('.table-section.commit-link a').text()).toContain( - pipeline.details.status.text, - ); - }); - }); - - describe('information column', () => { - beforeEach(() => { - wrapper = createWrapper(pipeline); - }); - - it('should render a pipeline link', () => { - expect(wrapper.find('.table-section:nth-child(2) a').attributes('href')).toEqual( - pipeline.path, - ); - }); - - it('should render pipeline ID', () => { - expect(wrapper.find('.table-section:nth-child(2) a > span').text()).toEqual( - `#${pipeline.id}`, - ); - }); - - describe('when a user is provided', () => { - it('should render user information', () => { - expect( - wrapper.find('.table-section:nth-child(3) .js-pipeline-url-user').attributes('href'), - ).toEqual(pipeline.user.path); - - expect( - wrapper.find('.table-section:nth-child(3) .js-user-avatar-image-tooltip').text().trim(), - ).toEqual(pipeline.user.name); - }); - }); - }); - - describe('commit column', () => { - it('should render link to commit', () => { - wrapper = createWrapper(pipeline); - - const commitLink = wrapper.find('.branch-commit .commit-sha'); - - expect(commitLink.attributes('href')).toEqual(pipeline.commit.commit_path); - }); - - const findElements = () => { - const commitTitleElement = wrapper.find('.branch-commit .commit-title'); - const commitAuthorElement = commitTitleElement.find('a.avatar-image-container'); - - if (!commitAuthorElement.exists()) { - return { - commitAuthorElement, - }; - } - - const commitAuthorLink = commitAuthorElement.attributes('href'); - const commitAuthorName = commitAuthorElement - .find('.js-user-avatar-image-tooltip') - .text() - .trim(); - - return { - commitAuthorElement, - commitAuthorLink, - commitAuthorName, - }; - }; - - it('renders nothing without commit', () => { - expect(pipelineWithoutCommit.commit).toBe(null); - - wrapper = createWrapper(pipelineWithoutCommit); - const { commitAuthorElement } = findElements(); - - expect(commitAuthorElement.exists()).toBe(false); - }); - - it('renders commit author', () => { - wrapper = createWrapper(pipeline); - const { commitAuthorLink, commitAuthorName } = findElements(); - - expect(commitAuthorLink).toEqual(pipeline.commit.author.path); - expect(commitAuthorName).toEqual(pipeline.commit.author.username); - }); - - it('renders commit with unregistered author', () => { - expect(pipelineWithoutAuthor.commit.author).toBe(null); - - wrapper = createWrapper(pipelineWithoutAuthor); - const { commitAuthorLink, commitAuthorName } = findElements(); - - expect(commitAuthorLink).toEqual(`mailto:${pipelineWithoutAuthor.commit.author_email}`); - expect(commitAuthorName).toEqual(pipelineWithoutAuthor.commit.author_name); - }); - }); - - describe('stages column', () => { - const findAllMiniPipelineStages = () => - wrapper.findAll('.table-section:nth-child(5) [data-testid="mini-pipeline-graph-dropdown"]'); - - it('should render an icon for each stage', () => { - wrapper = createWrapper(pipeline); - - expect(findAllMiniPipelineStages()).toHaveLength(pipeline.details.stages.length); - }); - - it('should not render stages when stages are empty', () => { - const withoutStages = { ...pipeline }; - withoutStages.details = { ...withoutStages.details, stages: null }; - - wrapper = createWrapper(withoutStages); - - expect(findAllMiniPipelineStages()).toHaveLength(0); - }); - }); - - describe('actions column', () => { - const scheduledJobAction = { - name: 'some scheduled job', - }; - - beforeEach(() => { - const withActions = { ...pipeline }; - withActions.details.scheduled_actions = [scheduledJobAction]; - withActions.flags.cancelable = true; - withActions.flags.retryable = true; - withActions.cancel_path = '/cancel'; - withActions.retry_path = '/retry'; - - wrapper = createWrapper(withActions); - }); - - it('should render the provided actions', () => { - expect(wrapper.find('.js-pipelines-retry-button').exists()).toBe(true); - expect(wrapper.find('.js-pipelines-retry-button').attributes('title')).toMatch('Retry'); - expect(wrapper.find('.js-pipelines-cancel-button').exists()).toBe(true); - expect(wrapper.find('.js-pipelines-cancel-button').attributes('title')).toMatch('Cancel'); - }); - - it('should render the manual actions', async () => { - const manualActions = wrapper.find('[data-testid="pipelines-manual-actions-dropdown"]'); - - // Click on the dropdown and wait for `lazy` dropdown items - manualActions.find('.dropdown-toggle').trigger('click'); - await waitForPromises(); - - expect(manualActions.text()).toContain(scheduledJobAction.name); - }); - - it('emits `retryPipeline` event when retry button is clicked and toggles loading', () => { - eventHub.$on('retryPipeline', (endpoint) => { - expect(endpoint).toBe('/retry'); - }); - - wrapper.find('.js-pipelines-retry-button').trigger('click'); - expect(wrapper.vm.isRetrying).toBe(true); - }); - - it('emits `openConfirmationModal` event when cancel button is clicked and toggles loading', () => { - eventHub.$once('openConfirmationModal', (data) => { - const { id, ref, commit } = pipeline; - - expect(data.endpoint).toBe('/cancel'); - expect(data.pipeline).toEqual( - expect.objectContaining({ - id, - ref, - commit, - }), - ); - }); - - wrapper.find('.js-pipelines-cancel-button').trigger('click'); - }); - - it('renders a loading icon when `cancelingPipeline` matches pipeline id', (done) => { - wrapper.setProps({ cancelingPipeline: pipeline.id }); - wrapper.vm - .$nextTick() - .then(() => { - expect(wrapper.vm.isCancelling).toBe(true); - }) - .then(done) - .catch(done.fail); - }); - }); -}); diff --git a/spec/frontend/pipelines/pipelines_table_spec.js b/spec/frontend/pipelines/pipelines_table_spec.js index 952bea81052..70e47b98575 100644 --- a/spec/frontend/pipelines/pipelines_table_spec.js +++ b/spec/frontend/pipelines/pipelines_table_spec.js @@ -30,23 +30,17 @@ describe('Pipelines Table', () => { return pipelines.find((p) => p.user !== null && p.commit !== null); }; - const createComponent = (props = {}, flagState = false) => { + const createComponent = (props = {}) => { wrapper = extendedWrapper( mount(PipelinesTable, { propsData: { ...defaultProps, ...props, }, - provide: { - glFeatures: { - newPipelinesTable: flagState, - }, - }, }), ); }; - const findRows = () => wrapper.findAll('.commit.gl-responsive-table-row'); const findGlTable = () => wrapper.findComponent(GlTable); const findStatusBadge = () => wrapper.findComponent(PipelinesStatusBadge); const findPipelineInfo = () => wrapper.findComponent(PipelineUrl); @@ -56,8 +50,7 @@ describe('Pipelines Table', () => { const findTimeAgo = () => wrapper.findComponent(PipelinesTimeago); const findActions = () => wrapper.findComponent(PipelineOperations); - const findLegacyTable = () => wrapper.findByTestId('legacy-ci-table'); - const findTableRows = () => wrapper.findAll('[data-testid="pipeline-table-row"]'); + const findTableRows = () => wrapper.findAllByTestId('pipeline-table-row'); const findStatusTh = () => wrapper.findByTestId('status-th'); const findPipelineTh = () => wrapper.findByTestId('pipeline-th'); const findTriggererTh = () => wrapper.findByTestId('triggerer-th'); @@ -75,52 +68,13 @@ describe('Pipelines Table', () => { wrapper = null; }); - describe('table with feature flag off', () => { - describe('renders the table correctly', () => { - beforeEach(() => { - createComponent(); - }); - - it('should render a table', () => { - expect(wrapper.classes()).toContain('ci-table'); - }); - - it('should render table head with correct columns', () => { - expect(wrapper.find('.table-section.js-pipeline-status').text()).toEqual('Status'); - - expect(wrapper.find('.table-section.js-pipeline-info').text()).toEqual('Pipeline'); - - expect(wrapper.find('.table-section.js-pipeline-commit').text()).toEqual('Commit'); - - expect(wrapper.find('.table-section.js-pipeline-stages').text()).toEqual('Stages'); - }); - }); - - describe('without data', () => { - it('should render an empty table', () => { - createComponent(); - - expect(findRows()).toHaveLength(0); - }); - }); - - describe('with data', () => { - it('should render rows', () => { - createComponent({ pipelines: [pipeline], viewType: 'root' }); - - expect(findRows()).toHaveLength(1); - }); - }); - }); - - describe('table with feature flag on', () => { + describe('Pipelines Table', () => { beforeEach(() => { - createComponent({ pipelines: [pipeline], viewType: 'root' }, true); + createComponent({ pipelines: [pipeline], viewType: 'root' }); }); - it('displays new table', () => { + it('displays table', () => { expect(findGlTable().exists()).toBe(true); - expect(findLegacyTable().exists()).toBe(false); }); it('should render table head with correct columns', () => { |