Skip to content

Commit

Permalink
updated workbench flakey test to match gitfram (#1741)
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy authored Feb 27, 2025
1 parent 5504f1e commit 3019e88
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 56 deletions.
81 changes: 54 additions & 27 deletions cypress/integration/plugins/query-workbench-dashboards/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
* SPDX-License-Identifier: Apache-2.0
*/


/// <reference types="cypress" />

import { edit } from 'brace';
import { delay, files, testDataSet, testQueries, verifyDownloadData } from '../../../utils/constants';
import {
delay,
files,
testDataSet,
testQueries,
verifyDownloadData,
} from '../../../utils/constants';

describe('Dump test data', () => {
it('Indexes test data for SQL and PPL', () => {
Expand All @@ -29,7 +34,7 @@ describe('Dump test data', () => {
});
});

testDataSet.forEach(({url, index}) => dumpDataSet(url, index));
testDataSet.forEach(({ url, index }) => dumpDataSet(url, index));
});
});

Expand All @@ -48,21 +53,23 @@ describe('Test PPL UI', () => {
});

it('Test Run button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('source=accounts | sort firstname', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiTab__content').contains('Events').click({ force: true });

cy.get('span.euiTableCellContent__text')
.eq(19)
.should((employer) => {
expect(employer).to.contain('Pyrami');
});
cy.contains('Abbott');
});

it('Test Clear button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('source=accounts', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
Expand All @@ -86,11 +93,16 @@ describe('Test PPL UI', () => {
cy.get('.euiButton__text').contains('Full screen view').should('not.exist');
cy.get('.euiTitle').contains('Query Workbench').should('exist');

cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('source=accounts', { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').click({ force: true });
cy.get('.euiButton__text')
.contains('Full screen view')
.click({ force: true });

cy.get('.euiTitle').should('not.exist');

Expand Down Expand Up @@ -119,7 +131,9 @@ describe('Test SQL UI', () => {
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{enter}select * from accounts where balance > 49500;', { force: true });
.type('{enter}select * from accounts where balance > 49500;', {
force: true,
});
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
Expand All @@ -134,14 +148,20 @@ describe('Test SQL UI', () => {
});

it('Test Translate button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{selectall}{backspace}', { force: true });
cy.wait(delay);
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{selectall}{backspace}select log(balance) from accounts where abs(age) > 20;', {
force: true,
});
.type(
'{selectall}{backspace}select log(balance) from accounts where abs(age) > 20;',
{
force: true,
}
);
cy.wait(delay);
cy.get('.euiButton__text').contains('Explain').click({ force: true });
cy.wait(delay);
Expand All @@ -168,7 +188,9 @@ describe('Test SQL UI', () => {

cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').click({ force: true });
cy.get('.euiButton__text')
.contains('Full screen view')
.click({ force: true });

cy.get('.euiTitle').should('not.exist');
});
Expand All @@ -186,10 +208,14 @@ describe('Test and verify SQL downloads', () => {
'osd-xsrf': true,
},
body: {
query: 'select * from accounts where balance > 49500',
query:
'select * from accounts where balance > 49500 order by account_number',
},
}).then((response) => {
if (title === 'Download and verify CSV' || title === 'Download and verify Text') {
if (
title === 'Download and verify CSV' ||
title === 'Download and verify Text'
) {
expect(response.body.data.body).to.have.string(files[file]);
} else {
expect(response.body.data.resp).to.have.string(files[file]);
Expand All @@ -205,7 +231,10 @@ describe('Test table display', () => {
cy.wait(delay);
cy.get('.euiToggle__input[title=SQL]').click({ force: true });
cy.wait(delay);
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}', { force: true });
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type('{selectall}{backspace}', { force: true });
cy.wait(delay);
});

Expand All @@ -231,17 +260,15 @@ describe('Test table display', () => {
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type(`{selectall}{backspace}select * from employee_nested;`, { force: true });
.type(`{selectall}{backspace}select * from employee_nested;`, {
force: true,
});
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);

cy.get('button.euiLink').eq(2).click({ force: true });
cy.wait(delay);
cy.get('span.euiTableCellContent__text')
.eq(24)
.should((cell) => {
expect(cell).to.contain('comment_2_1');
});
cy.contains('message');
});
});
55 changes: 26 additions & 29 deletions cypress/utils/plugins/query-workbench-dashboards/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


export const delay = 1000;

export const testDataSet = [
Expand All @@ -13,30 +12,30 @@ export const testDataSet = [
},
{
url: 'https://raw.githubusercontent.com/opensearch-project/sql/main/integ-test/src/test/resources/employee_nested.json',
index: 'employee_nested'
}
]
index: 'employee_nested',
},
];

export const verifyDownloadData = [
{
title: 'Download and verify JSON',
url: 'api/sql_console/sqljson',
file: 'JSONFile'
file: 'JSONFile',
},
{
title: 'Download and verify JDBC',
url: 'api/sql_console/sqlquery',
file: 'JDBCFile'
file: 'JDBCFile',
},
{
title: 'Download and verify CSV',
url: 'api/sql_console/sqlcsv',
file: 'CSVFile'
file: 'CSVFile',
},
{
title: 'Download and verify Text',
url: 'api/sql_console/sqltext',
file: 'TextFile'
file: 'TextFile',
},
];

Expand All @@ -45,55 +44,53 @@ export const testQueries = [
title: 'Test GROUP BY',
query: 'select count(*) from accounts group by gender;',
cell_idx: 3,
expected_string: '493'
expected_string: '493',
},
{
title: 'Test GROUP BY with aliases and scalar function',
query: 'SELECT ABS(age) AS a FROM accounts GROUP BY ABS(age);',
cell_idx: 17,
expected_string: '27'
expected_string: '27',
},
{
title: 'Test GROUP BY and HAVING',
query: 'SELECT age, MAX(balance) FROM accounts GROUP BY age HAVING MIN(balance) > 3000;',
query:
'SELECT age, MAX(balance) FROM accounts GROUP BY age HAVING MIN(balance) > 3000;',
cell_idx: 5,
expected_string: '49119'
expected_string: '49119',
},
{
title: 'Test ORDER BY',
query: 'SELECT account_number FROM accounts ORDER BY account_number DESC;',
cell_idx: 5,
expected_string: '998'
expected_string: '998',
},
{
title: 'Test JOIN',
query: 'select a.account_number, a.firstname, a.lastname, e.id, e.name from accounts a join employee_nested e order by a.account_number;',
query:
'select a.account_number, a.firstname, a.lastname, e.id, e.name from accounts a join employee_nested e order by a.account_number;',
cell_idx: 45,
expected_string: 'Duke'
expected_string: 'Duke',
},
];

export const files = {
JSONFile:
`"hits":[{"_index":"accounts","_type":"_doc","_id":"842","_score":0,"_source":{"account_number":842,"balance":49587,"firstname":"Meagan","lastname":"Buckner","age":23,"gender":"F","address":"833 Bushwick Court","employer":"Biospan","email":"[email protected]","city":"Craig","state":"TX"}},{"_index":"accounts","_type":"_doc","_id":"854","_score":0,"_source":{"account_number":854,"balance":49795,"firstname":"Jimenez","lastname":"Barry","age":25,"gender":"F","address":"603 Cooper Street","employer":"Verton","email":"[email protected]","city":"Moscow","state":"AL"}},{"_index":"accounts","_type":"_doc","_id":"97","_score":0,"_source":{"account_number":97,"balance":49671,"firstname":"Karen","lastname":"Trujillo","age":40,"gender":"F","address":"512 Cumberland Walk","employer":"Tsunamia","email":"[email protected]","city":"Fredericktown","state":"MO"}},{"_index":"accounts","_type":"_doc","_id":"168","_score":0,"_source":{"account_number":168,"balance":49568,"firstname":"Carissa","lastname":"Simon","age":20,"gender":"M","address":"975 Flatbush Avenue","employer":"Zillacom","email":"[email protected]","city":"Neibert","state":"IL"}},{"_index":"accounts","_type":"_doc","_id":"240","_score":0,"_source":{"account_number":240,"balance":49741,"firstname":"Oconnor","lastname":"Clay","age":35,"gender":"F","address":"659 Highland Boulevard","employer":"Franscene","email":"[email protected]","city":"Kilbourne","state":"NH"}},{"_index":"accounts","_type":"_doc","_id":"803","_score":0,"_source":{"account_number":803,"balance":49567,"firstname":"Marissa","lastname":"Spears","age":25,"gender":"M","address":"963 Highland Avenue","employer":"Centregy","email":"[email protected]","city":"Bloomington","state":"MS"}},{"_index":"accounts","_type":"_doc","_id":"248","_score":0,"_source":{"account_number":248,"balance":49989,"firstname":"West","lastname":"England","age":36,"gender":"M","address":"717 Hendrickson Place","employer":"Obliq","email":"[email protected]","city":"Maury","state":"WA"}}]`,
JDBCFile:
`{"schema":[{"name":"account_number","type":"long"},{"name":"firstname","type":"text"},{"name":"address","type":"text"},{"name":"balance","type":"long"},{"name":"gender","type":"text"},{"name":"city","type":"text"},{"name":"employer","type":"text"},{"name":"state","type":"text"},{"name":"age","type":"long"},{"name":"email","type":"text"},{"name":"lastname","type":"text"}],"datarows":[[842,"Meagan","833 Bushwick Court",49587,"F","Craig","Biospan","TX",23,"[email protected]","Buckner"],[854,"Jimenez","603 Cooper Street",49795,"F","Moscow","Verton","AL",25,"[email protected]","Barry"],[97,"Karen","512 Cumberland Walk",49671,"F","Fredericktown","Tsunamia","MO",40,"[email protected]","Trujillo"],[168,"Carissa","975 Flatbush Avenue",49568,"M","Neibert","Zillacom","IL",20,"[email protected]","Simon"],[240,"Oconnor","659 Highland Boulevard",49741,"F","Kilbourne","Franscene","NH",35,"[email protected]","Clay"],[803,"Marissa","963 Highland Avenue",49567,"M","Bloomington","Centregy","MS",25,"[email protected]","Spears"],[248,"West","717 Hendrickson Place",49989,"M","Maury","Obliq","WA",36,"[email protected]","England"]],"total":7,"size":7,"status":200}`,
CSVFile:
`account_number,firstname,address,balance,gender,city,employer,state,age,email,lastname
842,Meagan,833 Bushwick Court,49587,F,Craig,Biospan,TX,23,[email protected],Buckner
854,Jimenez,603 Cooper Street,49795,F,Moscow,Verton,AL,25,[email protected],Barry
JSONFile: `[{"_index":"accounts","_type":"_doc","_id":"97","_score":null,"_source":{"account_number":97,"balance":49671,"firstname":"Karen","lastname":"Trujillo","age":40,"gender":"F","address":"512 Cumberland Walk","employer":"Tsunamia","email":"[email protected]","city":"Fredericktown","state":"MO"},"sort":[97]},{"_index":"accounts","_type":"_doc","_id":"168","_score":null,"_source":{"account_number":168,"balance":49568,"firstname":"Carissa","lastname":"Simon","age":20,"gender":"M","address":"975 Flatbush Avenue","employer":"Zillacom","email":"[email protected]","city":"Neibert","state":"IL"},"sort":[168]},{"_index":"accounts","_type":"_doc","_id":"240","_score":null,"_source":{"account_number":240,"balance":49741,"firstname":"Oconnor","lastname":"Clay","age":35,"gender":"F","address":"659 Highland Boulevard","employer":"Franscene","email":"[email protected]","city":"Kilbourne","state":"NH"},"sort":[240]},{"_index":"accounts","_type":"_doc","_id":"248","_score":null,"_source":{"account_number":248,"balance":49989,"firstname":"West","lastname":"England","age":36,"gender":"M","address":"717 Hendrickson Place","employer":"Obliq","email":"[email protected]","city":"Maury","state":"WA"},"sort":[248]},{"_index":"accounts","_type":"_doc","_id":"803","_score":null,"_source":{"account_number":803,"balance":49567,"firstname":"Marissa","lastname":"Spears","age":25,"gender":"M","address":"963 Highland Avenue","employer":"Centregy","email":"[email protected]","city":"Bloomington","state":"MS"},"sort":[803]},{"_index":"accounts","_type":"_doc","_id":"842","_score":null,"_source":{"account_number":842,"balance":49587,"firstname":"Meagan","lastname":"Buckner","age":23,"gender":"F","address":"833 Bushwick Court","employer":"Biospan","email":"[email protected]","city":"Craig","state":"TX"},"sort":[842]},{"_index":"accounts","_type":"_doc","_id":"854","_score":null,"_source":{"account_number":854,"balance":49795,"firstname":"Jimenez","lastname":"Barry","age":25,"gender":"F","address":"603 Cooper Street","employer":"Verton","email":"[email protected]","city":"Moscow","state":"AL"},"sort":[854]}]`,
JDBCFile: `{"schema":[{"name":"account_number","type":"long"},{"name":"firstname","type":"text"},{"name":"address","type":"text"},{"name":"balance","type":"long"},{"name":"gender","type":"text"},{"name":"city","type":"text"},{"name":"employer","type":"text"},{"name":"state","type":"text"},{"name":"age","type":"long"},{"name":"email","type":"text"},{"name":"lastname","type":"text"}],"datarows":[[97,"Karen","512 Cumberland Walk",49671,"F","Fredericktown","Tsunamia","MO",40,"[email protected]","Trujillo"],[168,"Carissa","975 Flatbush Avenue",49568,"M","Neibert","Zillacom","IL",20,"[email protected]","Simon"],[240,"Oconnor","659 Highland Boulevard",49741,"F","Kilbourne","Franscene","NH",35,"[email protected]","Clay"],[248,"West","717 Hendrickson Place",49989,"M","Maury","Obliq","WA",36,"[email protected]","England"],[803,"Marissa","963 Highland Avenue",49567,"M","Bloomington","Centregy","MS",25,"[email protected]","Spears"],[842,"Meagan","833 Bushwick Court",49587,"F","Craig","Biospan","TX",23,"[email protected]","Buckner"],[854,"Jimenez","603 Cooper Street",49795,"F","Moscow","Verton","AL",25,"[email protected]","Barry"]],"total":7,"size":7,"status":200}`,
CSVFile: `account_number,firstname,address,balance,gender,city,employer,state,age,email,lastname
97,Karen,512 Cumberland Walk,49671,F,Fredericktown,Tsunamia,MO,40,[email protected],Trujillo
168,Carissa,975 Flatbush Avenue,49568,M,Neibert,Zillacom,IL,20,[email protected],Simon
240,Oconnor,659 Highland Boulevard,49741,F,Kilbourne,Franscene,NH,35,[email protected],Clay
248,West,717 Hendrickson Place,49989,M,Maury,Obliq,WA,36,[email protected],England
803,Marissa,963 Highland Avenue,49567,M,Bloomington,Centregy,MS,25,[email protected],Spears
248,West,717 Hendrickson Place,49989,M,Maury,Obliq,WA,36,[email protected],England`,
TextFile:
`account_number|firstname|address|balance|gender|city|employer|state|age|email|lastname
842|Meagan|833 Bushwick Court|49587|F|Craig|Biospan|TX|23|[email protected]|Buckner
854|Jimenez|603 Cooper Street|49795|F|Moscow|Verton|AL|25|[email protected]|Barry
842,Meagan,833 Bushwick Court,49587,F,Craig,Biospan,TX,23,[email protected],Buckner
854,Jimenez,603 Cooper Street,49795,F,Moscow,Verton,AL,25,[email protected],Barry`,
TextFile: `account_number|firstname|address|balance|gender|city|employer|state|age|email|lastname
97|Karen|512 Cumberland Walk|49671|F|Fredericktown|Tsunamia|MO|40|[email protected]|Trujillo
168|Carissa|975 Flatbush Avenue|49568|M|Neibert|Zillacom|IL|20|[email protected]|Simon
240|Oconnor|659 Highland Boulevard|49741|F|Kilbourne|Franscene|NH|35|[email protected]|Clay
248|West|717 Hendrickson Place|49989|M|Maury|Obliq|WA|36|[email protected]|England
803|Marissa|963 Highland Avenue|49567|M|Bloomington|Centregy|MS|25|[email protected]|Spears
248|West|717 Hendrickson Place|49989|M|Maury|Obliq|WA|36|[email protected]|England`,
842|Meagan|833 Bushwick Court|49587|F|Craig|Biospan|TX|23|[email protected]|Buckner
854|Jimenez|603 Cooper Street|49795|F|Moscow|Verton|AL|25|[email protected]|Barry`,
};

0 comments on commit 3019e88

Please sign in to comment.