Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jest tests #255

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
cypress tests
Signed-off-by: sumukhswamy <sumukhhs@amazon.com>
sumukhswamy committed Feb 6, 2024
commit 80c9f765889bfb3105bac2313e00c9d69a0a1038
173 changes: 60 additions & 113 deletions .cypress/integration/ui.spec.js
Original file line number Diff line number Diff line change
@@ -29,15 +29,15 @@ describe('Dump test data', () => {
});
});

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

describe('Test PPL UI', () => {
beforeEach(() => {
cy.visit('app/opensearch-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=PPL]').click({ force: true });
cy.get('[data-test-subj="PPL"]').click({ force: true });
sumukhswamy marked this conversation as resolved.
Show resolved Hide resolved
cy.wait(delay);
});

@@ -48,64 +48,42 @@ describe('Test PPL UI', () => {
});

it('Test Run button', () => {
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('.euiTab__content').contains('Events').click({ force: true });

cy.get('span.euiTableCellContent__text')
.eq(19)
.should((employer) => {
expect(employer).to.contain('Pyrami');
});
cy.get('textarea.ace_text-input').eq(0).focus().type('source=accounts', { force: true }).then(()=>{
cy.get('.ace_line').contains('source=accounts')
}).then(()=>{
cy.wait(1000)
cy.get('button[data-test-subj="pplRunButton"]').click({ force: true });
}).then(() => {
cy.get('[data-test-subj="result_tab"]').contains('Events').click({ force: true });
});
});

it('Test Clear button', () => {
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('.euiTab__content').contains('Events').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Clear').click({ force: true });
cy.wait(delay);
cy.get('[data-test-subj="pplClearButton"]').contains('Clear').click({ force: true });

cy.get('.euiTextAlign')
.contains('Enter a query in the query editor above to see results.')
.should('have.length', 1);
cy.get('.ace_content')
.eq(0)
.then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
cy.get('.euiTitle').should('not.exist');
});

it('Test full screen view', () => {
cy.get('[data-test-subj="pplClearButton"]').contains('Clear').click({ force: true });
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.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('[data-test-subj="pplRunButton"]').contains('Run').should('exist');
cy.wait(1000)
cy.get('[data-test-subj="pplRunButton"]').contains('Run').click({ force: true });

cy.get('.euiTitle').should('not.exist');
cy.get('[data-test-subj="fullScreenView"]').contains('Full screen view').click();

cy.get('button#exit-fullscreen-button').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Full screen view').should('exist');
cy.get('.euiTitle').contains('Query Workbench').should('exist');
cy.get('.euiTitle').should('not.exist');
});
});

describe('Test SQL UI', () => {
beforeEach(() => {
cy.visit('app/opensearch-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=SQL]').click({ force: true });
cy.get('[data-test-subj="SQL"]').click({ force: true });
cy.wait(delay);
});

@@ -115,65 +93,43 @@ describe('Test SQL UI', () => {
.should('have.length', 1);
});

it('Test Run button and field search', () => {
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.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);
cy.get('.euiTab__content').contains('accounts').click({ force: true });

cy.get('input.euiFieldSearch').type('marissa');
cy.get('span.euiTableCellContent__text')
.eq(13)
.should((account_number) => {
expect(account_number).to.contain('803');
});
it('Test Run button', () => {
cy.get('textarea.ace_text-input').eq(0).focus().type('{enter}', { force: true });
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').click();
cy.get('[data-test-subj="result_tab"]').contains("SHOW tables LIKE '%'").click({ force: true });
});

it('Test Translate button', () => {
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,
});
cy.wait(delay);
cy.get('textarea.ace_text-input').eq(0).focus().type('{enter}', {
force: true,
});
cy.get('.euiButton__text').contains('Explain').click({ force: true });
cy.wait(delay);

// hard to get euiCodeBlock content, check length instead
cy.get('.euiCodeBlock__code').children().should('have.length', 13);
cy.get('.euiCodeBlock__code').children().should('have.length', 25);
});

it('Test Clear button', () => {
cy.get('.euiButton__text').contains('Clear').click({ force: true });
cy.wait(delay);
cy.get('[data-test-subj="sqlClearButton"]').contains('Clear').click({ force: true });

cy.get('.ace_content')
.eq(0)
.then((queryEditor) => {
const editor = edit(queryEditor[0]);
expect(editor.getValue()).to.equal('');
});
cy.get('.euiTitle').should('not.exist');
});

it('Test full screen view', () => {
cy.get('.euiButton__text').contains('Full screen view').should('not.exist');
cy.get('.euiTitle').contains('Query Workbench').should('exist');

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('textarea.ace_text-input')
.eq(0)
.focus()
.type("{enter}", { force: true });
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').click();
cy.get('[data-test-subj="fullScreenView"]').contains('Full screen view').click();

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


describe('Test and verify SQL downloads', () => {
verifyDownloadData.map(({ title, url, file }) => {
it(title, () => {
@@ -186,14 +142,10 @@ 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') {
expect(response.body.data.body).to.have.string(files[file]);
} else {
expect(response.body.data.resp).to.have.string(files[file]);
}
expect(response.body.data.resp).to.have.string(files[file]);
});
});
});
@@ -203,22 +155,22 @@ describe('Test table display', () => {
beforeEach(() => {
cy.visit('app/opensearch-query-workbench');
cy.wait(delay);
cy.get('.euiToggle__input[title=SQL]').click({ force: true });
cy.get('[data-test-subj="SQL"]').click({ force: true });
cy.wait(delay);
cy.get('textarea.ace_text-input').eq(0).focus().type('{selectall}{backspace}', { force: true });
cy.get('[data-test-subj="sqlClearButton"]').contains('Clear').click();
cy.wait(delay);
});

testQueries.map(({ title, query, cell_idx, expected_string }) => {
it(title, () => {
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.type(`{selectall}{backspace}${query}`, { force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Run').click({ force: true });
cy.wait(delay);

cy.get('[data-test-subj="sqlClearButton"]').contains('Clear').click();
cy.get('div[data-test-subj="sqlCodeEditor"]')
.click({ force: true })
.type(`${query}`);
cy.get('div[data-test-subj="sqlCodeEditor"]').contains(`${query}`).should('exist');
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').should('exist');
cy.wait(1000)
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').click();
cy.get('span.euiTableCellContent__text')
.eq(cell_idx)
.should((cell) => {
@@ -228,20 +180,15 @@ describe('Test table display', () => {
});

it('Test nested fields display', () => {
cy.get('textarea.ace_text-input')
.eq(0)
.focus()
.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.get('[data-test-subj="sqlClearButton"]').contains('Clear').click();
cy.get('div[data-test-subj="sqlCodeEditor"]')
.click()
.type(`select * from employee_nested;`);
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').should('exist');
cy.wait(1000)
cy.get('[data-test-subj="sqlRunButton"]').contains('Run').click();
cy.get(('[data-test-subj="result_tab"]')).contains('employee_nested').should('exist');
cy.get('button.euiLink').eq(2).click();
cy.contains('message');
});
});
26 changes: 11 additions & 15 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
@@ -74,26 +74,22 @@ export const testQueries = [
];

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":"meaganbuckner@biospan.com","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":"jimenezbarry@verton.com","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":"karentrujillo@tsunamia.com","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":"carissasimon@zillacom.com","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":"oconnorclay@franscene.com","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":"marissaspears@centregy.com","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":"westengland@obliq.com","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,"meaganbuckner@biospan.com","Buckner"],[854,"Jimenez","603 Cooper Street",49795,"F","Moscow","Verton","AL",25,"jimenezbarry@verton.com","Barry"],[97,"Karen","512 Cumberland Walk",49671,"F","Fredericktown","Tsunamia","MO",40,"karentrujillo@tsunamia.com","Trujillo"],[168,"Carissa","975 Flatbush Avenue",49568,"M","Neibert","Zillacom","IL",20,"carissasimon@zillacom.com","Simon"],[240,"Oconnor","659 Highland Boulevard",49741,"F","Kilbourne","Franscene","NH",35,"oconnorclay@franscene.com","Clay"],[803,"Marissa","963 Highland Avenue",49567,"M","Bloomington","Centregy","MS",25,"marissaspears@centregy.com","Spears"],[248,"West","717 Hendrickson Place",49989,"M","Maury","Obliq","WA",36,"westengland@obliq.com","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,meaganbuckner@biospan.com,Buckner
854,Jimenez,603 Cooper Street,49795,F,Moscow,Verton,AL,25,jimenezbarry@verton.com,Barry
JSONFile: `[{"_index":"accounts","_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":"karentrujillo@tsunamia.com","city":"Fredericktown","state":"MO"},"sort":[97]},{"_index":"accounts","_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":"carissasimon@zillacom.com","city":"Neibert","state":"IL"},"sort":[168]},{"_index":"accounts","_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":"oconnorclay@franscene.com","city":"Kilbourne","state":"NH"},"sort":[240]},{"_index":"accounts","_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":"westengland@obliq.com","city":"Maury","state":"WA"},"sort":[248]},{"_index":"accounts","_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":"marissaspears@centregy.com","city":"Bloomington","state":"MS"},"sort":[803]},{"_index":"accounts","_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":"meaganbuckner@biospan.com","city":"Craig","state":"TX"},"sort":[842]},{"_index":"accounts","_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":"jimenezbarry@verton.com","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,"karentrujillo@tsunamia.com","Trujillo"],[168,"Carissa","975 Flatbush Avenue",49568,"M","Neibert","Zillacom","IL",20,"carissasimon@zillacom.com","Simon"],[240,"Oconnor","659 Highland Boulevard",49741,"F","Kilbourne","Franscene","NH",35,"oconnorclay@franscene.com","Clay"],[248,"West","717 Hendrickson Place",49989,"M","Maury","Obliq","WA",36,"westengland@obliq.com","England"],[803,"Marissa","963 Highland Avenue",49567,"M","Bloomington","Centregy","MS",25,"marissaspears@centregy.com","Spears"],[842,"Meagan","833 Bushwick Court",49587,"F","Craig","Biospan","TX",23,"meaganbuckner@biospan.com","Buckner"],[854,"Jimenez","603 Cooper Street",49795,"F","Moscow","Verton","AL",25,"jimenezbarry@verton.com","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,karentrujillo@tsunamia.com,Trujillo
168,Carissa,975 Flatbush Avenue,49568,M,Neibert,Zillacom,IL,20,carissasimon@zillacom.com,Simon
240,Oconnor,659 Highland Boulevard,49741,F,Kilbourne,Franscene,NH,35,oconnorclay@franscene.com,Clay
248,West,717 Hendrickson Place,49989,M,Maury,Obliq,WA,36,westengland@obliq.com,England
803,Marissa,963 Highland Avenue,49567,M,Bloomington,Centregy,MS,25,marissaspears@centregy.com,Spears
248,West,717 Hendrickson Place,49989,M,Maury,Obliq,WA,36,westengland@obliq.com,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|meaganbuckner@biospan.com|Buckner
854|Jimenez|603 Cooper Street|49795|F|Moscow|Verton|AL|25|jimenezbarry@verton.com|Barry
842,Meagan,833 Bushwick Court,49587,F,Craig,Biospan,TX,23,meaganbuckner@biospan.com,Buckner
854,Jimenez,603 Cooper Street,49795,F,Moscow,Verton,AL,25,jimenezbarry@verton.com,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|karentrujillo@tsunamia.com|Trujillo
168|Carissa|975 Flatbush Avenue|49568|M|Neibert|Zillacom|IL|20|carissasimon@zillacom.com|Simon
240|Oconnor|659 Highland Boulevard|49741|F|Kilbourne|Franscene|NH|35|oconnorclay@franscene.com|Clay
248|West|717 Hendrickson Place|49989|M|Maury|Obliq|WA|36|westengland@obliq.com|England
803|Marissa|963 Highland Avenue|49567|M|Bloomington|Centregy|MS|25|marissaspears@centregy.com|Spears
248|West|717 Hendrickson Place|49989|M|Maury|Obliq|WA|36|westengland@obliq.com|England`,
};
842|Meagan|833 Bushwick Court|49587|F|Craig|Biospan|TX|23|meaganbuckner@biospan.com|Buckner
854|Jimenez|603 Cooper Street|49795|F|Moscow|Verton|AL|25|jimenezbarry@verton.com|Barry`,
};
Loading