diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 15:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 15:09:24 +0000 |
commit | 37699393e9d68181a04f54ded5ae1b08b6272291 (patch) | |
tree | 6d02f81cb671476f5b9b8a635f9307fd7728d04f /spec/frontend | |
parent | 7f59234892f27812dc91044cd63a6a4655e26263 (diff) | |
download | gitlab-ce-37699393e9d68181a04f54ded5ae1b08b6272291.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
5 files changed, 81 insertions, 14 deletions
diff --git a/spec/frontend/ci_lint/components/ci_lint_results_spec.js b/spec/frontend/ci_lint/components/ci_lint_results_spec.js index 37575a988c5..93c2d2dbcf3 100644 --- a/spec/frontend/ci_lint/components/ci_lint_results_spec.js +++ b/spec/frontend/ci_lint/components/ci_lint_results_spec.js @@ -1,20 +1,24 @@ import { shallowMount, mount } from '@vue/test-utils'; -import { GlTable } from '@gitlab/ui'; +import { GlTable, GlLink } from '@gitlab/ui'; import CiLintResults from '~/ci_lint/components/ci_lint_results.vue'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { mockJobs, mockErrors, mockWarnings } from '../mock_data'; describe('CI Lint Results', () => { let wrapper; + const defaultProps = { + valid: true, + jobs: mockJobs, + errors: [], + warnings: [], + dryRun: false, + lintHelpPagePath: '/help', + }; const createComponent = (props = {}, mountFn = shallowMount) => { wrapper = mountFn(CiLintResults, { propsData: { - valid: true, - jobs: mockJobs, - errors: [], - warnings: [], - dryRun: false, + ...defaultProps, ...props, }, }); @@ -23,6 +27,7 @@ describe('CI Lint Results', () => { const findTable = () => wrapper.find(GlTable); const findByTestId = selector => () => wrapper.find(`[data-testid="ci-lint-${selector}"]`); const findAllByTestId = selector => () => wrapper.findAll(`[data-testid="ci-lint-${selector}"]`); + const findLinkToDoc = () => wrapper.find(GlLink); const findErrors = findByTestId('errors'); const findWarnings = findByTestId('warnings'); const findStatus = findByTestId('status'); @@ -48,10 +53,15 @@ describe('CI Lint Results', () => { }); it('displays the invalid status', () => { - expect(findStatus().text()).toBe(`Status: ${wrapper.vm.$options.incorrect.text}`); + expect(findStatus().text()).toContain(`Status: ${wrapper.vm.$options.incorrect.text}`); expect(findStatus().props('variant')).toBe(wrapper.vm.$options.incorrect.variant); }); + it('contains the link to documentation', () => { + expect(findLinkToDoc().text()).toBe('More information'); + expect(findLinkToDoc().attributes('href')).toBe(defaultProps.lintHelpPagePath); + }); + it('displays the error message', () => { const [expectedError] = mockErrors; @@ -66,9 +76,9 @@ describe('CI Lint Results', () => { }); }); - describe('Valid results', () => { + describe('Valid results with dry run', () => { beforeEach(() => { - createComponent(); + createComponent({ dryRun: true }, mount); }); it('displays table', () => { @@ -76,13 +86,18 @@ describe('CI Lint Results', () => { }); it('displays the valid status', () => { - expect(findStatus().text()).toBe(wrapper.vm.$options.correct.text); + expect(findStatus().text()).toContain(wrapper.vm.$options.correct.text); expect(findStatus().props('variant')).toBe(wrapper.vm.$options.correct.variant); }); it('does not display only/expect values with dry run', () => { expect(findOnlyExcept().exists()).toBe(false); }); + + it('contains the link to documentation', () => { + expect(findLinkToDoc().text()).toBe('More information'); + expect(findLinkToDoc().attributes('href')).toBe(defaultProps.lintHelpPagePath); + }); }); describe('Lint results', () => { diff --git a/spec/frontend/ci_lint/components/ci_lint_spec.js b/spec/frontend/ci_lint/components/ci_lint_spec.js index 03ddfd4eeb8..b353da5910d 100644 --- a/spec/frontend/ci_lint/components/ci_lint_spec.js +++ b/spec/frontend/ci_lint/components/ci_lint_spec.js @@ -24,7 +24,8 @@ describe('CI Lint', () => { }, propsData: { endpoint, - helpPagePath: '/help/ci/lint#pipeline-simulation', + pipelineSimulationHelpPagePath: '/help/ci/lint#pipeline-simulation', + lintHelpPagePath: '/help/ci/lint#anchor', }, mocks: { $apollo: { diff --git a/spec/frontend/pipelines/header_component_spec.js b/spec/frontend/pipelines/header_component_spec.js index 6b7371a934a..03e385e3cc8 100644 --- a/spec/frontend/pipelines/header_component_spec.js +++ b/spec/frontend/pipelines/header_component_spec.js @@ -97,6 +97,24 @@ describe('Pipeline details header', () => { ); }); + describe('polling', () => { + it('is stopped when pipeline is finished', async () => { + wrapper = createComponent({ ...mockRunningPipelineHeader }); + + await wrapper.setData({ + pipeline: { ...mockCancelledPipelineHeader }, + }); + + expect(wrapper.vm.$apollo.queries.pipeline.stopPolling).toHaveBeenCalled(); + }); + + it('is not stopped when pipeline is not finished', () => { + wrapper = createComponent(); + + expect(wrapper.vm.$apollo.queries.pipeline.stopPolling).not.toHaveBeenCalled(); + }); + }); + describe('actions', () => { describe('Retry action', () => { beforeEach(() => { diff --git a/spec/frontend/terraform/components/terraform_list_spec.js b/spec/frontend/terraform/components/terraform_list_spec.js index a0c11c45e5b..b31afecc816 100644 --- a/spec/frontend/terraform/components/terraform_list_spec.js +++ b/spec/frontend/terraform/components/terraform_list_spec.js @@ -1,4 +1,4 @@ -import { GlAlert, GlBadge, GlLoadingIcon, GlTab } from '@gitlab/ui'; +import { GlAlert, GlBadge, GlKeysetPagination, GlLoadingIcon, GlTab } from '@gitlab/ui'; import { createLocalVue, shallowMount } from '@vue/test-utils'; import createMockApollo from 'jest/helpers/mock_apollo_helper'; import VueApollo from 'vue-apollo'; @@ -39,6 +39,7 @@ describe('TerraformList', () => { const findBadge = () => wrapper.find(GlBadge); const findEmptyState = () => wrapper.find(EmptyState); + const findPaginationButtons = () => wrapper.find(GlKeysetPagination); const findStatesTable = () => wrapper.find(StatesTable); const findTab = () => wrapper.find(GlTab); @@ -73,6 +74,12 @@ describe('TerraformList', () => { terraformStates: { nodes: states, count: states.length, + pageInfo: { + hasNextPage: true, + hasPreviousPage: false, + startCursor: 'prev', + endCursor: 'next', + }, }, }); @@ -84,8 +91,33 @@ describe('TerraformList', () => { expect(findBadge().text()).toBe('2'); }); - it('renders the states table', () => { + it('renders the states table and pagination buttons', () => { expect(findStatesTable().exists()).toBe(true); + expect(findPaginationButtons().exists()).toBe(true); + }); + + describe('when list has no additional pages', () => { + beforeEach(() => { + createWrapper({ + terraformStates: { + nodes: states, + count: states.length, + pageInfo: { + hasNextPage: false, + hasPreviousPage: false, + startCursor: '', + endCursor: '', + }, + }, + }); + + return wrapper.vm.$nextTick(); + }); + + it('renders the states table without pagination buttons', () => { + expect(findStatesTable().exists()).toBe(true); + expect(findPaginationButtons().exists()).toBe(false); + }); }); }); @@ -95,6 +127,7 @@ describe('TerraformList', () => { terraformStates: { nodes: [], count: 0, + pageInfo: null, }, }); diff --git a/spec/frontend/whats_new/components/app_spec.js b/spec/frontend/whats_new/components/app_spec.js index 8ea8a24935f..cba550b19db 100644 --- a/spec/frontend/whats_new/components/app_spec.js +++ b/spec/frontend/whats_new/components/app_spec.js @@ -107,7 +107,7 @@ describe('App', () => { it('send an event when feature item is clicked', () => { trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn); - const link = wrapper.find('[data-testid="whats-new-title-link"]'); + const link = wrapper.find('.whats-new-item-title-link'); triggerEvent(link.element); expect(trackingSpy.mock.calls[1]).toMatchObject([ |