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

Panel table fixes #406

Merged
merged 13 commits into from
Apr 20, 2023
93 changes: 46 additions & 47 deletions .cypress/integration/3_panels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ describe('Testing panels table', () => {
moveToPanelHome();
});

it('Displays error toast for invalid panel name', () => {
it.skip('Displays error toast for invalid panel name', () => {
clickCreatePanelButton();
confirmModal();
expectToastWith('Invalid Operational Panel name');
expectToastWith('Invalid Dashboard name');
});

it('Creates a panel and redirects to the panel', () => {
Expand Down Expand Up @@ -150,6 +150,37 @@ describe('Testing panels table', () => {
cy.get('button[data-test-subj="popoverModal__deleteButton"]').click();
cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist');
});

it('Searches panels', () => {
createLegacyPanel('Legacy Named');
createSavedObjectPanel('Saved Object');
cy.reload();
cy.get('input[data-test-subj="operationalPanelSearchBar"]')
.focus()
.type('this panel should not exist', {
delay: 50,
});

cy.get('.euiTableCellContent__text').contains('No items found').should('exist');

// Search for oriignal Legacy Panel
cy.get('[aria-label="Clear input"]').click();
cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type(TEST_PANEL, {
delay: 50,
});

cy.get('a.euiLink').contains(TEST_PANEL).should('exist');
cy.get('.euiTableRow').should('have.length', 1);

// Search for teh Saved Object panel
cy.get('[aria-label="Clear input"]').click();
cy.get('input[data-test-subj="operationalPanelSearchBar"]').focus().type('Saved Object', {
delay: 50,
});

cy.get('a.euiLink').contains('Saved Object').should('exist');
cy.get('.euiTableRow').should('have.length', 1);
});
});

describe('with a SavedObjects Panel', () => {
Expand Down Expand Up @@ -196,38 +227,6 @@ describe('Testing panels table', () => {
cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist');
});
});

it('Searches existing panel', () => {
createLegacyPanel();
cy.get('input[data-test-subj="operationalPanelSearchBar"]')
.focus()
.type('this panel should not exist', {
delay: 50,
});

cy.get('.euiTableCellContent__text').contains('No items found').should('exist');

cy.get('[aria-label="Clear input"]').click();
cy.get('input[data-test-subj="operationalPanelSearchBar"]')
.focus()
.type(TEST_PANEL + ' (copy) (rename)', {
delay: 50,
});

cy.get('a.euiLink')
.contains(TEST_PANEL + ' (copy) (rename)')
.should('exist');
});

it('Create a panel for testing', () => {
moveToPanelHome();
// keep a panel for testing
clickCreatePanelButton();
cy.get('input.euiFieldText').focus().type(TEST_PANEL, {
delay: 50,
});
cy.get('button[data-test-subj="runModalButton"]').click();
});
});

describe('Testing a panel', () => {
Expand Down Expand Up @@ -274,7 +273,7 @@ describe('Testing a panel', () => {

cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`)
.focus()
.clear({force: true})
.clear({ force: true })
.focus()
.type('Renamed Panel', {
delay: 200,
Expand Down Expand Up @@ -347,9 +346,9 @@ describe('Testing a panel', () => {

cy.get('h5[data-test-subj="visualizationHeader"]')
.contains(PPL_VISUALIZATIONS_NAMES[1])
.trigger('mousedown', {which: 1})
.trigger('mousemove', {clientX: 1100, clientY: 0})
.trigger('mouseup', {force: true});
.trigger('mousedown', { which: 1 })
.trigger('mousemove', { clientX: 1100, clientY: 0 })
.trigger('mouseup', { force: true });

cy.get('button[data-test-subj="savePanelButton"]').click();
cy.wait(delay * 3);
Expand All @@ -364,9 +363,9 @@ describe('Testing a panel', () => {

cy.get('.react-resizable-handle')
.eq(1)
.trigger('mousedown', {which: 1})
.trigger('mousemove', {clientX: 2000, clientY: 800})
.trigger('mouseup', {force: true});
.trigger('mousedown', { which: 1 })
.trigger('mousemove', { clientX: 2000, clientY: 800 })
.trigger('mouseup', { force: true });

cy.get('button[data-test-subj="savePanelButton"]').click();
cy.wait(delay * 3);
Expand Down Expand Up @@ -481,7 +480,7 @@ describe('Testing a panel', () => {
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click();
cy.wait(1000);
cy.get('[data-test-subj="eventExplorer__querySaveName"]')
.clear({force: true})
.clear({ force: true })
.type(NEW_VISUALIZATION_NAME, {
delay: 200,
});
Expand Down Expand Up @@ -537,7 +536,7 @@ describe('Clean up all test data', () => {

const moveToEventsHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`);
cy.wait(delay * 3);
cy.wait(6000);
};

const moveToPanelHome = () => {
Expand Down Expand Up @@ -620,7 +619,7 @@ const uuidRx = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4
const clickCreatePanelButton = () =>
cy.get('a[data-test-subj="customPanels__createNewPanels"]').click();

const createSavedObjectPanel = () => {
const createSavedObjectPanel = (newName = TEST_PANEL) => {
const result = cy
.request({
method: 'POST',
Expand All @@ -632,7 +631,7 @@ const createSavedObjectPanel = () => {
},
body: {
attributes: {
title: TEST_PANEL,
title: newName,
description: '',
dateCreated: 1681127334085,
dateModified: 1681127334085,
Expand All @@ -652,7 +651,7 @@ const createSavedObjectPanel = () => {
.then((response) => console.log(response));
};

const createLegacyPanel = () => {
const createLegacyPanel = (newName = TEST_PANEL) => {
const result = cy.request({
method: 'POST',
failOnStatusCode: false,
Expand All @@ -661,7 +660,7 @@ const createLegacyPanel = () => {
'content-type': 'application/json;charset=UTF-8',
'osd-xsrf': true,
},
body: { panelName: TEST_PANEL },
body: { panelName: newName },
});
};

Expand Down
Loading