diff --git a/x-pack/plugins/osquery/cypress/cypress.config.ts b/x-pack/plugins/osquery/cypress/cypress.config.ts index b230c43d460bb..8fb3044b4e408 100644 --- a/x-pack/plugins/osquery/cypress/cypress.config.ts +++ b/x-pack/plugins/osquery/cypress/cypress.config.ts @@ -11,7 +11,7 @@ import path from 'path'; import { safeLoad as loadYaml } from 'js-yaml'; import { readFileSync } from 'fs'; -import { filterCypressVideos } from './support/filter_videos'; +import { getFailedSpecVideos } from './support/filter_videos'; import type { YamlRoleDefinitions } from '../../../test_serverless/shared/lib'; import { setupUserDataLoader } from '../../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks'; const ROLES_YAML_FILE_PATH = path.join( @@ -61,7 +61,7 @@ export default defineCypressConfig({ numTestsKeptInMemory: 3, setupNodeEvents(on, config) { setupUserDataLoader(on, config, { roleDefinitions, additionalRoleName: 'viewer' }); - on('after:spec', filterCypressVideos); + on('after:spec', getFailedSpecVideos); return config; }, diff --git a/x-pack/plugins/osquery/cypress/e2e/all/packs_integration.cy.ts b/x-pack/plugins/osquery/cypress/e2e/all/packs_integration.cy.ts index 9ae92ac2823d8..d2a130b1e6d9c 100644 --- a/x-pack/plugins/osquery/cypress/e2e/all/packs_integration.cy.ts +++ b/x-pack/plugins/osquery/cypress/e2e/all/packs_integration.cy.ts @@ -64,8 +64,8 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => { cy.get('span').contains('Add pack').click(); cy.get('input[name="name"]').type(`${REMOVING_PACK}{downArrow}{enter}`); cy.getBySel('policyIdsComboBox').type(`${AGENT_POLICY_NAME}{downArrow}{enter}`); - cy.get('button').contains('Save pack').click(); - + // cy.get('button').contains('Save pack').click(); + cy.getBySel('savePackButton').click(); closeToastIfVisible(); cy.getBySel('tablePaginationPopoverButton').click(); cy.getBySel('tablePagination-50-rows').click(); @@ -123,7 +123,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => { cy.contains(PREBUILD_PACK_NAME).click(); cy.contains('Edit').click(); cy.getBySel('policyIdsComboBox').type(`${DEFAULT_POLICY} {downArrow}{enter}`); - cy.contains('Update pack').click(); + cy.getBySel('updatePackButton').click(); cy.getBySel('confirmModalConfirmButton').click(); cy.contains(`Successfully updated "${PREBUILD_PACK_NAME}" pack`); }); @@ -204,9 +204,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => { cy.getBySel('policyIdsComboBox').should('exist'); cy.getBySel('osqueryPackTypeGlobal').click(); cy.getBySel('policyIdsComboBox').should('not.exist'); - - cy.get('button').contains('Save pack').click(); - + cy.getBySel('savePackButton').click(); cy.getBySel('tablePaginationPopoverButton').click(); cy.getBySel('tablePagination-50-rows').click(); cy.contains(globalPack); @@ -275,7 +273,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => { cy.getBySel('shards-field-policy').type(`${OSQUERY_POLICY}{downArrow}{enter}`); cy.get('#shardsPercentage1').type('{backspace}{backspace}{backspace}'); }); - cy.get('button').contains('Save pack').click(); + cy.getBySel('savePackButton').click(); cy.contains(`Successfully created "${shardPack}" pack`); closeToastIfVisible(); diff --git a/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts b/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts index 86669ed227006..215f5b6389af9 100644 --- a/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts +++ b/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts @@ -6,7 +6,7 @@ */ import { defineCypressConfig } from '@kbn/cypress-config'; -import { filterCypressVideos } from './support/filter_videos'; +import { getFailedSpecVideos } from './support/filter_videos'; import { setupUserDataLoader } from '../../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks'; // eslint-disable-next-line import/no-default-export @@ -43,7 +43,7 @@ export default defineCypressConfig({ numTestsKeptInMemory: 3, setupNodeEvents: (on, config) => { setupUserDataLoader(on, config, { additionalRoleName: 'viewer' }); - on('after:spec', filterCypressVideos); + on('after:spec', getFailedSpecVideos); return config; }, diff --git a/x-pack/plugins/osquery/cypress/support/e2e.ts b/x-pack/plugins/osquery/cypress/support/e2e.ts index 13caa0aff93e8..d5943e655e5ae 100644 --- a/x-pack/plugins/osquery/cypress/support/e2e.ts +++ b/x-pack/plugins/osquery/cypress/support/e2e.ts @@ -81,13 +81,9 @@ Cypress.Commands.add( Cypress.Commands.add('login', (role) => { if (isServerless) { - cy.log('commands1'); - return login.with(role, 'changeme'); } - cy.log('commands2'); - // @ts-expect-error hackish way to provide a new role in Osquery ESS only (Reader) return login(role); }); diff --git a/x-pack/plugins/osquery/cypress/support/filter_videos.ts b/x-pack/plugins/osquery/cypress/support/filter_videos.ts index 705aca7c39860..69826fb39b0bc 100644 --- a/x-pack/plugins/osquery/cypress/support/filter_videos.ts +++ b/x-pack/plugins/osquery/cypress/support/filter_videos.ts @@ -7,7 +7,7 @@ import fs from 'fs'; // makes sure we save videos just for failed specs -export const filterCypressVideos = (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => { +export const getFailedSpecVideos = (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => { if (results && results.video) { // Do we have failures for any retry attempts? const failures = results.tests.some((test) => diff --git a/x-pack/plugins/osquery/cypress/tasks/inventory.ts b/x-pack/plugins/osquery/cypress/tasks/inventory.ts index d33eccd151fa7..d4a2d1111db8f 100644 --- a/x-pack/plugins/osquery/cypress/tasks/inventory.ts +++ b/x-pack/plugins/osquery/cypress/tasks/inventory.ts @@ -6,12 +6,18 @@ */ export const triggerLoadData = () => { - // @ts-expect-error update types for multiple true - const nodeContainers = cy.getBySel('nodeContainer', { multiple: true }); cy.getBySel('infraWaffleTimeControlsAutoRefreshButton').should('exist'); cy.wait(1000); cy.getBySel('infraWaffleTimeControlsAutoRefreshButton').click(); - nodeContainers.not(':contains("dev-fleet-server")').first().should('exist'); + // @ts-expect-error update types for multiple true + cy.getBySel('nodeContainer', { multiple: true }) + .not(':contains("dev-fleet-server")') + .first() + .should('exist'); cy.getBySel('infraWaffleTimeControlsStopRefreshingButton').click(); - nodeContainers.not(':contains("dev-fleet-server")').first().click(); + // @ts-expect-error update types for multiple true + cy.getBySel('nodeContainer', { multiple: true }) + .not(':contains("dev-fleet-server")') + .first() + .click(); }; diff --git a/x-pack/plugins/osquery/public/packs/add_pack_button.tsx b/x-pack/plugins/osquery/public/packs/add_pack_button.tsx index 70a97f2354a54..07df6d83c7284 100644 --- a/x-pack/plugins/osquery/public/packs/add_pack_button.tsx +++ b/x-pack/plugins/osquery/public/packs/add_pack_button.tsx @@ -25,6 +25,7 @@ const AddPackButtonComponent: React.FC = ({ fill = {...newQueryLinkProps} iconType="plusInCircle" isDisabled={!permissions.writePacks} + data-test-subj={'addPackButton'} > diff --git a/x-pack/plugins/osquery/public/packs/form/index.tsx b/x-pack/plugins/osquery/public/packs/form/index.tsx index 259e6d0d7b9ee..43420efd47e3f 100644 --- a/x-pack/plugins/osquery/public/packs/form/index.tsx +++ b/x-pack/plugins/osquery/public/packs/form/index.tsx @@ -315,6 +315,7 @@ const PackFormComponent: React.FC = ({ size="m" iconType="save" onClick={handleSaveClick} + data-test-subj={`${editMode ? 'update' : 'save'}PackButton`} > {editMode ? (