diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-03 00:16:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-03 00:16:54 +0300 |
commit | bd091da6d5cb036cf3c58d4ba5671f931c8381e1 (patch) | |
tree | 285571eaae458aa65fb2dc8de115ef98dc98f39e /spec | |
parent | ad4dfa2eb4a24a56fbdcf838fc28f2a5b2b6a3a0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
10 files changed, 127 insertions, 33 deletions
diff --git a/spec/features/projects/pages/user_adds_domain_spec.rb b/spec/features/projects/pages/user_adds_domain_spec.rb index bd4cb1aa39b..71bf1c24655 100644 --- a/spec/features/projects/pages/user_adds_domain_spec.rb +++ b/spec/features/projects/pages/user_adds_domain_spec.rb @@ -95,7 +95,7 @@ RSpec.describe 'User adds pages domain', :js do fill_in 'Domain', with: 'my.test.domain.com' - find('.js-auto-ssl-toggle-container .project-feature-toggle').click + find('.js-auto-ssl-toggle-container .js-project-feature-toggle').click fill_in 'Certificate (PEM)', with: certificate_pem fill_in 'Key (PEM)', with: certificate_key diff --git a/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb b/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb index a3fc5804e13..bdf280f4fe4 100644 --- a/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb +++ b/spec/features/projects/pages/user_edits_lets_encrypt_settings_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "Pages with Let's Encrypt", :https_pages_enabled do expect(page).to have_selector '.card-header', text: 'Certificate' expect(page).to have_text domain.subject - find('.js-auto-ssl-toggle-container .project-feature-toggle').click + find('.js-auto-ssl-toggle-container .js-project-feature-toggle').click expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true' expect(page).not_to have_selector '.card-header', text: 'Certificate' @@ -74,7 +74,7 @@ RSpec.describe "Pages with Let's Encrypt", :https_pages_enabled do expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea' expect(page).not_to have_field 'Key (PEM)', type: 'textarea' - find('.js-auto-ssl-toggle-container .project-feature-toggle').click + find('.js-auto-ssl-toggle-container .js-project-feature-toggle').click expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'false' expect(page).to have_field 'Certificate (PEM)', type: 'textarea' diff --git a/spec/frontend/integrations/edit/components/integration_form_spec.js b/spec/frontend/integrations/edit/components/integration_form_spec.js index 7e01b79383a..7be519b6cde 100644 --- a/spec/frontend/integrations/edit/components/integration_form_spec.js +++ b/spec/frontend/integrations/edit/components/integration_form_spec.js @@ -37,7 +37,7 @@ describe('IntegrationForm', () => { const createComponent = ({ customStateProps = {}, initialState = {}, - props = {}, + provide = {}, mountFn = shallowMountExtended, } = {}) => { const store = createStore({ @@ -47,7 +47,7 @@ describe('IntegrationForm', () => { dispatch = jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = mountFn(IntegrationForm, { - propsData: { ...props }, + provide, store, stubs: { OverrideDropdown, @@ -300,7 +300,7 @@ describe('IntegrationForm', () => { }); }); - describe('with `helpHtml` prop', () => { + describe('with `helpHtml` provided', () => { const mockTestId = 'jest-help-html-test'; setHTMLFixture(` @@ -316,7 +316,7 @@ describe('IntegrationForm', () => { const mockHelpHtml = document.querySelector(`[data-testid="${mockTestId}"]`); createComponent({ - props: { + provide: { helpHtml: mockHelpHtml.outerHTML, }, }); diff --git a/spec/frontend/integrations/edit/mock_data.js b/spec/frontend/integrations/edit/mock_data.js index 39e5f8521e8..c8b292dcf6a 100644 --- a/spec/frontend/integrations/edit/mock_data.js +++ b/spec/frontend/integrations/edit/mock_data.js @@ -13,6 +13,7 @@ export const mockIntegrationProps = { fields: [], type: '', inheritFromId: 25, + integrationLevel: 'project', }; export const mockJiraIssueTypes = [ diff --git a/spec/frontend/integrations/edit/store/getters_spec.js b/spec/frontend/integrations/edit/store/getters_spec.js index 3353e0c84cc..4680c4b24cc 100644 --- a/spec/frontend/integrations/edit/store/getters_spec.js +++ b/spec/frontend/integrations/edit/store/getters_spec.js @@ -1,5 +1,12 @@ -import { currentKey, isInheriting, propsSource } from '~/integrations/edit/store/getters'; +import { + currentKey, + isInheriting, + isProjectLevel, + propsSource, +} from '~/integrations/edit/store/getters'; + import createState from '~/integrations/edit/store/state'; +import { integrationLevels } from '~/integrations/constants'; import { mockIntegrationProps } from '../mock_data'; describe('Integration form store getters', () => { @@ -45,6 +52,18 @@ describe('Integration form store getters', () => { }); }); + describe('isProjectLevel', () => { + it.each` + integrationLevel | expected + ${integrationLevels.PROJECT} | ${true} + ${integrationLevels.GROUP} | ${false} + ${integrationLevels.INSTANCE} | ${false} + `('when integrationLevel is `$integrationLevel`', ({ integrationLevel, expected }) => { + state.customState.integrationLevel = integrationLevel; + expect(isProjectLevel(state)).toBe(expected); + }); + }); + describe('propsSource', () => { beforeEach(() => { state.defaultState = defaultState; diff --git a/spec/frontend/issues/show/components/incidents/incident_tabs_spec.js b/spec/frontend/issues/show/components/incidents/incident_tabs_spec.js index 68c204766ca..20c6cda33d4 100644 --- a/spec/frontend/issues/show/components/incidents/incident_tabs_spec.js +++ b/spec/frontend/issues/show/components/incidents/incident_tabs_spec.js @@ -58,7 +58,6 @@ describe('Incident Tabs component', () => { const findTabs = () => wrapper.findAll(GlTab); const findSummaryTab = () => findTabs().at(0); const findMetricsTab = () => wrapper.find('[data-testid="metrics-tab"]'); - const findTimelineTab = () => wrapper.find('[data-testid="timeline-events-tab"]'); const findAlertDetailsTab = () => wrapper.find('[data-testid="alert-details-tab"]'); const findAlertDetailsComponent = () => wrapper.find(AlertDetailsTable); const findDescriptionComponent = () => wrapper.find(DescriptionComponent); @@ -74,29 +73,6 @@ describe('Incident Tabs component', () => { }); }); - describe('incident timeline tab', () => { - beforeEach(() => { - mountComponent(); - }); - - it('renders the timeline tab when feature flag is enabled', () => { - expect(findTimelineTab().exists()).toBe(true); - expect(findTimelineTab().attributes('title')).toBe('Timeline'); - }); - - it('does not render timeline tab when feature flag is disabled', () => { - mountComponent({}, { provide: { glFeatures: { incidentTimelineEventTab: false } } }); - - expect(findTimelineTab().exists()).toBe(false); - }); - - it('does not render timeline tab when not available in license', () => { - mountComponent({}, { provide: { glFeatures: { incidentTimelineEvents: false } } }); - - expect(findTimelineTab().exists()).toBe(false); - }); - }); - describe('with an alert present', () => { beforeEach(() => { mountComponent(); diff --git a/spec/frontend/pages/projects/pages_domains/form_spec.js b/spec/frontend/pages/projects/pages_domains/form_spec.js new file mode 100644 index 00000000000..55336596f30 --- /dev/null +++ b/spec/frontend/pages/projects/pages_domains/form_spec.js @@ -0,0 +1,82 @@ +import initForm from '~/pages/projects/pages_domains/form'; + +const ENABLED_UNLESS_AUTO_SSL_CLASS = 'js-enabled-unless-auto-ssl'; +const SSL_TOGGLE_CLASS = 'js-enable-ssl-gl-toggle'; +const SSL_TOGGLE_INPUT_CLASS = 'js-project-feature-toggle-input'; +const SHOW_IF_AUTO_SSL_CLASS = 'js-shown-if-auto-ssl'; +const SHOW_UNLESS_AUTO_SSL_CLASS = 'js-shown-unless-auto-ssl'; +const D_NONE_CLASS = 'd-none'; + +describe('Page domains form', () => { + let toggle; + + const findEnabledUnless = () => document.querySelector(`.${ENABLED_UNLESS_AUTO_SSL_CLASS}`); + const findSslToggle = () => document.querySelector(`.${SSL_TOGGLE_CLASS} button`); + const findSslToggleInput = () => document.querySelector(`.${SSL_TOGGLE_INPUT_CLASS}`); + const findIfAutoSsl = () => document.querySelector(`.${SHOW_IF_AUTO_SSL_CLASS}`); + const findUnlessAutoSsl = () => document.querySelector(`.${SHOW_UNLESS_AUTO_SSL_CLASS}`); + + const create = () => { + setFixtures(` + <form> + <span + class="${SSL_TOGGLE_CLASS}" + data-label="SSL toggle" + ></span> + <input class="${SSL_TOGGLE_INPUT_CLASS}" type="hidden" /> + <span class="${SHOW_UNLESS_AUTO_SSL_CLASS}"></span> + <span class="${SHOW_IF_AUTO_SSL_CLASS}"></span> + <button class="${ENABLED_UNLESS_AUTO_SSL_CLASS}"></button> + </form> + `); + }; + + it('instantiates the toggle', () => { + create(); + initForm(); + + expect(findSslToggle()).not.toBe(null); + }); + + describe('when auto SSL is enabled', () => { + beforeEach(() => { + create(); + toggle = initForm(); + toggle.$emit('change', true); + }); + + it('sets the correct classes', () => { + expect(Array.from(findIfAutoSsl().classList)).not.toContain(D_NONE_CLASS); + expect(Array.from(findUnlessAutoSsl().classList)).toContain(D_NONE_CLASS); + }); + + it('sets the correct disabled value', () => { + expect(findEnabledUnless().getAttribute('disabled')).toBe('disabled'); + }); + + it('sets the correct value for the input', () => { + expect(findSslToggleInput().getAttribute('value')).toBe('true'); + }); + }); + + describe('when auto SSL is not enabled', () => { + beforeEach(() => { + create(); + toggle = initForm(); + toggle.$emit('change', false); + }); + + it('sets the correct classes', () => { + expect(Array.from(findIfAutoSsl().classList)).toContain(D_NONE_CLASS); + expect(Array.from(findUnlessAutoSsl().classList)).not.toContain(D_NONE_CLASS); + }); + + it('sets the correct disabled value', () => { + expect(findUnlessAutoSsl().getAttribute('disabled')).toBe(null); + }); + + it('sets the correct value for the input', () => { + expect(findSslToggleInput().getAttribute('value')).toBe('false'); + }); + }); +}); diff --git a/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js b/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js index f15d5f334d6..6cdf9a93d55 100644 --- a/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js +++ b/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js @@ -1,6 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import { EDITOR_READY_EVENT } from '~/editor/constants'; +import { SOURCE_EDITOR_DEBOUNCE } from '~/pipeline_editor/constants'; import TextEditor from '~/pipeline_editor/components/editor/text_editor.vue'; import { mockCiConfigPath, @@ -22,7 +23,7 @@ describe('Pipeline Editor | Text editor component', () => { const MockSourceEditor = { template: '<div/>', - props: ['value', 'fileName'], + props: ['value', 'fileName', 'editorOptions', 'debounceValue'], }; const createComponent = (glFeatures = {}, mountFn = shallowMount) => { @@ -90,6 +91,14 @@ describe('Pipeline Editor | Text editor component', () => { expect(findEditor().props('fileName')).toBe(mockCiConfigPath); }); + it('passes down editor configs options', () => { + expect(findEditor().props('editorOptions')).toEqual({ quickSuggestions: true }); + }); + + it('passes down editor debounce value', () => { + expect(findEditor().props('debounceValue')).toBe(SOURCE_EDITOR_DEBOUNCE); + }); + it('bubbles up events', () => { findEditor().vm.$emit(EDITOR_READY_EVENT, editorInstanceDetail); diff --git a/spec/frontend/snippets/components/__snapshots__/snippet_blob_edit_spec.js.snap b/spec/frontend/snippets/components/__snapshots__/snippet_blob_edit_spec.js.snap index e12255fe825..6fc358a6a15 100644 --- a/spec/frontend/snippets/components/__snapshots__/snippet_blob_edit_spec.js.snap +++ b/spec/frontend/snippets/components/__snapshots__/snippet_blob_edit_spec.js.snap @@ -14,6 +14,7 @@ exports[`Snippet Blob Edit component with loaded blob matches snapshot 1`] = ` /> <source-editor-stub + debouncevalue="250" editoroptions="[object Object]" fileglobalid="blob_local_7" filename="foo/bar/test.md" diff --git a/spec/frontend/toggles/index_spec.js b/spec/frontend/toggles/index_spec.js index 575b1b6080c..19c4d6f1f1d 100644 --- a/spec/frontend/toggles/index_spec.js +++ b/spec/frontend/toggles/index_spec.js @@ -99,10 +99,12 @@ describe('toggles/index.js', () => { const name = 'toggle-name'; const help = 'Help text'; const foo = 'bar'; + const id = 'an-id'; beforeEach(() => { initToggleWithOptions({ name, + id, isChecked: true, disabled: true, isLoading: true, @@ -144,6 +146,10 @@ describe('toggles/index.js', () => { it('passes custom dataset to the wrapper', () => { expect(toggleWrapper.dataset.foo).toBe('bar'); }); + + it('passes an id to the wrapper', () => { + expect(toggleWrapper.id).toBe(id); + }); }); }); }); |