|
| 1 | +/// <reference types="cypress" /> |
| 2 | +import should from 'should' |
| 3 | + |
| 4 | +/* eslint-disable cypress/no-unnecessary-waiting */ |
| 5 | +describe('Node/-RED Dashboard 2.0 - Chart Widget - line - max limits', () => { |
| 6 | + it('should limit the chart data to 3 points', () => { |
| 7 | + const overrides = [ |
| 8 | + { |
| 9 | + id: 'chart-1', // the ID in the base flow fixture (required) |
| 10 | + mode: 'merge', |
| 11 | + data: { |
| 12 | + name: 'line-append-max-3-points', |
| 13 | + label: 'line-append-max-3-points', |
| 14 | + removeOlder: 1, // 1 of unit (e.g. 1 x 3600 seconds == 1 hour) |
| 15 | + removeOlderUnit: '3600', // seconds |
| 16 | + removeOlderPoints: '3' // maximum of 3 points |
| 17 | + } |
| 18 | + } |
| 19 | + ] |
| 20 | + cy.deployFixture('dashboard-chart-line-max-limits', overrides) |
| 21 | + cy.visit('/dashboard/page1') |
| 22 | + cy.reload() |
| 23 | + |
| 24 | + cy.get('#nrdb-ui-widget-chart-1 > div > div').should('exist') |
| 25 | + // operate input button 5 times |
| 26 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 27 | + cy.wait(10) |
| 28 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 29 | + cy.wait(10) |
| 30 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 31 | + cy.wait(10) |
| 32 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 33 | + cy.wait(10) |
| 34 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 35 | + cy.wait(10) |
| 36 | + |
| 37 | + // eslint-disable-next-line promise/catch-or-return, promise/always-return |
| 38 | + cy.window().then(win => { |
| 39 | + should(win.uiCharts).is.not.empty() |
| 40 | + const chart = win.uiCharts['chart-1'] |
| 41 | + should(chart).is.not.empty() |
| 42 | + const options = chart.chart.getOption() |
| 43 | + should(options.series).be.an.Array() |
| 44 | + |
| 45 | + should(options.series).be.an.Array().and.have.length(1) |
| 46 | + should(options.series[0].data).be.an.Array().and.have.length(3) |
| 47 | + }) |
| 48 | + }) |
| 49 | + it('should limit the chart data to 3 seconds', () => { |
| 50 | + const overrides = [ |
| 51 | + { |
| 52 | + id: 'chart-1', // the ID in the base flow fixture (required) |
| 53 | + mode: 'merge', |
| 54 | + data: { |
| 55 | + name: 'line-append-max-3-seconds', |
| 56 | + label: 'line-append-max-3-seconds', |
| 57 | + removeOlder: '3', // 3 of unit (e.g. 3 x 1 seconds == 3 seconds) |
| 58 | + removeOlderUnit: '1', // seconds |
| 59 | + removeOlderPoints: '' |
| 60 | + } |
| 61 | + } |
| 62 | + ] |
| 63 | + cy.deployFixture('dashboard-chart-line-max-limits', overrides) |
| 64 | + cy.visit('/dashboard/page1') |
| 65 | + cy.reload() |
| 66 | + |
| 67 | + cy.get('#nrdb-ui-widget-chart-1 > div > div').should('exist') |
| 68 | + // operate input button (add 3 points) |
| 69 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 70 | + cy.wait(10) |
| 71 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 72 | + cy.wait(10) |
| 73 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 74 | + |
| 75 | + // wait some time to allow data pruning to occur |
| 76 | + cy.wait(3500) |
| 77 | + |
| 78 | + // add 2 more points |
| 79 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 80 | + cy.wait(10) |
| 81 | + cy.clickAndWait(cy.get('button').contains('random')) |
| 82 | + cy.wait(10) |
| 83 | + |
| 84 | + // eslint-disable-next-line promise/catch-or-return, promise/always-return |
| 85 | + cy.window().then(win => { |
| 86 | + should(win.uiCharts).is.not.empty() |
| 87 | + const chart = win.uiCharts['chart-1'] |
| 88 | + should(chart).is.not.empty() |
| 89 | + const options = chart.chart.getOption() |
| 90 | + should(options.series).be.an.Array() |
| 91 | + |
| 92 | + should(options.series).be.an.Array().and.have.length(1) |
| 93 | + should(options.series[0].data).be.an.Array().and.have.length(2) |
| 94 | + }) |
| 95 | + }) |
| 96 | +}) |
0 commit comments