Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsonpl committed Oct 31, 2023
1 parent 44c74cb commit 9105d07
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/osquery/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
},
Expand Down
12 changes: 5 additions & 7 deletions x-pack/plugins/osquery/cypress/e2e/all/packs_integration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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`);
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/osquery/cypress/serverless_cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
},
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/osquery/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/osquery/cypress/support/filter_videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
14 changes: 10 additions & 4 deletions x-pack/plugins/osquery/cypress/tasks/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
1 change: 1 addition & 0 deletions x-pack/plugins/osquery/public/packs/add_pack_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const AddPackButtonComponent: React.FC<AddPackButtonComponentProps> = ({ fill =
{...newQueryLinkProps}
iconType="plusInCircle"
isDisabled={!permissions.writePacks}
data-test-subj={'addPackButton'}
>
<FormattedMessage id="xpack.osquery.packList.addPackButtonLabel" defaultMessage="Add pack" />
</EuiButton>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/osquery/public/packs/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const PackFormComponent: React.FC<PackFormProps> = ({
size="m"
iconType="save"
onClick={handleSaveClick}
data-test-subj={`${editMode ? 'update' : 'save'}PackButton`}
>
{editMode ? (
<FormattedMessage
Expand Down

0 comments on commit 9105d07

Please sign in to comment.