From 45daf83f3c551418e55d76acb87638e9ee46cb5c Mon Sep 17 00:00:00 2001 From: leanneeliatra Date: Thu, 20 Jul 2023 10:07:46 +0100 Subject: [PATCH] linting errors resolved Signed-off-by: leanneeliatra Signed-off-by: leanneeliatra --- .../change_tenant_successfully.js | 1 - .../switch_tenant.js | 12 +-- .../tenancy_change_on_shortlink.js | 78 +++++++++---------- cypress/utils/commands.js | 7 +- package-lock.json | 6 +- package.json | 2 +- 6 files changed, 52 insertions(+), 54 deletions(-) diff --git a/cypress/integration/plugins/security-dashboards-plugin/change_tenant_successfully.js b/cypress/integration/plugins/security-dashboards-plugin/change_tenant_successfully.js index 3799264ec..76e44ae2a 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/change_tenant_successfully.js +++ b/cypress/integration/plugins/security-dashboards-plugin/change_tenant_successfully.js @@ -6,7 +6,6 @@ import { CURRENT_TENANT } from '../../../utils/commands'; import { switchTenantTo } from './switch_tenant'; - if (Cypress.env('SECURITY_ENABLED')) { describe('Switch tenants when visiting copied links: ', () => { const tenantName = 'private'; diff --git a/cypress/integration/plugins/security-dashboards-plugin/switch_tenant.js b/cypress/integration/plugins/security-dashboards-plugin/switch_tenant.js index ec86bbe78..5666eca8f 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/switch_tenant.js +++ b/cypress/integration/plugins/security-dashboards-plugin/switch_tenant.js @@ -2,7 +2,7 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ - + export function switchTenantTo(newTenant) { cy.getElementByTestId('account-popover').click(); cy.intercept({ @@ -17,8 +17,10 @@ export function switchTenantTo(newTenant) { cy.getElementByTestId('switch-tenants').click(); //should ensures the dialog window is fully loaded and the radios can be selected. - cy.get('[id="' + newTenant + '"][name="tenantSwitchRadios"]').should('be.enabled'); - cy.get('.euiRadio__label[for="' + newTenant + '"]').click(); + cy.get('[id="' + newTenant + '"][name="tenantSwitchRadios"]').should( + 'be.enabled' + ); + cy.get('.euiRadio__label[for="' + newTenant + '"]').click(); cy.intercept({ method: 'POST', @@ -28,10 +30,10 @@ export function switchTenantTo(newTenant) { .find('[data-test-subj="confirm"]') .click(); - cy.wait('@waitForUpdatingTenants') + cy.wait('@waitForUpdatingTenants'); // Make sure dashboards has really reloaded. // @waitForReloadAfterTenantSwitch should be triggered twice cy.wait('@waitForDashboardsInfo'); cy.wait('@waitForDashboardsInfo'); -} \ No newline at end of file +} diff --git a/cypress/integration/plugins/security-dashboards-plugin/tenancy_change_on_shortlink.js b/cypress/integration/plugins/security-dashboards-plugin/tenancy_change_on_shortlink.js index 1f406fa18..fcd2d6903 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/tenancy_change_on_shortlink.js +++ b/cypress/integration/plugins/security-dashboards-plugin/tenancy_change_on_shortlink.js @@ -1,38 +1,36 @@ /* -* Copyright OpenSearch Contributors -* SPDX-License-Identifier: Apache-2.0 -*/ + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ import { CURRENT_TENANT } from '../../../utils/commands'; import { switchTenantTo } from './switch_tenant'; -import indexPatternGlobalTenantHeaderSetUp - from "../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternGlobalTenantHeader.json"; -import indexPatternPrivateTenantHeaderSetUp - from "../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternPrivateTenantHeader.json"; +import indexPatternGlobalTenantHeaderSetUp from '../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternGlobalTenantHeader.json'; +import indexPatternPrivateTenantHeaderSetUp from '../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternPrivateTenantHeader.json'; if (Cypress.env('SECURITY_ENABLED')) { describe('Multi Tenancy Tests: ', () => { - before(() => { - cy.server(); + before(() => { + cy.server(); - cy.createIndexPattern( - 'index-pattern1', - { - title: 's*', - timeFieldName: 'timestamp', - }, - indexPatternGlobalTenantHeaderSetUp - ); + cy.createIndexPattern( + 'index-pattern1', + { + title: 's*', + timeFieldName: 'timestamp', + }, + indexPatternGlobalTenantHeaderSetUp + ); - cy.createIndexPattern( - 'index-pattern2', - { - title: 'se*', - timeFieldName: 'timestamp', - }, - indexPatternPrivateTenantHeaderSetUp - ); - }); + cy.createIndexPattern( + 'index-pattern2', + { + title: 'se*', + timeFieldName: 'timestamp', + }, + indexPatternPrivateTenantHeaderSetUp + ); + }); it('Tests that when the short URL is copied and pasted, it will route correctly with the right tenant', function () { const randomNumber = Cypress._.random(0, 1e6); @@ -40,11 +38,14 @@ if (Cypress.env('SECURITY_ENABLED')) { // We are programmatically creating a dashboard so that the test // always have the same view. An empty list would show the empty prompt. // Also, this saves us some typing, clicking and waiting in the test. - cy.createDashboard({ - title: dashboardName - }, { - security_tenant: 'private' - }) + cy.createDashboard( + { + title: dashboardName, + }, + { + security_tenant: 'private', + } + ); // When creating the shortUrl, we don't want to have the security_tenant // parameter in the url - otherwise it will be stored in the shortUrl @@ -67,7 +68,7 @@ if (Cypress.env('SECURITY_ENABLED')) { '__user__' ); }, - } ); + }); // Navigate to the Dashboards app cy.getElementByTestId('toggleNavButton').should('be.visible').click(); // After clicking the navigation, the security_tenant parameter should be gone @@ -76,7 +77,11 @@ if (Cypress.env('SECURITY_ENABLED')) { // The test subj seems to replace spaces with a dash, so we convert the dashboard name here too. // Go to the dashboard we have created const selectorDashboardName = dashboardName.split(' ').join('-'); - cy.getElementByTestId('dashboardListingTitleLink-' + selectorDashboardName).should('be.visible').click(); + cy.getElementByTestId( + 'dashboardListingTitleLink-' + selectorDashboardName + ) + .should('be.visible') + .click(); // Open top share navigation to access copy short url cy.getElementByTestId('shareTopNavButton').should('be.visible').click(); @@ -90,7 +95,6 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.getElementByTestId('createShortUrl').click(); cy.wait('@getShortUrl'); - //4. Switch tenant & visit shortURL link to ensure tenant from short URL is retained cy.get('[data-test-subj="copyShareUrlButton"]') .invoke('attr', 'data-share-url') @@ -109,10 +113,7 @@ if (Cypress.env('SECURITY_ENABLED')) { }, }); - cy.url({ timeout: 10000 }).should( - 'contain', - 'security_tenant=' - ); + cy.url({ timeout: 10000 }).should('contain', 'security_tenant='); cy.getElementByTestId('breadcrumb last').should( 'contain.text', dashboardName @@ -121,4 +122,3 @@ if (Cypress.env('SECURITY_ENABLED')) { }); }); } - diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index b17ebd351..1b753dc5d 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -338,7 +338,6 @@ Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => { const url = `${ Cypress.config().baseUrl }/api/saved_objects/index-pattern/${id}?overwrite=true`; // When running tests locally if ran multiple times the tests fail. The fix is to set Overwrite to true. - cy.request({ method: 'POST', @@ -355,10 +354,8 @@ Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => { }); }); -Cypress.Commands.add('createDashboard', (attributes= {}, headers = {}) => { - const url = `${ - Cypress.config().baseUrl - }/api/saved_objects/dashboard`; +Cypress.Commands.add('createDashboard', (attributes = {}, headers = {}) => { + const url = `${Cypress.config().baseUrl}/api/saved_objects/dashboard`; cy.request({ method: 'POST', diff --git a/package-lock.json b/package-lock.json index be3b195ff..933607a33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2387,9 +2387,9 @@ "dev": true }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" diff --git a/package.json b/package.json index a4f304776..ec47eb5cb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1", "cypress:open": "cypress open", "cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false", - "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200", + "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200", "cypress:run-with-security-and-aggregation-view": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,AGGREGATION_VIEW=true", "cypress:run-plugin-tests-without-security": "yarn cypress:run-without-security --spec 'cypress/integration/plugins/*/*.js'", "cypress:run-plugin-tests-with-security": "yarn cypress:run-with-security --spec 'cypress/integration/plugins/*/*.js'",