From ea26e7bed50761352fc30f7d2295b8abdd293002 Mon Sep 17 00:00:00 2001 From: Ran Byron Date: Sun, 24 Mar 2019 09:14:12 +0200 Subject: [PATCH 1/2] Widget size and position test --- .../integration/dashboard/dashboard_spec.js | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/client/cypress/integration/dashboard/dashboard_spec.js b/client/cypress/integration/dashboard/dashboard_spec.js index cdb74061a6..a538e482ca 100644 --- a/client/cypress/integration/dashboard/dashboard_spec.js +++ b/client/cypress/integration/dashboard/dashboard_spec.js @@ -15,15 +15,15 @@ function editDashboard() { }); } -function addTextboxByAPI(text, dashId) { +function addTextboxByAPI(text, dashId, options = {}) { const data = { width: 1, dashboard_id: dashId, visualization_id: null, text: 'text', - options: { + options: Object.assign({ position: { col: 0, row: 0, sizeX: 3, sizeY: 3 }, - }, + }, options), }; return cy.request('POST', 'api/widgets', data) @@ -251,6 +251,27 @@ describe('Dashboard', () => { cy.get('@textboxEl').should('contain', newContent); }); }); + + it('renders textbox according to position configuration', function () { + const id = this.dashboardId; + const txb1Pos = { col: 0, row: 0, sizeX: 3, sizeY: 2 }; + const txb2Pos = { col: 1, row: 1, sizeX: 3, sizeY: 4 }; + + cy.viewport(1215, 800); + addTextboxByAPI('x', id, { position: txb1Pos }) + .then(() => addTextboxByAPI('x', id, { position: txb2Pos })) + .then((elTestId) => { + cy.visit(this.dashboardUrl); + return cy.getByTestId(elTestId); + }) + .should(($el) => { + const { top, left } = $el.offset(); + expect(top).to.eq(214); + expect(left).to.eq(215); + expect($el.width()).to.eq(600); + expect($el.height()).to.eq(185); + }); + }); }); describe('Grid compliant widgets', () => { From a0d1f563966d50866f85852ea2a76827f6e56521 Mon Sep 17 00:00:00 2001 From: Ran Byron Date: Tue, 26 Mar 2019 11:08:43 +0200 Subject: [PATCH 2/2] Fixed wrong assertion --- client/cypress/integration/dashboard/dashboard_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cypress/integration/dashboard/dashboard_spec.js b/client/cypress/integration/dashboard/dashboard_spec.js index a538e482ca..ce381c3210 100644 --- a/client/cypress/integration/dashboard/dashboard_spec.js +++ b/client/cypress/integration/dashboard/dashboard_spec.js @@ -268,7 +268,7 @@ describe('Dashboard', () => { const { top, left } = $el.offset(); expect(top).to.eq(214); expect(left).to.eq(215); - expect($el.width()).to.eq(600); + expect($el.width()).to.eq(585); expect($el.height()).to.eq(185); }); });