diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-07 16:12:13 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-07 16:12:13 +0900 |
commit | 08fba1327fa5d2b123155b647e2ac963f9d76bb3 (patch) | |
tree | 538b1356bbda6358a40a7bf9b7a68813f44d1275 /spec/javascripts | |
parent | f8391bd782ef9a19b6c8595331ada49721bd89be (diff) | |
parent | 49430c47d4d34072ff43cc1e35213317802055d7 (diff) | |
download | gitlab-ce-08fba1327fa5d2b123155b647e2ac963f9d76bb3.tar.gz |
merge from master
Diffstat (limited to 'spec/javascripts')
6 files changed, 73 insertions, 49 deletions
diff --git a/spec/javascripts/environments/environments_store_spec.js b/spec/javascripts/environments/environments_store_spec.js index 6e855530b21..f2c6ec24dd7 100644 --- a/spec/javascripts/environments/environments_store_spec.js +++ b/spec/javascripts/environments/environments_store_spec.js @@ -86,6 +86,16 @@ describe('Store', () => { store.toggleFolder(store.state.environments[1]); expect(store.state.environments[1].isOpen).toEqual(false); }); + + it('should keep folder open when environments are updated', () => { + store.storeEnvironments(serverData); + + store.toggleFolder(store.state.environments[1]); + expect(store.state.environments[1].isOpen).toEqual(true); + + store.storeEnvironments(serverData); + expect(store.state.environments[1].isOpen).toEqual(true); + }); }); describe('setfolderContent', () => { @@ -97,6 +107,17 @@ describe('Store', () => { expect(store.state.environments[1].children.length).toEqual(serverData.length); expect(store.state.environments[1].children[0].isChildren).toEqual(true); }); + + it('should keep folder content when environments are updated', () => { + store.storeEnvironments(serverData); + + store.setfolderContent(store.state.environments[1], serverData); + + expect(store.state.environments[1].children.length).toEqual(serverData.length); + // poll + store.storeEnvironments(serverData); + expect(store.state.environments[1].children.length).toEqual(serverData.length); + }); }); describe('store pagination', () => { diff --git a/spec/javascripts/fixtures/oauth_remember_me.html.haml b/spec/javascripts/fixtures/oauth_remember_me.html.haml new file mode 100644 index 00000000000..7886e995e57 --- /dev/null +++ b/spec/javascripts/fixtures/oauth_remember_me.html.haml @@ -0,0 +1,5 @@ +#oauth-container + %input#remember_me{ type: "checkbox" } + + %a.oauth-login.twitter{ href: "http://example.com/" } + %a.oauth-login.github{ href: "http://example.com/" } diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 56d938e1fbe..b69f4eddffc 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -2481,6 +2481,7 @@ export const singleRowMetrics = [ 'queries': [ { 'query_range': 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100', + 'label': 'Container CPU', 'result': [ { 'metric': { diff --git a/spec/javascripts/monitoring/monitoring_column_spec.js b/spec/javascripts/monitoring/monitoring_column_spec.js index b3bc97adc9f..c423024dce0 100644 --- a/spec/javascripts/monitoring/monitoring_column_spec.js +++ b/spec/javascripts/monitoring/monitoring_column_spec.js @@ -95,7 +95,7 @@ describe('MonitoringColumn', () => { }); }); - it('has a title for the y-axis that comes from the backend', () => { + it('has a title for the y-axis and the chart legend that comes from the backend', () => { const component = createComponent({ columnData: singleRowMetrics[0], classType: 'col-md-6', @@ -104,5 +104,6 @@ describe('MonitoringColumn', () => { }); expect(component.yAxisLabel).toEqual(component.columnData.y_label); + expect(component.legendTitle).toEqual(component.columnData.queries[0].label); }); }); diff --git a/spec/javascripts/oauth_remember_me_spec.js b/spec/javascripts/oauth_remember_me_spec.js new file mode 100644 index 00000000000..f90e0093d25 --- /dev/null +++ b/spec/javascripts/oauth_remember_me_spec.js @@ -0,0 +1,26 @@ +import OAuthRememberMe from '~/oauth_remember_me'; + +describe('OAuthRememberMe', () => { + preloadFixtures('static/oauth_remember_me.html.raw'); + + beforeEach(() => { + loadFixtures('static/oauth_remember_me.html.raw'); + + new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents(); + }); + + it('adds the "remember_me" query parameter to all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/?remember_me=1'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/?remember_me=1'); + }); + + it('removes the "remember_me" query parameter from all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/'); + }); +}); diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js index 4b6f171c8d6..647b59520f8 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js @@ -76,28 +76,6 @@ describe('MRWidgetPipeline', () => { el = vm.$el; }); - afterEach(() => { - vm.$destroy(); - }); - - describe('without a pipeline', () => { - beforeEach(() => { - vm.mr = { pipeline: null }; - }); - - it('should render message with spinner', (done) => { - Vue.nextTick() - .then(() => { - expect(el.querySelector('.pipeline-id')).toBe(null); - expect(el.innerText.trim()).toBe('Waiting for pipeline...'); - expect(el.querySelectorAll('i.fa.fa-spinner.fa-spin').length).toBe(1); - done(); - }) - .then(done) - .catch(done.fail); - }); - }); - it('should render template elements correctly', () => { expect(el.classList.contains('mr-widget-heading')).toBeTruthy(); expect(el.querySelectorAll('.ci-status-icon.ci-status-icon-success').length).toEqual(1); @@ -115,47 +93,39 @@ describe('MRWidgetPipeline', () => { it('should list single stage', (done) => { pipeline.details.stages.splice(0, 1); - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(1); - expect(el.innerText).toContain('with stage'); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(1); + expect(el.innerText).toContain('with stage'); + done(); + }); }); it('should not have stages when there is no stage', (done) => { vm.mr.pipeline.details.stages = []; - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(0); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(0); + done(); + }); }); it('should not have coverage text when pipeline has no coverage info', (done) => { vm.mr.pipeline.coverage = null; - Vue.nextTick() - .then(() => { - expect(el.querySelector('.js-mr-coverage')).toEqual(null); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelector('.js-mr-coverage')).toEqual(null); + done(); + }); }); it('should show CI error when there is a CI error', (done) => { vm.mr.ciStatus = null; - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); - expect(el.innerText).toContain('Could not connect to the CI server'); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); + expect(el.innerText).toContain('Could not connect to the CI server'); + done(); + }); }); }); }); |