This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--sqllab-cypress
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/chris--sqllab-cypress by this
push:
new 83a7bfd [cypress] add tests for SQL Lab tabs
83a7bfd is described below
commit 83a7bfd972e28a16bf3a75730cc5acb43da9c105
Author: Chris Williams <[email protected]>
AuthorDate: Tue Sep 25 22:44:23 2018 -0700
[cypress] add tests for SQL Lab tabs
---
.../assets/cypress/integration/sqllab/query.js | 63 +++++++++++-----------
superset/assets/cypress/integration/sqllab/tabs.js | 42 +++++++++++++++
2 files changed, 73 insertions(+), 32 deletions(-)
diff --git a/superset/assets/cypress/integration/sqllab/query.js
b/superset/assets/cypress/integration/sqllab/query.js
index 73d71bb..d2e3768 100644
--- a/superset/assets/cypress/integration/sqllab/query.js
+++ b/superset/assets/cypress/integration/sqllab/query.js
@@ -29,34 +29,34 @@ describe('SqlLab query panel', () => {
cy.visit('/superset/sqllab');
});
- // it('supports entering and running a query', () => {
- // // note that the limit has to be < ~10 for us to be able to determine
- // // how many rows are below (because React _Virtualized_ does not render
all rows)
- // const rowLimit = 3;
- //
- // cy.get('#brace-editor textarea')
- // .type(
- // `{selectall}{backspace}SELECT ds, gender, name, num FROM
main.birth_names LIMIT ${rowLimit}`,
- // { force: true },
- // )
- // .then(() => {
- // cy.get('#js-sql-toolbar button')
- // .eq(0)
- // .click()
- // .then(() => {
- // cy.get('.SouthPane .ReactVirtualized__Table')
- // .eq(0) // ensures results tab in case preview tab exists
- // .then((tableNodes) => {
- // const [header, bodyWrapper] = tableNodes[0].childNodes;
- // const body = bodyWrapper.childNodes[0];
- // const expectedColCount = header.childNodes.length;
- // const expectedRowCount = body.childNodes.length;
- // expect(expectedColCount).to.equal(4);
- // expect(expectedRowCount).to.equal(rowLimit);
- // });
- // });
- // });
- // });
+ it('supports entering and running a query', () => {
+ // note that the limit has to be < ~10 for us to be able to determine
+ // how many rows are below (because React _Virtualized_ does not render
all rows)
+ const rowLimit = 3;
+
+ cy.get('#brace-editor textarea')
+ .type(
+ `{selectall}{backspace}SELECT ds, gender, name, num FROM
main.birth_names LIMIT ${rowLimit}`,
+ { force: true },
+ )
+ .then(() => {
+ cy.get('#js-sql-toolbar button')
+ .eq(0)
+ .click()
+ .then(() => {
+ cy.get('.SouthPane .ReactVirtualized__Table')
+ .eq(0) // ensures results tab in case preview tab exists
+ .then((tableNodes) => {
+ const [header, bodyWrapper] = tableNodes[0].childNodes;
+ const body = bodyWrapper.childNodes[0];
+ const expectedColCount = header.childNodes.length;
+ const expectedRowCount = body.childNodes.length;
+ expect(expectedColCount).to.equal(4);
+ expect(expectedRowCount).to.equal(rowLimit);
+ });
+ });
+ });
+ });
it('successfully saves a query', () => {
const query = 'SELECT ds, gender, name, num FROM main.birth_names ORDER BY
name LIMIT 3';
@@ -78,7 +78,6 @@ describe('SqlLab query panel', () => {
selectResultsTab().then((resultsA) => {
// Save results to check agains below
initialResultsTable = resultsA[0];
- console.log('initialResultsTable', initialResultsTable);
cy.get('#js-sql-toolbar button')
.eq(1) // save query
@@ -91,7 +90,7 @@ describe('SqlLab query panel', () => {
})
.then(() => {
cy.get('.modal-sm .modal-body button')
- .eq(0)
+ .eq(0) // save
.click()
.then(() => {
// visit saved queries
@@ -102,7 +101,7 @@ describe('SqlLab query panel', () => {
.click()
.then(() => {
cy.get('#js-sql-toolbar button')
- .eq(0) // Run query
+ .eq(0) // run query
.click()
.then(() => {
selectResultsTab().then((resultsB) => {
@@ -120,7 +119,7 @@ describe('SqlLab query panel', () => {
});
});
});
- }); // run query
+ });
});
});
});
diff --git a/superset/assets/cypress/integration/sqllab/tabs.js
b/superset/assets/cypress/integration/sqllab/tabs.js
new file mode 100644
index 0000000..52ba0d1
--- /dev/null
+++ b/superset/assets/cypress/integration/sqllab/tabs.js
@@ -0,0 +1,42 @@
+describe('SqlLab query tabs', () => {
+ beforeEach(() => {
+ cy.login();
+ cy.server();
+ cy.visit('/superset/sqllab');
+ });
+
+ it('allows you to create a tab', () => {
+ cy.get('#a11y-query-editor-tabs > ul > li').then((tabList) => {
+ const initialTabCount = tabList.length;
+
+ // add tab
+ cy.get('#a11y-query-editor-tabs > ul > li')
+ .last()
+ .click()
+ .then(() => {
+ cy.get('#a11y-query-editor-tabs > ul > li').should('have.length',
initialTabCount + 1);
+ });
+ });
+ });
+
+ it('allows you to close a tab', () => {
+ cy.get('#a11y-query-editor-tabs > ul > li').then((tabListA) => {
+ const initialTabCount = tabListA.length;
+
+ // open the tab dropdown
+ cy.get('#a11y-query-editor-tabs > ul > li:first button')
+ .click()
+ .then(() => {
+ cy.get('#a11y-query-editor-tabs > ul > li:first ul li a')
+ .eq(0) // first is close
+ .click()
+ .then(() => {
+ cy.get('#a11y-query-editor-tabs > ul > li').should(
+ 'have.length',
+ initialTabCount - 1,
+ );
+ });
+ });
+ });
+ });
+});