diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-10-04 16:43:45 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-10-04 16:45:02 +0100 |
commit | 2e53056e94e2be32d481e084b68be87dc0e448dd (patch) | |
tree | 4b31fcc8f99060555c91479897406445ffcfe45f /spec | |
parent | 8d9d0f9401269a5718da9d22a1863a4c4ab5f36e (diff) | |
download | gitlab-ce-2e53056e94e2be32d481e084b68be87dc0e448dd.tar.gz |
Adds Frontend specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/clusters_spec.js | 79 | ||||
-rw-r--r-- | spec/javascripts/fixtures/clusters.rb | 35 |
2 files changed, 114 insertions, 0 deletions
diff --git a/spec/javascripts/clusters_spec.js b/spec/javascripts/clusters_spec.js new file mode 100644 index 00000000000..2ceb0cfdf4c --- /dev/null +++ b/spec/javascripts/clusters_spec.js @@ -0,0 +1,79 @@ +import Clusters from '~/clusters'; + +describe('Clusters', () => { + let cluster; + preloadFixtures('clusters/show_cluster.html.raw'); + + beforeEach(() => { + loadFixtures('clusters/show_cluster.html.raw'); + cluster = new Clusters(); + }); + + describe('toggle', () => { + it('should update the button and the input field on click', () => { + cluster.toggleButton.click(); + + expect( + cluster.toggleButton.classList, + ).not.toContain('checked'); + + expect( + cluster.toggleInput.getAttribute('value'), + ).toEqual('false'); + }); + }); + + describe('updateContainer', () => { + describe('when creating cluster', () => { + it('should show the creating container', () => { + cluster.updateContainer('creating'); + + expect( + cluster.creatingContainer.classList, + ).not.toContain('hidden'); + expect( + cluster.successContainer.classList, + ).toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).toContain('hidden'); + }); + }); + + describe('when cluster is created', () => { + it('should show the success container', () => { + cluster.updateContainer('created'); + + expect( + cluster.creatingContainer.classList, + ).toContain('hidden'); + expect( + cluster.successContainer.classList, + ).not.toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).toContain('hidden'); + }); + }); + + describe('when cluster has error', () => { + it('should show the error container', () => { + cluster.updateContainer('errored', 'this is an error'); + + expect( + cluster.creatingContainer.classList, + ).toContain('hidden'); + expect( + cluster.successContainer.classList, + ).toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).not.toContain('hidden'); + + expect( + cluster.errorContainer.querySelector('.js-error-reason').textContent, + ).toContain('this is an error'); + }); + }); + }); +}); diff --git a/spec/javascripts/fixtures/clusters.rb b/spec/javascripts/fixtures/clusters.rb new file mode 100644 index 00000000000..be9d1d8f216 --- /dev/null +++ b/spec/javascripts/fixtures/clusters.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Projects::ClustersController, '(JavaScript fixtures)', type: :controller do + include JavaScriptFixturesHelpers + + let(:admin) { create(:admin) } + let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} + let(:project) { create(:project, :repository, namespace: namespace) } + let(:cluster) { project.create_cluster!(gcp_cluster_name: "gke-test-creation-1", gcp_project_id: 'gitlab-internal-153318', gcp_cluster_zone: 'us-central1-a', gcp_cluster_size: '1', project_namespace: 'aaa', gcp_machine_type: 'n1-standard-1')} + + render_views + + before(:all) do + clean_frontend_fixtures('branches/') + end + + before do + sign_in(admin) + end + + after do + remove_repository(project) + end + + it 'clusters/show_cluster.html.raw' do |example| + get :show, + namespace_id: project.namespace.to_param, + project_id: project, + id: cluster + + expect(response).to be_success + store_frontend_fixture(response, example.description) + end + +end |