From a8ba15a0175cc1684a020cac5712de12c99c68d9 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Wed, 31 Jul 2024 23:18:16 -0400 Subject: [PATCH] Fixes the permissions spec and related to fixtures to reflect correct action-group names (#1449) * Fixes the permissions spec and related to fixtures to reflect correct action-group names Signed-off-by: Darshit Chanpura * Adds a test case to check for button availability before making a call Signed-off-by: Darshit Chanpura * Adds a focus call Signed-off-by: Darshit Chanpura * Temp add 10 CI runs Signed-off-by: Darshit Chanpura * Fixes sanity test spec Signed-off-by: Darshit Chanpura * Revert "Temp add 10 CI runs" This reverts commit 0619d35c1e1e5fc7ae5331fa59ab783ac90b0b35. Signed-off-by: Darshit Chanpura --------- Signed-off-by: Darshit Chanpura --- ..._new_creation_from_selection_response.json | 2 +- ...tiongroups_post_new_creation_response.json | 2 +- .../sanity_tests.spec.js | 11 ++++- .../plugins/security/permissions_spec.js | 40 ++++++++++++------- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_from_selection_response.json b/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_from_selection_response.json index 4fb8ddfea..13b06b451 100644 --- a/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_from_selection_response.json +++ b/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_from_selection_response.json @@ -1,7 +1,7 @@ { "total": 26, "data": { - "test": { + "test-selection": { "reserved": false, "hidden": false, "allowed_actions": ["data_access"], diff --git a/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_response.json b/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_response.json index 1582affc5..8bd009562 100644 --- a/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_response.json +++ b/cypress/fixtures/plugins/security/permissions/actiongroups_post_new_creation_response.json @@ -1,7 +1,7 @@ { "total": 26, "data": { - "test": { + "test-creation": { "reserved": false, "hidden": false, "allowed_actions": [], diff --git a/cypress/integration/plugins/security-dashboards-plugin/sanity_tests.spec.js b/cypress/integration/plugins/security-dashboards-plugin/sanity_tests.spec.js index 28c809612..9dc579bed 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/sanity_tests.spec.js +++ b/cypress/integration/plugins/security-dashboards-plugin/sanity_tests.spec.js @@ -156,7 +156,16 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.loadSampleData('flights'); // Step 3: Navigate to Manage data to add an index pattern cy.visit(`${BASE_PATH}/app/home`); - cy.get('button[aria-label="Closes this modal window"]').click(); + + cy.get('.euiOverlayMask').then(($body) => { + if ( + $body.find('button[aria-label="Closes this modal window"]').length + ) { + cy.get('button[aria-label="Closes this modal window"]').click(); + } else { + // do nothing + } + }); cy.contains('Manage').click(); // Adjust the selector as needed // Step 4: Add the index pattern diff --git a/cypress/integration/plugins/security/permissions_spec.js b/cypress/integration/plugins/security/permissions_spec.js index 2935daa32..5ee7a2f94 100644 --- a/cypress/integration/plugins/security/permissions_spec.js +++ b/cypress/integration/plugins/security/permissions_spec.js @@ -73,13 +73,7 @@ if (Cypress.env('SECURITY_ENABLED')) { }); it('should create new action group successfully by selecting `Create from blank`', () => { - cy.mockPermissionsAction( - SEC_PERMISSIONS_FIXTURES_PATH + - '/actiongroups_post_new_creation_response.json', - () => { - cy.visit(SEC_UI_PERMISSIONS_PATH); - } - ); + cy.visit(SEC_UI_PERMISSIONS_PATH); cy.contains('button', 'Create action group') .first() @@ -92,16 +86,26 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.contains('.euiModalHeader__title', 'Create new action group'); const actionGroupName = 'test-creation'; - cy.get('input[data-test-subj="name-text"]').type(actionGroupName, { - force: true, - }); + cy.get('input[data-test-subj="name-text"]') + .focus() + .clear() + .type(actionGroupName, { + force: true, + }) + .blur(); cy.get('input[data-test-subj="name-text"]').should( 'have.value', actionGroupName ); + cy.get('button[id="submit"]').should('not.have.attr', 'disabled'); - cy.get('button[id="submit"]').first().click({ force: true }); - + cy.mockPermissionsAction( + SEC_PERMISSIONS_FIXTURES_PATH + + '/actiongroups_post_new_creation_response.json', + () => { + cy.get('button[id="submit"]').first().click({ force: true }); + } + ); cy.url().should((url) => { expect(url).to.contain('/permissions'); }); @@ -139,13 +143,19 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.contains('.euiModalHeader__title', 'Create new action group'); const actionGroupName = 'test-selection'; - cy.get('input[data-test-subj="name-text"]').type(actionGroupName, { - force: true, - }); + cy.get('input[data-test-subj="name-text"]') + .focus() + .clear() + .type(actionGroupName, { + force: true, + }) + .blur(); + cy.get('input[data-test-subj="name-text"]').should( 'have.value', actionGroupName ); + cy.get('button[id="submit"]').should('not.have.attr', 'disabled'); cy.get('div[data-test-subj="comboBoxInput"]') .find('span')