Skip to content

Commit

Permalink
update cypress testing for panels (#2285) (#2290)
Browse files Browse the repository at this point in the history
(cherry picked from commit c6c2bab)

Signed-off-by: Ritvi Bhatt <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ritvi Bhatt <[email protected]>
  • Loading branch information
3 people authored Dec 10, 2024
1 parent 3c43835 commit 12140f2
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .cypress/integration/panels_test/panels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Panels testing with Sample Data', { defaultCommandTimeout: 10000 }, ()
it('Displays error toast for invalid panel name', () => {
clickCreatePanelButton();
confirmModal();
expectToastWith('Invalid Dashboard name');
expectToastWith('Invalid Dashboard Name');
});

it('Creates a panel and redirects to the panel', () => {
Expand Down Expand Up @@ -124,14 +124,21 @@ describe('Panels testing with Sample Data', { defaultCommandTimeout: 10000 }, ()
cy.get('.euiTableRow').should('have.length', 2);
const duplicateName = TEST_PANEL + ' (copy)';
cy.contains(duplicateName).should('exist');
const duplicate = cy.get('.euiLink').contains(duplicateName);
expectUuid(duplicate);
cy.get('.euiLink')
.contains(duplicateName)
.should('exist')
.then(($anchorElem) => {
expectUuid(cy.wrap($anchorElem));
});
});

it('Renames the panel', () => {
cy.reload();
const cell = cy.get('.euiTableCellContent');
expectLegacyId(cell);
cy.get('.euiTableCellContent')
.should('exist')
.then(($anchorElem) => {
expectLegacyId(cy.wrap($anchorElem));
});
cy.get('.euiCheckbox__input[title="Select this row"]').first().click();
openActionsDropdown();
cy.get('button[data-test-subj="renameContextMenuItem"]').click();
Expand Down Expand Up @@ -192,8 +199,12 @@ describe('Panels testing with Sample Data', { defaultCommandTimeout: 10000 }, ()
cy.get('[data-test-subj="breadcrumb"]').click({ force: true }); //reload page
cy.get('.euiTableRow').should('have.length', 2);
cy.contains(duplicateName).should('exist');
const duplicate = cy.get('.euiLink').contains(duplicateName);
expectUuid(duplicate);
cy.get('.euiLink')
.contains(duplicateName)
.should('exist')
.then(($anchorElem) => {
expectUuid(cy.wrap($anchorElem));
});
});

it('Renames a saved-objects panel', () => {
Expand Down Expand Up @@ -227,11 +238,10 @@ describe('Panels testing with Sample Data', { defaultCommandTimeout: 10000 }, ()
it('Redirects to observability dashboard from OSD dashboards with edit', () => {
moveToOsdDashboards();
cy.location('pathname').should('eq', '/app/dashboards');
cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]')
.closest('tr')
.get('span.euiToolTipAnchor > button.euiButtonIcon')
cy.get('[data-test-subj="dashboardEditBtn"]')
.eq(0)
.click();
cy.get('[data-test-subj="dashboardEditDashboard"]').click();
cy.location('pathname').should('eq', '/app/observability-dashboards');
cy.location('hash').should('include', '/edit');
});
Expand Down Expand Up @@ -775,7 +785,7 @@ const createSavedObjectPanel = (newName = TEST_PANEL) => {
.then((response) => response.body);
};

const addVisualizationsToPanel = (panel, additionalVisualizationIds: string[]) => {
const addVisualizationsToPanel = (panel, additionalVisualizationIds) => {
const additionalVisualizations = additionalVisualizationIds.map((id, idx) => {
return {
savedVisualizationId: `observability-visualization:${id}`,
Expand Down Expand Up @@ -849,7 +859,7 @@ const createVisualization = (newName, query, vizConfig) => {
};

const createLegacyPanel = (newName = TEST_PANEL) => {
const result = cy.request({
cy.request({
method: 'POST',
failOnStatusCode: false,
url: 'api/observability/operational_panels/panels',
Expand Down

0 comments on commit 12140f2

Please sign in to comment.