You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/17 00:32:09 UTC

[GitHub] [superset] ktmud commented on a diff in pull request #21105: fix(sqllab): Enable cypress specs for sqllab query

ktmud commented on code in PR #21105:
URL: https://github.com/apache/superset/pull/21105#discussion_r947350589


##########
superset-frontend/cypress-base/cypress/integration/sqllab/query.test.ts:
##########
@@ -17,144 +17,343 @@
  * under the License.
  */
 import * as shortid from 'shortid';
-import { selectResultsTab, assertSQLLabResultsAreEqual } from './sqllab.helper';
-
-function parseClockStr(node: JQuery) {
-  return Number.parseFloat(node.text().replace(/:/g, ''));
-}
+import { selectResultsTab } from './sqllab.helper';
 
 describe('SqlLab query panel', () => {
+  const mockTabId = '88889999';
+  const mockQueryId = 'mock_qid_28dvde';
+
   beforeEach(() => {
+    cy.intercept('/tableschemaview/', {
+      id: 1,
+    }).as('mockTableSchemaView');
+    cy.intercept('/tabstate/', {
+      id: 1,
+    }).as('mockTabStateView');
+    cy.intercept('GET', '/api/v1/database/?q=**', req => {
+      req.continue(res => {
+        res.send({ fixture: 'sqllab_databases.json' });
+      });
+    }).as('mockDatabaseList');
+    cy.intercept('GET', '/api/v1/database/*/function_names/', {
+      function_names: [],
+    }).as('mockFunctionNameList');
+    cy.intercept(
+      {
+        method: 'GET',
+        url: '/api/v1/database/*/schemas/?q=*',
+      },
+      {
+        result: ['mock'],
+      },
+    ).as('mockSchemaList');
+    cy.intercept(
+      {
+        method: 'POST',
+        url: '/superset/sql_json/',
+      },
+      req => {
+        req.reply({
+          delay: 800,
+          fixture: 'sqllab_sql_json.json',
+        });
+      },
+    ).as('mockSQLResponse');
+    cy.intercept('GET', '/superset/tables/1/**', {
+      fixture: 'sqllab_tables.json',
+    }).as('mockTableList');
+    cy.intercept('GET', '/api/v1/database/1/table/mock_table_1/*/', req => {
+      req.reply({
+        fixture: 'sqllab_table_1.json',
+        delay: 500,
+      });
+    }).as('mockTable1Schema');
+    cy.intercept('GET', '/api/v1/database/1/table_extra/mock_table_1/*/', {
+      body: {},
+    }).as('mockTable1SchemaExtra');
+    cy.intercept('GET', '/superset/queries/*', {
+      fixture: 'sqllab_queries_progress1.json',
+    });
+    cy.intercept('POST', 'tabstateview', {
+      id: mockTabId,
+    }).as('mockTabCreate');
+    cy.intercept('PUT', `tabstateview/*`, req => {
+      req.reply({
+        id: req.url.match(/\d+$/)?.[0],
+      });
+    }).as('mockTabUpdate');
+    cy.intercept('DELETE', `tabstateview/*`, req => {
+      req.reply({
+        id: req.url.match(/\d+$/)?.[0],
+      });
+    }).as('mockTabDelete');

Review Comment:
   Can these fixture setup be put in some kind of utils function so it can be shared with other tests in SQL Lab (suppose we will have more)?



##########
superset-frontend/cypress-base/cypress/fixtures/sqllab_tables.json:
##########
@@ -0,0 +1,29 @@
+{

Review Comment:
   Can these JSON files be typed JavaScript objects instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org