diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/frontend/environments/empty_state_spec.js | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/frontend/environments/empty_state_spec.js')
-rw-r--r-- | spec/frontend/environments/empty_state_spec.js | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/spec/frontend/environments/empty_state_spec.js b/spec/frontend/environments/empty_state_spec.js index 974afc6d032..02cf2dc3c68 100644 --- a/spec/frontend/environments/empty_state_spec.js +++ b/spec/frontend/environments/empty_state_spec.js @@ -4,10 +4,21 @@ import EmptyState from '~/environments/components/empty_state.vue'; import { ENVIRONMENTS_SCOPE } from '~/environments/constants'; const HELP_PATH = '/help'; +const NEW_PATH = '/new'; describe('~/environments/components/empty_state.vue', () => { let wrapper; + const findNewEnvironmentLink = () => + wrapper.findByRole('link', { + name: s__('Environments|New environment'), + }); + + const findDocsLink = () => + wrapper.findByRole('link', { + name: s__('Environments|How do I create an environment?'), + }); + const createWrapper = ({ propsData = {} } = {}) => mountExtended(EmptyState, { propsData: { @@ -15,6 +26,7 @@ describe('~/environments/components/empty_state.vue', () => { helpPath: HELP_PATH, ...propsData, }, + provide: { newEnvironmentPath: NEW_PATH }, }); afterEach(() => { @@ -44,10 +56,44 @@ describe('~/environments/components/empty_state.vue', () => { it('shows a link to the the help path', () => { wrapper = createWrapper(); - const link = wrapper.findByRole('link', { - name: s__('Environments|How do I create an environment?'), - }); + const link = findDocsLink(); expect(link.attributes('href')).toBe(HELP_PATH); }); + + it('hides a link to creating a new environment', () => { + const link = findNewEnvironmentLink(); + + expect(link.exists()).toBe(false); + }); + + describe('with search term', () => { + beforeEach(() => { + wrapper = createWrapper({ propsData: { hasTerm: true } }); + }); + + it('should show text about searching', () => { + const header = wrapper.findByRole('heading', { + name: s__('Environments|No results found'), + }); + + expect(header.exists()).toBe(true); + + const text = wrapper.findByText(s__('Environments|Edit your search and try again')); + + expect(text.exists()).toBe(true); + }); + + it('hides the documentation link', () => { + const link = findDocsLink(); + + expect(link.exists()).toBe(false); + }); + + it('shows a link to create a new environment', () => { + const link = findNewEnvironmentLink(); + + expect(link.attributes('href')).toBe(NEW_PATH); + }); + }); }); |