Skip to content

Commit

Permalink
[Onboarding] Fix failing Cypress tests (elastic#186898)
Browse files Browse the repository at this point in the history
## Summary

Fixes [failng Cypress
tests](https://buildkite.com/elastic/kibana-pull-request/builds/217616#01904f09-ffdb-4ef4-8cc4-84ed91834b25)
by adding a payload with required `agentId` to 'ea-status': 'complete'
progress step.
  • Loading branch information
mykolaharmash authored Jun 26, 2024
1 parent 97c57b6 commit 4468ce5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ describe('[Logs onboarding] Custom logs - install elastic agent', () => {
});

it('shows a success callout when elastic agent status is healthy', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
cy.getByTestSubj('obltOnboardingStepStatus-complete')
.contains('Connected to the Elastic Agent')
.should('exist');
Expand Down Expand Up @@ -299,7 +301,9 @@ describe('[Logs onboarding] Custom logs - install elastic agent', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
});

it('shows loading callout when config is being downloaded to the host', () => {
Expand Down Expand Up @@ -340,7 +344,9 @@ describe('[Logs onboarding] Custom logs - install elastic agent', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
});

it('shows loading callout when config is being downloaded to the host', () => {
Expand Down Expand Up @@ -424,7 +430,9 @@ describe('[Logs onboarding] Custom logs - install elastic agent', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
cy.updateInstallationStepStatus(onboardingId, 'ea-config', 'complete');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ describe('[Logs onboarding] System logs', () => {
});

it('shows a success callout when elastic agent status is healthy', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
cy.getByTestSubj('obltOnboardingStepStatus-complete')
.contains('Connected to the Elastic Agent')
.should('exist');
Expand Down Expand Up @@ -330,7 +332,9 @@ describe('[Logs onboarding] System logs', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
});

it('shows loading callout when config is being downloaded to the host', () => {
Expand Down Expand Up @@ -371,7 +375,9 @@ describe('[Logs onboarding] System logs', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
});

it('shows loading callout when config is being downloaded to the host', () => {
Expand Down Expand Up @@ -456,7 +462,9 @@ describe('[Logs onboarding] System logs', () => {
cy.updateInstallationStepStatus(onboardingId, 'ea-download', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-extract', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-install', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete');
cy.updateInstallationStepStatus(onboardingId, 'ea-status', 'complete', {
agentId: 'test-agent-id',
});
cy.updateInstallationStepStatus(onboardingId, 'ea-config', 'complete');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export type InstallationStepStatus =
| 'danger'
| 'current';

export interface ElasticAgentStepPayload {
agentId: string;
}

Cypress.Commands.add('loginAsViewerUser', () => {
return cy.loginAs({
username: ObservabilityOnboardingUsername.viewerUser,
Expand Down Expand Up @@ -151,7 +155,12 @@ Cypress.Commands.add('deleteIntegration', (integrationName: string) => {

Cypress.Commands.add(
'updateInstallationStepStatus',
(onboardingId: string, step: InstallationStep, status: InstallationStepStatus) => {
(
onboardingId: string,
step: InstallationStep,
status: InstallationStepStatus,
payload: ElasticAgentStepPayload | undefined
) => {
const kibanaUrl = Cypress.env('KIBANA_URL');

cy.log(onboardingId, step, status);
Expand All @@ -166,6 +175,7 @@ Cypress.Commands.add(
auth: { user: 'editor', pass: 'changeme' },
body: {
status,
payload,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ declare namespace Cypress {
updateInstallationStepStatus(
onboardingId: string,
step: InstallationStep,
status: InstallationStepStatus
status: InstallationStepStatus,
payload?: ElasticAgentStepPayload
): void;
}
}

0 comments on commit 4468ce5

Please sign in to comment.