Skip to content

Commit

Permalink
[Enhancement] Flint Datasource Cypress testing for tables (opensearch…
Browse files Browse the repository at this point in the history
…-project#1610)

* Add the cypress module for AO

Signed-off-by: Ryan Liang <[email protected]>

* Prettier cache files

Signed-off-by: Ryan Liang <[email protected]>

* Finish asso table header check 0  missing callout still

Signed-off-by: Ryan Liang <[email protected]>

* AO table content testing 1

Signed-off-by: Ryan Liang <[email protected]>

* AO table content testing all

Signed-off-by: Ryan Liang <[email protected]>

* Refactor some constants name for AO testing and setup ACC test case

Signed-off-by: Ryan Liang <[email protected]>

* Correct the timestamp constant naming in AO tests

Signed-off-by: Ryan Liang <[email protected]>

* Refactor the constants file

Signed-off-by: Ryan Liang <[email protected]>

* Add ACC columns checks

Signed-off-by: Ryan Liang <[email protected]>

* Correct the lint

Signed-off-by: Ryan Liang <[email protected]>

* Add mv test for acc table

Signed-off-by: Ryan Liang <[email protected]>

* Finalize the Acc tests but 1 failure

Signed-off-by: Ryan Liang <[email protected]>

* Finalize the Acc table tests

Signed-off-by: Ryan Liang <[email protected]>

* Formatting constants file

Signed-off-by: Ryan Liang <[email protected]>

---------

Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 authored Mar 26, 2024
1 parent 175bf96 commit 0812d3e
Show file tree
Hide file tree
Showing 5 changed files with 637 additions and 0 deletions.
236 changes: 236 additions & 0 deletions .cypress/integration/flint_datasources/acceleration_table.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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

import {
ACC_TABLE_TITLE,
ACC_TABLE_DESC,
UPDATE_AT_DESC,
LOCALIZED_UPDATE_TIMESTAMP_ACC,
REFRESH_BTN_DESC,
CREATE_ACC_BTN_DESC,
ACC_NAME,
ACC_STATUS,
ACC_TYPE,
ACC_DATABASE,
ACC_TABLE,
ACC_REFRESH_TYPE,
ACC_DESTINATION_INDEX,
ACC_ACTIONS_COL,
TYPE_MV,
TYPE_SI,
EMPTY_CONTENT,
ACTIVE_MV_NAME,
SKIP_INDEX_NAME,
ACTION_ICON_DEL,
ACTION_ICON_VAC,
ACTION_ICON_SYN,
REFRESH_TYPE_MANUAL,
DATABASE_NAME_DEFAULT,
TABLE_NAME_1,
STATUS_DEL,
} from '../../utils/flint-datasources/panel_constants';

Cypress.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('ResizeObserver loop completed with undelivered notifications')) {
return false;
}
});

const goToAccelerationTable = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/datasources`);
cy.get('h1[data-test-subj="dataconnections-header"]').should('be.visible');
cy.get('a[data-test-subj="mys3DataConnectionsLink"]').click();
cy.get('button#acceleration_table').click();
};

describe('Acceleration Table test', () => {
beforeEach(() => {
// Load the catalog cache data
const catalogCachePath = './.cypress/utils/flint-datasources/catalog-cache.json';
cy.readFile(catalogCachePath).then((cache) => {
cy.visit(`${Cypress.env('opensearchDashboards')}`, {
onBeforeLoad: (win) => {
win.localStorage.setItem('async-query-catalog-cache', JSON.stringify(cache));
},
});
});

// Load the accelerations cache data
const accelerationCachePath = './.cypress/utils/flint-datasources/accelerations-cache.json';
cy.readFile(accelerationCachePath).then((cache) => {
cy.visit(`${Cypress.env('opensearchDashboards')}`, {
onBeforeLoad: (win) => {
win.localStorage.setItem('async-query-acclerations-cache', JSON.stringify(cache));
},
});
});
});

afterEach(() => {
cy.clearLocalStorage('async-query-catalog-cache');
cy.clearLocalStorage('async-query-acclerations-cache');
});

it('Navigates to Acceleration table and check header elements', () => {
goToAccelerationTable();

cy.contains('.euiFlexItem .euiText.euiText--medium', ACC_TABLE_TITLE).should(
'contain.text',
ACC_TABLE_DESC
);

cy.contains('.euiTextColor--subdued', UPDATE_AT_DESC).should('exist');
cy.contains('.euiTextColor--subdued', LOCALIZED_UPDATE_TIMESTAMP_ACC).should('exist');

cy.contains('.euiButton--primary', REFRESH_BTN_DESC).should('exist');
cy.contains('.euiButton--primary.euiButton--fill', CREATE_ACC_BTN_DESC).should('exist');
});

it('Navigates to Acceleration table and check table columns', () => {
goToAccelerationTable();

cy.get('th[data-test-subj="tableHeaderCell_indexName_0"]')
.contains('span', ACC_NAME)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_status_1"]')
.contains('span', ACC_STATUS)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_type_2"]')
.contains('span', ACC_TYPE)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_database_3"]')
.contains('span', ACC_DATABASE)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_table_4"]')
.contains('span', ACC_TABLE)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_refreshType_5"]')
.contains('span', ACC_REFRESH_TYPE)
.should('exist');

cy.get('th[data-test-subj="tableHeaderCell_flintIndexName_6"]')
.contains('span', ACC_DESTINATION_INDEX)
.should('exist');

cy.get('th').contains('span[title="Actions"]', ACC_ACTIONS_COL).should('exist');
});

it('Checks rows for "Materialized View" type and verifies table column content', () => {
goToAccelerationTable();

cy.get('tbody')
.find('tr')
.each(($row) => {
cy.wrap($row)
.find('td')
.eq(2)
.invoke('text')
.then((text) => {
if (text.includes(TYPE_MV)) {
cy.wrap($row).find('td').eq(4).should('contain.text', EMPTY_CONTENT);
}
});
});
});

it('Checks rows for "Skipping index" type and verifies Destination Index column content', () => {
goToAccelerationTable();

cy.get('tbody')
.find('tr')
.each(($row) => {
cy.wrap($row)
.find('td')
.eq(2)
.invoke('text')
.then((text) => {
if (text.includes(TYPE_SI)) {
cy.wrap($row).find('td').eq(6).should('contain.text', EMPTY_CONTENT);
}
});
});
});

it('Verifies Sync is enabled and Vacuum is disabled for specific row', () => {
goToAccelerationTable();

cy.get('tbody tr').contains('td', ACTIVE_MV_NAME).parent('tr').as('selectedRow');

cy.get('@selectedRow').find('td').eq(2).contains('div', TYPE_MV).should('exist');

cy.get('@selectedRow').find('td').eq(5).contains('div', REFRESH_TYPE_MANUAL).should('exist');

cy.get('@selectedRow').find('[data-test-subj="euiCollapsedItemActionsButton"]').click();

cy.get('.euiContextMenuPanel')
.should('be.visible')
.within(() => {
cy.contains('button', ACTION_ICON_SYN).should('be.visible').and('not.be.disabled');
});

cy.get('.euiContextMenuPanel').within(() => {
cy.contains('button', ACTION_ICON_DEL).should('be.visible').and('not.be.disabled');
});

cy.get('.euiContextMenuPanel').within(() => {
cy.contains('button', ACTION_ICON_VAC).should('be.visible').and('be.disabled');
});

cy.get('body').click(0, 0);
});

it('Verifies actions for rows with specific criteria and ensures menu interaction', () => {
goToAccelerationTable();
let criteriaMet = false;

cy.get('tbody tr')
.each(($row) => {
const name = $row.find('td:eq(0) .euiLink').text().trim();
const database = $row.find('td:eq(3) .euiText--small').text().trim();
const table = $row.find('td:eq(4) .euiText--small').text().trim();
const statusText = $row.find('td:eq(1) .euiHealth').text().trim();

cy.log(
`Extracted -> Name: '${name}', Database: '${database}', Table: '${table}', Status: '${statusText}'`
);

if (
name === SKIP_INDEX_NAME &&
database === DATABASE_NAME_DEFAULT &&
table === TABLE_NAME_1 &&
statusText.includes(STATUS_DEL)
) {
criteriaMet = true;
console.log('Found row matching criteria');
cy.wrap($row)
.find('[data-test-subj="euiCollapsedItemActionsButton"]')
.should('exist')
.click({ force: true });

cy.get('.euiContextMenuPanel')
.should('be.visible')
.within(() => {
cy.contains('button', ACTION_ICON_SYN).should('exist').and('be.disabled');
cy.contains('button', ACTION_ICON_DEL).should('exist').and('be.disabled');
cy.contains('button', ACTION_ICON_VAC).should('exist').and('not.be.disabled');
});

cy.get('body').click(0, 0);

return false;
}
})
.then(() => {
expect(criteriaMet, 'Failed to find a row matching the specified criteria').to.be.true;
});
});
});
Loading

0 comments on commit 0812d3e

Please sign in to comment.