diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 12:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 12:09:46 +0300 |
commit | 221b529789f4090341a825695aeb49b8df6dd11d (patch) | |
tree | c8843e4ca5ef1034752eb68712fcf338b24950db /spec/frontend/static_site_editor | |
parent | 00a8c64ffd18e74df4b1cdeda7776b5221fddafe (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/static_site_editor')
4 files changed, 71 insertions, 4 deletions
diff --git a/spec/frontend/static_site_editor/components/edit_header_spec.js b/spec/frontend/static_site_editor/components/edit_header_spec.js new file mode 100644 index 00000000000..2b0fe226a0b --- /dev/null +++ b/spec/frontend/static_site_editor/components/edit_header_spec.js @@ -0,0 +1,38 @@ +import { shallowMount } from '@vue/test-utils'; + +import EditHeader from '~/static_site_editor/components/edit_header.vue'; +import { DEFAULT_HEADING } from '~/static_site_editor/constants'; + +import { sourceContentTitle } from '../mock_data'; + +describe('~/static_site_editor/components/edit_header.vue', () => { + let wrapper; + + const buildWrapper = (propsData = {}) => { + wrapper = shallowMount(EditHeader, { + propsData: { + ...propsData, + }, + }); + }; + + const findHeading = () => wrapper.find({ ref: 'sseHeading' }); + + beforeEach(() => { + buildWrapper(); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + it('renders the default heading if there is no title prop', () => { + expect(findHeading().text()).toBe(DEFAULT_HEADING); + }); + + it('renders the title prop value in the heading', () => { + buildWrapper({ title: sourceContentTitle }); + + expect(findHeading().text()).toBe(sourceContentTitle); + }); +}); diff --git a/spec/frontend/static_site_editor/components/publish_toolbar_spec.js b/spec/frontend/static_site_editor/components/publish_toolbar_spec.js index 0edc3f4c920..f00fc38430f 100644 --- a/spec/frontend/static_site_editor/components/publish_toolbar_spec.js +++ b/spec/frontend/static_site_editor/components/publish_toolbar_spec.js @@ -3,6 +3,8 @@ import { GlNewButton, GlLoadingIcon } from '@gitlab/ui'; import PublishToolbar from '~/static_site_editor/components/publish_toolbar.vue'; +import { returnUrl } from '../mock_data'; + describe('Static Site Editor Toolbar', () => { let wrapper; @@ -15,6 +17,7 @@ describe('Static Site Editor Toolbar', () => { }); }; + const findReturnUrlLink = () => wrapper.find({ ref: 'returnUrlLink' }); const findSaveChangesButton = () => wrapper.find(GlNewButton); const findLoadingIndicator = () => wrapper.find(GlLoadingIcon); @@ -38,6 +41,17 @@ describe('Static Site Editor Toolbar', () => { expect(findLoadingIndicator().classes()).toContain('invisible'); }); + it('does not render returnUrl link', () => { + expect(findReturnUrlLink().exists()).toBe(false); + }); + + it('renders returnUrl link when returnUrl prop exists', () => { + buildWrapper({ returnUrl }); + + expect(findReturnUrlLink().exists()).toBe(true); + expect(findReturnUrlLink().attributes('href')).toBe(returnUrl); + }); + describe('when saveable', () => { it('enables Submit Changes button', () => { buildWrapper({ saveable: true }); diff --git a/spec/frontend/static_site_editor/components/static_site_editor_spec.js b/spec/frontend/static_site_editor/components/static_site_editor_spec.js index 2c4fa0e061a..d427df9bd4b 100644 --- a/spec/frontend/static_site_editor/components/static_site_editor_spec.js +++ b/spec/frontend/static_site_editor/components/static_site_editor_spec.js @@ -7,9 +7,10 @@ import createState from '~/static_site_editor/store/state'; import StaticSiteEditor from '~/static_site_editor/components/static_site_editor.vue'; import EditArea from '~/static_site_editor/components/edit_area.vue'; +import EditHeader from '~/static_site_editor/components/edit_header.vue'; import PublishToolbar from '~/static_site_editor/components/publish_toolbar.vue'; -import { sourceContent } from '../mock_data'; +import { sourceContent, sourceContentTitle } from '../mock_data'; const localVue = createLocalVue(); @@ -60,6 +61,7 @@ describe('StaticSiteEditor', () => { }; const findEditArea = () => wrapper.find(EditArea); + const findEditHeader = () => wrapper.find(EditHeader); const findPublishToolbar = () => wrapper.find(PublishToolbar); const findSkeletonLoader = () => wrapper.find(GlSkeletonLoader); @@ -77,16 +79,21 @@ describe('StaticSiteEditor', () => { expect(findEditArea().exists()).toBe(false); }); + it('does not render edit header', () => { + expect(findEditHeader().exists()).toBe(false); + }); + it('does not render toolbar', () => { expect(findPublishToolbar().exists()).toBe(false); }); }); describe('when content is loaded', () => { - const content = 'edit area content'; + const content = sourceContent; + const title = sourceContentTitle; beforeEach(() => { - buildContentLoadedStore({ initialState: { content } }); + buildContentLoadedStore({ initialState: { content, title } }); buildWrapper(); }); @@ -94,6 +101,10 @@ describe('StaticSiteEditor', () => { expect(findEditArea().exists()).toBe(true); }); + it('renders the edit header', () => { + expect(findEditHeader().exists()).toBe(true); + }); + it('does not render skeleton loader', () => { expect(findSkeletonLoader().exists()).toBe(false); }); @@ -102,6 +113,10 @@ describe('StaticSiteEditor', () => { expect(findEditArea().props('value')).toBe(content); }); + it('passes page title to edit header', () => { + expect(findEditHeader().props('title')).toBe(title); + }); + it('renders toolbar', () => { expect(findPublishToolbar().exists()).toBe(true); }); diff --git a/spec/frontend/static_site_editor/mock_data.js b/spec/frontend/static_site_editor/mock_data.js index 1993636ab12..345ae0ce6f6 100644 --- a/spec/frontend/static_site_editor/mock_data.js +++ b/spec/frontend/static_site_editor/mock_data.js @@ -11,11 +11,11 @@ twitter_image: '/images/tweets/handbook-gitlab.png' - TOC {:toc .hidden-md .hidden-lg} `; - export const sourceContentTitle = 'Handbook'; export const username = 'gitlabuser'; export const projectId = '123456'; +export const returnUrl = 'https://www.gitlab.com'; export const sourcePath = 'foobar.md.html'; export const savedContentMeta = { |