From 75beeeed27cecab02397a0b29669eb61125f4e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Fri, 29 Sep 2023 17:14:00 +0200 Subject: [PATCH] E2E: Move mysql test to various suite (#75221) * E2E: Move mysql test to various suite * Decide command key based on platform --- .../fixtures}/datasets-response.json | 0 .../fixtures}/fields-response.json | 0 .../fixtures}/tables-response.json | 0 .../mysql.spec.ts | 50 +++++++++---------- 4 files changed, 23 insertions(+), 27 deletions(-) rename e2e/{sql-suite => various-suite/fixtures}/datasets-response.json (100%) rename e2e/{sql-suite => various-suite/fixtures}/fields-response.json (100%) rename e2e/{sql-suite => various-suite/fixtures}/tables-response.json (100%) rename e2e/{sql-suite => various-suite}/mysql.spec.ts (64%) diff --git a/e2e/sql-suite/datasets-response.json b/e2e/various-suite/fixtures/datasets-response.json similarity index 100% rename from e2e/sql-suite/datasets-response.json rename to e2e/various-suite/fixtures/datasets-response.json diff --git a/e2e/sql-suite/fields-response.json b/e2e/various-suite/fixtures/fields-response.json similarity index 100% rename from e2e/sql-suite/fields-response.json rename to e2e/various-suite/fixtures/fields-response.json diff --git a/e2e/sql-suite/tables-response.json b/e2e/various-suite/fixtures/tables-response.json similarity index 100% rename from e2e/sql-suite/tables-response.json rename to e2e/various-suite/fixtures/tables-response.json diff --git a/e2e/sql-suite/mysql.spec.ts b/e2e/various-suite/mysql.spec.ts similarity index 64% rename from e2e/sql-suite/mysql.spec.ts rename to e2e/various-suite/mysql.spec.ts index 3c1c1f7fa44..6ef2502d87b 100644 --- a/e2e/sql-suite/mysql.spec.ts +++ b/e2e/various-suite/mysql.spec.ts @@ -1,8 +1,8 @@ import { e2e } from '../utils'; -import datasetResponse from './datasets-response.json'; -import fieldsResponse from './fields-response.json'; -import tablesResponse from './tables-response.json'; +import datasetResponse from './fixtures/datasets-response.json'; +import fieldsResponse from './fixtures/fields-response.json'; +import tablesResponse from './fixtures/tables-response.json'; const tableNameWithSpecialCharacter = tablesResponse.results.tables.frames[0].data.values[0][1]; const normalTableName = tablesResponse.results.tables.frames[0].data.values[0][0]; @@ -13,30 +13,24 @@ describe('MySQL datasource', () => { }); it('code editor autocomplete should handle table name escaping/quoting', () => { - cy.intercept( - 'POST', - { - pathname: '/api/ds/query', - }, - (req) => { - if (req.body.queries[0].refId === 'datasets') { - req.alias = 'datasets'; - req.reply({ - body: datasetResponse, - }); - } else if (req.body.queries[0].refId === 'tables') { - req.alias = 'tables'; - req.reply({ - body: tablesResponse, - }); - } else if (req.body.queries[0].refId === 'fields') { - req.alias = 'fields'; - req.reply({ - body: fieldsResponse, - }); - } + cy.intercept('POST', '/api/ds/query', (req) => { + if (req.body.queries[0].refId === 'datasets') { + req.alias = 'datasets'; + req.reply({ + body: datasetResponse, + }); + } else if (req.body.queries[0].refId === 'tables') { + req.alias = 'tables'; + req.reply({ + body: tablesResponse, + }); + } else if (req.body.queries[0].refId === 'fields') { + req.alias = 'fields'; + req.reply({ + body: fieldsResponse, + }); } - ); + }); e2e.pages.Explore.visit(); @@ -56,7 +50,9 @@ describe('MySQL datasource', () => { ); cy.get('textarea').type(deleteTimes.join('')); - cy.get('textarea').type('{command}i'); + const commandKey = Cypress.platform === 'darwin' ? '{command}' : '{ctrl}'; + + cy.get('textarea').type(`${commandKey}i`); cy.get('.suggest-widget').contains(tableNameWithSpecialCharacter).should('be.visible'); cy.get('textarea').type('S{downArrow}{enter}'); cy.get('textarea').should('have.value', `SELECT FROM grafana.${normalTableName}`);