From d303b5ba1f6b7c2465bb6d67f42138ca0e37b875 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Fri, 6 Apr 2018 13:30:58 -0500 Subject: [PATCH] Added specs for rendered output, changed the background for stable tracks --- .../monitoring/components/graph/axis.vue | 7 ++++- .../monitoring/components/graph/legend.vue | 12 ++++++- .../components/graph/track_line.vue | 10 +++--- .../stylesheets/framework/variables.scss | 5 +++ .../stylesheets/pages/environments.scss | 9 ++++++ .../monitoring/graph/track_info_spec.js | 13 ++++++++ .../monitoring/graph/track_line_spec.js | 31 ++++++++++++++----- 7 files changed, 73 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/monitoring/components/graph/axis.vue b/app/assets/javascripts/monitoring/components/graph/axis.vue index 6e15f938ab7..fc4b3689dfd 100644 --- a/app/assets/javascripts/monitoring/components/graph/axis.vue +++ b/app/assets/javascripts/monitoring/components/graph/axis.vue @@ -1,5 +1,6 @@ diff --git a/app/assets/javascripts/monitoring/components/graph/track_line.vue b/app/assets/javascripts/monitoring/components/graph/track_line.vue index d529ac1ceb9..79b322e2e42 100644 --- a/app/assets/javascripts/monitoring/components/graph/track_line.vue +++ b/app/assets/javascripts/monitoring/components/graph/track_line.vue @@ -7,10 +7,10 @@ export default { required: true, }, }, - methods: { - strokeDashArray(type) { - if (type === 'dashed') return '6, 3'; - if (type === 'dotted') return '3, 3'; + computed: { + stylizedLine() { + if (this.track.lineStyle === 'dashed') return '6, 3'; + if (this.track.lineStyle === 'dotted') return '3, 3'; return null; }, }, @@ -22,7 +22,7 @@ export default { width="15" height="6"> { expect(vm.summaryMetrics).toEqual('Avg: 0.000 · Max: 0.000'); }); }); + + describe('Rendered output', () => { + beforeEach(() => { + vm = mountComponent(Component, { track: timeSeries[0] }); + }); + + it('contains metric tag and the summary metrics', () => { + const metricTag = vm.$el.querySelector('strong'); + + expect(metricTag.textContent.trim()).toEqual(vm.track.metricTag); + expect(vm.$el.textContent).toContain('Avg: 0.000 · Max: 0.000'); + }); + }); }); diff --git a/spec/javascripts/monitoring/graph/track_line_spec.js b/spec/javascripts/monitoring/graph/track_line_spec.js index 9be2bca1c28..45106830a67 100644 --- a/spec/javascripts/monitoring/graph/track_line_spec.js +++ b/spec/javascripts/monitoring/graph/track_line_spec.js @@ -20,16 +20,33 @@ describe('TrackLine component', () => { }); describe('Computed props', () => { - beforeEach(() => { - vm = mountComponent(Component, { track: timeSeries[0] }); + it('stylizedLine for dashed lineStyles', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0], lineStyle: 'dashed' } }); + + expect(vm.stylizedLine).toEqual('6, 3'); }); - it('strokeDashArray', () => { - const dashedArray = vm.strokeDashArray('dashed'); - const dottedArray = vm.strokeDashArray('dotted'); + it('stylizedLine for dotted lineStyles', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0], lineStyle: 'dotted' } }); - expect(dashedArray).toEqual('6, 3'); - expect(dottedArray).toEqual('3, 3'); + expect(vm.stylizedLine).toEqual('3, 3'); + }); + }); + + describe('Rendered output', () => { + it('has an svg with a line', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0] } }); + const svgEl = vm.$el.querySelector('svg'); + const lineEl = vm.$el.querySelector('svg line'); + + expect(svgEl.getAttribute('width')).toEqual('15'); + expect(svgEl.getAttribute('height')).toEqual('6'); + + expect(lineEl.getAttribute('stroke-width')).toEqual('4'); + expect(lineEl.getAttribute('x1')).toEqual('0'); + expect(lineEl.getAttribute('x2')).toEqual('15'); + expect(lineEl.getAttribute('y1')).toEqual('2'); + expect(lineEl.getAttribute('y2')).toEqual('2'); }); }); });