From 3e122455db61c3f026364bf94b9a27587c0df191 Mon Sep 17 00:00:00 2001 From: Jaden Diefenbaugh <blakcap@users.noreply.github.com> Date: Wed, 12 Apr 2017 15:40:53 +0200 Subject: [PATCH] finished group report items mgmt tests, fixed rm exp test --- .../static/reports/test/report-spec.js | 113 ++++++++++++------ 1 file changed, 76 insertions(+), 37 deletions(-) diff --git a/beat/web/reports/static/reports/test/report-spec.js b/beat/web/reports/static/reports/test/report-spec.js index f9eea2150..761845122 100644 --- a/beat/web/reports/static/reports/test/report-spec.js +++ b/beat/web/reports/static/reports/test/report-spec.js @@ -495,7 +495,8 @@ describe('reports app', function(){ }); it('removes the exp table', function(){ - expect(g1ExpPanel.getText()).toBe(''); + const explistPanel = element(by.css('#collapse-group1-explist > .panel-body')); + expect(explistPanel.getText()).toBe(''); }); it('removes the analyzer tag', function() { @@ -525,28 +526,43 @@ describe('reports app', function(){ describe('adding a plot', function() { beforeAll(function() { // add plot here + const addButton = element(by.partialButtonText('Add Plot')); + return addButton.click() + .then(() => { + const parent = addButton.element(by.xpath('..')); + const firstPlotLi = parent.element(by.css('ul > li')); + return firstPlotLi.click(); + }) + ; }); it('adds a plot', function() { - + const plotContainer = element(by.css('#collapse-group1_plot_0')); + expect(plotContainer.isDisplayed()).toBeTruthy(); }); it('eventually renders the plot', function() { + const plotContainer = element(by.css('#collapse-group1_plot_0 > .panel-body > div')); + + browser.wait(until.presenceOf(plotContainer.element(by.css('img'))), + 5000, 'Plot render hasnt been inserted in Angular for 5s'); + const img = plotContainer.element(by.css('img')); + expect(img.isDisplayed()).toBeTruthy(); }); }); describe('removing a plot', function() { beforeAll(function() { // rm plot here - }); - - it('removes the plot', function() { + const delButton = element(by.css('#group1_plot_0-heading .btn-delete')); + return delButton.click(); }); - it('has no report items now', function() { - + it('removes the plot and has no report items', function() { + const groupBodyChildren = element(by.model('group._reportItems')).all(by.css('*')); + expect(groupBodyChildren.count()).toBe(0); }); }); }); @@ -555,48 +571,66 @@ describe('reports app', function(){ describe('adding a table', function() { beforeAll(function() { // add table here + const addButton = element(by.partialButtonText('Add Table')); + return addButton.click(); }); it('adds a table', function() { - - }); - - it('has at least one column', function() { - - }); - - it('has a default precision of 10', function() { - + const tableContainer = element(by.css('#collapse-group1_table_0 .panel-body')); + expect(tableContainer.isDisplayed()).toBeTruthy(); }); - it('has enabled button for choosing columns', function() { + describe('layout', function() { + const panelHeaderButtonGroup = element.all(by.css('#group1_table_0-heading > h4 > .btn-group')).get(1); + const colsButton = panelHeaderButtonGroup.element(by.css('#group1_table_0_columnSelector')); + const precButton = panelHeaderButtonGroup.element(by.css('#group1_table_0-precision')); + const tcsvButton = panelHeaderButtonGroup.element(by.buttonText('Toggle CSV View')); - }); + const table = element(by.css('#collapse-group1_table_0 table')); + const headers = table.all(by.css('thead > tr > th')); + const rows = table.all(by.css('tbody > tr')); - it('has enabled button for choosing precision', function() { + it('has at least one column for the name of the experiments', function() { + expect(headers.count()).toBeGreaterThan(0); + expect(headers.get(0).element(by.css('a')).getText()).toContain('Experiment'); + }); - }); + it('has a default precision of 10', function() { + expect(precButton.getText()).toBe('Float Precision: 10'); + }); - it('has enabled button for toggling the csv view', function() { + it('has enabled button for choosing columns', function() { + expect(colsButton.getAttribute('disabled')).toBeNull(); + }); - }); + it('has enabled button for choosing precision', function() { + expect(precButton.getAttribute('disabled')).toBeNull(); + }); - it('has 1 row with the name col matching the alias', function() { + it('has enabled button for toggling the csv view', function() { + expect(tcsvButton.getAttribute('disabled')).toBeNull(); + }); + it('has 1 row with the name col matching the alias', function() { + const pName = rows.get(0).element(by.css('td')).getText(); + const pCurrAlias = element(by.css('#collapse-group1-explist table > tbody input')).getAttribute('value'); + Promise.all([pName, pCurrAlias]) + .then(([name, currAlias]) => expect(name).toBe(currAlias)); + }); }); }); describe('removing a table', function() { beforeAll(function() { // rm table here - }); - - it('removes the table', function() { + const delButton = element(by.css('#group1_table_0-heading .btn-delete')); + return delButton.click(); }); - it('has no report items now', function() { - + it('removes the table and has no report items', function() { + const groupBodyChildren = element(by.model('group._reportItems')).all(by.css('*')); + expect(groupBodyChildren.count()).toBe(0); }); }); }); @@ -605,32 +639,37 @@ describe('reports app', function(){ describe('adding a text block', function() { beforeAll(function(){ // add text block here + const addButton = element(by.partialButtonText('Add Text Block')); + return addButton.click(); }); it('added a text block to the group', function() { - + const textContainer = element(by.css('#collapse-group1_text_0 .panel-body')); + expect(textContainer.isDisplayed()).toBeTruthy(); }); it('is blank/empty', function() { - + const emptyContainer = element(by.css('#collapse-group1_text_0 > .panel-body > .row > .col-sm-10 > div')); + expect(emptyContainer.getText()).toBe(''); }); it('shows the "edit" button', function() { - + const editButton = element(by.css('#collapse-group1_text_0 > .panel-body > .row > .col-sm-2 > div > a')); + expect(editButton.getText()).toContain('Edit'); }); }); describe('removing a text block', function() { beforeAll(function() { - // rm text block here - }); - - it('removed a text block from the group', function() { + // rm text here + const delButton = element(by.css('#group1_text_0-heading .btn-delete')); + return delButton.click(); }); - it('has no report items now', function() { - + it('removes the text and has no report items', function() { + const groupBodyChildren = element(by.model('group._reportItems')).all(by.css('*')); + expect(groupBodyChildren.count()).toBe(0); }); }); }); -- GitLab