williaster commented on a change in pull request #5974: [cypress] add SQL lab 
tests
URL: 
https://github.com/apache/incubator-superset/pull/5974#discussion_r220643177
 
 

 ##########
 File path: superset/assets/cypress/integration/sqllab/query.js
 ##########
 @@ -0,0 +1,125 @@
+import shortid from 'shortid';
+import { selectResultsTab } from '../../selectors';
+
+// this function asserts that the result set for two SQL lab table results are 
equal
+const assertSQLLabResultsAreEqual = (resultsA, resultsB) => {
+  const [headerA, bodyWrapperA] = resultsA.childNodes;
+  const bodyA = bodyWrapperA.childNodes[0];
+
+  const [headerB, bodyWrapperB] = resultsB.childNodes;
+  const bodyB = bodyWrapperB.childNodes[0];
+
+  expect(headerA.childNodes.length).to.equal(headerB.childNodes.length);
+  expect(bodyA.childNodes.length).to.equal(bodyB.childNodes.length);
+
+  bodyA.childNodes.forEach((rowA, rowIndex) => {
+    const rowB = bodyB.childNodes[rowIndex];
+
+    rowA.childNodes.forEach((cellA, columnIndex) => {
+      const cellB = rowB.childNodes[columnIndex];
+      expect(cellA.innerText).to.equal(cellB.innerText);
+    });
+  });
+};
+
+describe('SqlLab query panel', () => {
+  beforeEach(() => {
+    cy.login();
+    cy.server();
+    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)
 
 Review comment:
   takes the first element, generalized version of `first()` or `last()`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to