Skip to content

Commit

Permalink
Update gantt chart tenant (#1226)
Browse files Browse the repository at this point in the history
* update gantt chart tenant

Signed-off-by: Shenoy Pratik <[email protected]>

* fix add index pattern request

Signed-off-by: Shenoy Pratik <[email protected]>

* make default tenant global

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 authored Apr 24, 2024
1 parent 4359f86 commit a60fa70
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import customParseFormat from 'dayjs/plugin/customParseFormat';
import dayjs from 'dayjs';
import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';
import { devToolsRequest } from '../../../utils/helpers';
import { CURRENT_TENANT } from '../../../utils/commands';

dayjs.extend(customParseFormat);

Expand All @@ -20,16 +20,22 @@ const X_LABEL = 'A unique label for X-axis';
const DEFAULT_SIZE = 10;

describe('Dump test data', () => {
it('Indexes test data for gantt chart', () => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
if (Cypress.env('SECURITY_ENABLED')) {
// Set default tenant to private to avoid tenant popup
/**
* Security plugin is using private tenant as default.
* So here we'd need to set global tenant as default manually.
*/
cy.changeDefaultTenant({
multitenancy_enabled: true,
private_tenant_enabled: true,
default_tenant: 'private',
default_tenant: 'global',
});
}
CURRENT_TENANT.newTenant = 'private';
});

it('Indexes test data for gantt chart', () => {
const dumpDataSet = (ndjson, index) =>
cy.request({
method: 'POST',
Expand Down Expand Up @@ -67,10 +73,12 @@ describe('Dump test data', () => {

describe('Save a gantt chart', { defaultCommandTimeout: 20000 }, () => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/visualize#`);
});

it('Creates and saves a gantt chart', () => {
CURRENT_TENANT.newTenant = 'global';
cy.get('.euiButton__text').contains('Create ').click({ force: true });
cy.get('[data-test-subj="visTypeTitle"]')
.contains('Gantt Chart')
Expand All @@ -91,10 +99,11 @@ describe(
{ defaultCommandTimeout: 20000 },
() => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'private';
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.intercept('**').as('searchRequest');
cy.get('.euiFieldSearch').focus().type(GANTT_VIS_NAME);
cy.get('.euiFieldSearch').focus();
cy.get('.euiFieldSearch').type(GANTT_VIS_NAME);
cy.wait('@searchRequest');
cy.wait(5000);
cy.get('[data-test-subj="itemsInMemTable"]')
Expand Down Expand Up @@ -138,20 +147,20 @@ describe(

describe('Configure panel settings', { defaultCommandTimeout: 20000 }, () => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.intercept('**').as('searchRequest');
cy.get('.euiFieldSearch').focus().type(GANTT_VIS_NAME);
cy.get('.euiFieldSearch').focus();
cy.get('.euiFieldSearch').type(GANTT_VIS_NAME);
cy.wait('@searchRequest');
cy.wait(5000);
cy.contains(GANTT_VIS_NAME).should('exist').click();
cy.contains('Panel settings').click({ force: true });
});

it('Changes y-axis label', () => {
cy.get('input.euiFieldText[placeholder="Label"]')
.eq(0)
.focus()
.type(Y_LABEL);
cy.get('input.euiFieldText[placeholder="Label"]').eq(0).focus();
cy.get('input.euiFieldText[placeholder="Label"]').eq(0).type(Y_LABEL);
cy.get('.euiButton__text').contains('Update').click({ force: true });

cy.get('text.ytitle').contains(Y_LABEL).should('exist');
Expand All @@ -165,10 +174,8 @@ describe('Configure panel settings', { defaultCommandTimeout: 20000 }, () => {
});

it('Changes x-axis label', () => {
cy.get('input.euiFieldText[placeholder="Label"]')
.eq(1)
.focus()
.type(X_LABEL);
cy.get('input.euiFieldText[placeholder="Label"]').eq(1).focus();
cy.get('input.euiFieldText[placeholder="Label"]').eq(1).type(X_LABEL);
cy.get('.euiButton__text').contains('Update').click({ force: true });

cy.get('text.xtitle').contains(X_LABEL).should('exist');
Expand Down Expand Up @@ -264,11 +271,13 @@ describe(
{ defaultCommandTimeout: 20000 },
() => {
it('Adds gantt chart to dashboard', () => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/dashboards#/create`);
cy.contains('Add an existing').click({ force: true });
cy.get('input[data-test-subj="savedObjectFinderSearchInput"]')
.focus()
.type(GANTT_VIS_NAME);
cy.get('input[data-test-subj="savedObjectFinderSearchInput"]').focus();
cy.get('input[data-test-subj="savedObjectFinderSearchInput"]').type(
GANTT_VIS_NAME
);
cy.get(`.euiListGroupItem__label[title="${GANTT_VIS_NAME}"]`).click({
force: true,
});
Expand Down

0 comments on commit a60fa70

Please sign in to comment.