diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 15:06:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 15:06:32 +0300 |
commit | d2ffc30fd583e86d4122bb5061098f4f3ca7b3f1 (patch) | |
tree | cb29c77a3ea49eb8ec732b0e644ed6cfad4770d9 /spec/frontend | |
parent | 914ea32e0efca21436220df2c10e1bfbe4ed3da9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 123 insertions, 18 deletions
diff --git a/spec/frontend/ide/stores/integration_spec.js b/spec/frontend/ide/stores/integration_spec.js new file mode 100644 index 00000000000..443de18f288 --- /dev/null +++ b/spec/frontend/ide/stores/integration_spec.js @@ -0,0 +1,100 @@ +import { decorateFiles } from '~/ide/lib/files'; +import { createStore } from '~/ide/stores'; + +const TEST_BRANCH = 'test_branch'; +const TEST_NAMESPACE = 'test_namespace'; +const TEST_PROJECT_ID = `${TEST_NAMESPACE}/test_project`; +const TEST_PATH_DIR = 'src'; +const TEST_PATH = `${TEST_PATH_DIR}/foo.js`; +const TEST_CONTENT = `Lorem ipsum dolar sit +Lorem ipsum dolar +Lorem ipsum +Lorem +`; + +jest.mock('~/ide/ide_router'); + +describe('IDE store integration', () => { + let store; + + beforeEach(() => { + store = createStore(); + store.replaceState({ + ...store.state, + projects: { + [TEST_PROJECT_ID]: { + web_url: 'test_web_url', + branches: [], + }, + }, + currentProjectId: TEST_PROJECT_ID, + currentBranchId: TEST_BRANCH, + }); + }); + + describe('with project and files', () => { + beforeEach(() => { + const { entries, treeList } = decorateFiles({ + data: [`${TEST_PATH_DIR}/`, TEST_PATH, 'README.md'], + projectId: TEST_PROJECT_ID, + branchId: TEST_BRANCH, + }); + + Object.assign(entries[TEST_PATH], { + raw: TEST_CONTENT, + }); + + store.replaceState({ + ...store.state, + trees: { + [`${TEST_PROJECT_ID}/${TEST_BRANCH}`]: { + tree: treeList, + }, + }, + entries, + }); + }); + + describe('when a file is deleted and readded', () => { + beforeEach(() => { + store.dispatch('deleteEntry', TEST_PATH); + store.dispatch('createTempEntry', { name: TEST_PATH, type: 'blob' }); + }); + + it('has changed and staged', () => { + expect(store.state.changedFiles).toEqual([ + expect.objectContaining({ + path: TEST_PATH, + tempFile: true, + deleted: false, + }), + ]); + + expect(store.state.stagedFiles).toEqual([ + expect.objectContaining({ + path: TEST_PATH, + deleted: true, + }), + ]); + }); + + it('cleans up after commit', () => { + const expected = expect.objectContaining({ + path: TEST_PATH, + staged: false, + changed: false, + tempFile: false, + deleted: false, + }); + store.dispatch('stageChange', TEST_PATH); + + store.dispatch('commit/updateFilesAfterCommit', { data: {} }); + + expect(store.state.entries[TEST_PATH]).toEqual(expected); + expect(store.state.entries[TEST_PATH_DIR].tree.find(x => x.path === TEST_PATH)).toEqual( + expected, + ); + }); + }); + }); +}); diff --git a/spec/frontend/registry/components/app_spec.js b/spec/frontend/registry/components/app_spec.js index 190af5c11cd..5dcb61e03b5 100644 --- a/spec/frontend/registry/components/app_spec.js +++ b/spec/frontend/registry/components/app_spec.js @@ -1,5 +1,5 @@ -import registry from '~/registry/components/app.vue'; import { mount } from '@vue/test-utils'; +import registry from '~/registry/components/app.vue'; import { TEST_HOST } from '../../helpers/test_constants'; import { reposServerResponse, parsedReposServerResponse } from '../mock_data'; @@ -8,6 +8,7 @@ describe('Registry List', () => { const findCollapsibleContainer = w => w.findAll({ name: 'CollapsibeContainerRegisty' }); const findNoContainerImagesText = w => w.find('.js-no-container-images-text'); + const findNotLoggedInToRegistryText = w => w.find('.js-not-logged-in-to-registry-text'); const findSpinner = w => w.find('.gl-spinner'); const findCharacterErrorText = w => w.find('.js-character-error-text'); @@ -17,6 +18,9 @@ describe('Registry List', () => { noContainersImage: 'foo', containersErrorImage: 'foo', repositoryUrl: 'foo', + registryHostUrlWithPort: 'foo', + personalAccessTokensHelpLink: 'foo', + twoFactorAuthHelpLink: 'foo', }; const setMainEndpoint = jest.fn(); @@ -67,6 +71,13 @@ describe('Registry List', () => { 'With the Container Registry, every project can have its own space to store its Docker images. More Information', ); }); + + it('should render login help text', () => { + const notLoggedInToRegistryText = findNotLoggedInToRegistryText(localWrapper); + expect(notLoggedInToRegistryText.text()).toEqual( + 'If you are not already logged in, you need to authenticate to the Container Registry by using your GitLab username and password. If you have Two-Factor Authentication enabled, use a Personal Access Token instead of a password.', + ); + }); }); describe('while loading data', () => { diff --git a/spec/frontend/vue_mr_widget/components/artifacts_list_app_spec.js b/spec/frontend/vue_mr_widget/components/artifacts_list_app_spec.js index 49ed796d9a8..7d593a77bf3 100644 --- a/spec/frontend/vue_mr_widget/components/artifacts_list_app_spec.js +++ b/spec/frontend/vue_mr_widget/components/artifacts_list_app_spec.js @@ -44,6 +44,7 @@ describe('Merge Requests Artifacts list app', () => { const findButtons = () => wrapper.findAll('button'); const findTitle = () => wrapper.find('.js-title'); + const findErrorMessage = () => wrapper.find('.js-error-state'); const findTableRows = () => wrapper.findAll('tbody tr'); describe('while loading', () => { @@ -109,13 +110,12 @@ describe('Merge Requests Artifacts list app', () => { }); it('renders the error state', () => { - expect(findTitle().text()).toBe('An error occurred while fetching the artifacts'); + expect(findErrorMessage().text()).toBe('An error occurred while fetching the artifacts'); }); - it('renders disabled buttons', () => { + it('does not render buttons', () => { const buttons = findButtons(); - expect(buttons.at(0).attributes('disabled')).toBe('disabled'); - expect(buttons.at(1).attributes('disabled')).toBe('disabled'); + expect(buttons.exists()).toBe(false); }); }); }); diff --git a/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js b/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js index 4c9507223a1..ee107f297ef 100644 --- a/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_collapsible_extension_spec.js @@ -20,6 +20,7 @@ describe('Merge Request Collapsible Extension', () => { }; const findTitle = () => wrapper.find('.js-title'); + const findErrorMessage = () => wrapper.find('.js-error-state'); afterEach(() => { wrapper.destroy(); @@ -87,19 +88,12 @@ describe('Merge Request Collapsible Extension', () => { mountComponent(Object.assign({}, data, { hasError: true })); }); - it('renders the buttons disabled', () => { - expect( - wrapper - .findAll('button') - .at(0) - .attributes('disabled'), - ).toEqual('disabled'); - expect( - wrapper - .findAll('button') - .at(1) - .attributes('disabled'), - ).toEqual('disabled'); + it('does not render the buttons', () => { + expect(wrapper.findAll('button').exists()).toBe(false); + }); + + it('renders title message provided', () => { + expect(findErrorMessage().text()).toBe(data.title); }); }); }); |