Skip to content

Commit

Permalink
Convert agent installation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mykolaharmash committed Jan 3, 2025
1 parent 4a710e0 commit 740b0d5
Show file tree
Hide file tree
Showing 3 changed files with 838 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,91 @@ export class CustomLogsPage {
}
}

async updateInstallationStepStatus(
onboardingId: string,
step: string,
status: string,
payload?: object
) {
await this.kbnClient.request({
method: 'POST',
path: `/internal/observability_onboarding/flow/${onboardingId}/step/${step}`,
body: {
status,
payload,
},
});
}

customIntegrationSuccessCallout() {
return this.page.testSubj.locator('obltOnboardingCustomIntegrationInstalled');
}

customIntegrationErrorCallout() {
return this.page.testSubj.locator('obltOnboardingCustomIntegrationErrorCallout');
}

apiKeyCreateSuccessCallout() {
return this.page.testSubj.locator('obltOnboardingLogsApiKeyCreated');
}

apiKeyPrivilegesErrorCallout() {
return this.page.testSubj.locator('obltOnboardingLogsApiKeyCreationNoPrivileges');
}

apiKeyCreateErrorCallout() {
return this.page.testSubj.locator('obltOnboardingLogsApiKeyCreationFailed');
}

linuxCodeSnippetButton() {
return this.page.testSubj.locator('linux-tar');
}

macOSCodeSnippetButton() {
return this.page.testSubj.locator('macos');
}

windowsCodeSnippetButton() {
return this.page.testSubj.locator('windows');
}

autoDownloadConfigurationToggle() {
return this.page.testSubj.locator('obltOnboardingInstallElasticAgentAutoDownloadConfig');
}

autoDownloadConfigurationCallout() {
return this.page.testSubj.locator('obltOnboardingInstallElasticAgentAutoDownloadConfigCallout');
}

installCodeSnippet() {
return this.page.testSubj.locator('obltOnboardingInstallElasticAgentStep').getByRole('code');
}

windowsInstallElasticAgentDocLink() {
return this.page.testSubj.locator('obltOnboardingInstallElasticAgentWindowsDocsLink');
}

configureElasticAgentStep() {
return this.page.testSubj.locator('obltOnboardingConfigureElasticAgentStep');
}

downloadConfigurationButton() {
return this.page.testSubj.locator('obltOnboardingConfigureElasticAgentStepDownloadConfig');
}

stepStatusLoading() {
return this.page.testSubj.locator('obltOnboardingStepStatus-loading');
}

stepStatusComplete() {
return this.page.testSubj.locator('obltOnboardingStepStatus-complete');
}

stepStatusDanger() {
return this.page.testSubj.locator('obltOnboardingStepStatus-danger');
}

stepStatusWarning() {
return this.page.testSubj.locator('obltOnboardingStepStatus-warning');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import { expect } from '@kbn/scout';
import { test } from '../fixtures';
import { test } from '../../fixtures';

test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@svlOblt'] }, () => {
test.describe('Onboarding app - Custom logs configuration', { tag: ['@ess', '@svlOblt'] }, () => {
test.beforeEach(async ({ browserAuth, pageObjects: { customLogsPage } }) => {
await browserAuth.loginAsViewer();
await browserAuth.loginAsAdmin();
await customLogsPage.goto();
});

Expand All @@ -22,121 +22,102 @@ test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@
expect(page.url()).toContain('/app/observabilityOnboarding');
});

test.describe('Log file path inputs', () => {
test(`Users shouldn't be able to continue if logFilePaths is empty`, async ({
pageObjects: { customLogsPage },
}) => {
await expect(customLogsPage.logFilePathInput(0)).toHaveValue('');
await expect(customLogsPage.continueButton()).toBeDisabled();
});
test(`Users shouldn't be able to continue if logFilePaths is empty`, async ({
pageObjects: { customLogsPage },
}) => {
await expect(customLogsPage.logFilePathInput(0)).toHaveValue('');
await expect(customLogsPage.continueButton()).toBeDisabled();
});

test(`Users should be able to continue if logFilePaths is not empty`, async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('some/path');
test(`Users should be able to continue if logFilePaths is not empty`, async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('some/path');

await expect(customLogsPage.continueButton()).not.toBeDisabled();
});
await expect(customLogsPage.continueButton()).not.toBeDisabled();
});

test('Users can add multiple logFilePaths', async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.addLogFilePathButton().click();
await expect(customLogsPage.logFilePathInput(0)).toBeVisible();
await expect(customLogsPage.logFilePathInput(1)).toBeVisible();
});
test('Users can add multiple logFilePaths', async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.addLogFilePathButton().click();
await expect(customLogsPage.logFilePathInput(0)).toBeVisible();
await expect(customLogsPage.logFilePathInput(1)).toBeVisible();
});

test('Users can delete logFilePaths', async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.addLogFilePathButton().click();
await expect(customLogsPage.logFilePathList()).toHaveCount(2);
test('Users can delete logFilePaths', async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.addLogFilePathButton().click();
await expect(customLogsPage.logFilePathList()).toHaveCount(2);

await customLogsPage.logFilePathDeleteButton(1).click();
await expect(customLogsPage.logFilePathList()).toHaveCount(1);
});
await customLogsPage.logFilePathDeleteButton(1).click();
await expect(customLogsPage.logFilePathList()).toHaveCount(1);
});

test.describe('when users fill logFilePaths', () => {
test('datasetname and integration name are auto generated if it is the first path', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('myLogs.log');
test('Dataset Name and Integration Name are auto generated if it is the first path', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('myLogs.log');

await expect(customLogsPage.integrationNameInput()).toHaveValue('mylogs');
await expect(customLogsPage.datasetNameInput()).toHaveValue('mylogs');
});
await expect(customLogsPage.integrationNameInput()).toHaveValue('mylogs');
await expect(customLogsPage.datasetNameInput()).toHaveValue('mylogs');
});

test('datasetname and integration name are not generated if it is not the first path', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.addLogFilePathButton().click();
await customLogsPage.logFilePathInput(1).fill('myLogs.log');
test('Dataset Name and Integration Name are not generated if it is not the first path', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.addLogFilePathButton().click();
await customLogsPage.logFilePathInput(1).fill('myLogs.log');

await expect(customLogsPage.integrationNameInput()).toHaveValue('');
await expect(customLogsPage.datasetNameInput()).toHaveValue('');
});
});
await expect(customLogsPage.integrationNameInput()).toHaveValue('');
await expect(customLogsPage.datasetNameInput()).toHaveValue('');
});

test.describe('Service name input', () => {
test('should be optional allowing user to continue if it is empty', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('myLogs.log');
test('Service name input should be optional allowing user to continue if it is empty', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('myLogs.log');

await expect(customLogsPage.serviceNameInput()).toHaveValue('');
await expect(customLogsPage.continueButton()).not.toBeDisabled();
});
await expect(customLogsPage.serviceNameInput()).toHaveValue('');
await expect(customLogsPage.continueButton()).not.toBeDisabled();
});

test.describe('Advanced settings', () => {
test('Users should expand and collapse the section', async ({
pageObjects: { customLogsPage },
}) => {
await expect(customLogsPage.namespaceInput()).not.toBeInViewport();
await expect(customLogsPage.customConfigInput()).not.toBeInViewport();
test('Users should expand and collapse the Advanced settings section', async ({
pageObjects: { customLogsPage },
}) => {
await expect(customLogsPage.namespaceInput()).not.toBeInViewport();
await expect(customLogsPage.customConfigInput()).not.toBeInViewport();

await customLogsPage.clickAdvancedSettingsButton();
await customLogsPage.clickAdvancedSettingsButton();

await expect(customLogsPage.namespaceInput()).toBeInViewport();
await expect(customLogsPage.customConfigInput()).toBeInViewport();
await expect(customLogsPage.namespaceInput()).toBeInViewport();
await expect(customLogsPage.customConfigInput()).toBeInViewport();

await customLogsPage.clickAdvancedSettingsButton();
await customLogsPage.clickAdvancedSettingsButton();

await expect(customLogsPage.namespaceInput()).not.toBeInViewport();
await expect(customLogsPage.customConfigInput()).not.toBeInViewport();
});

test.describe('Namespace', () => {
test.beforeEach(async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.clickAdvancedSettingsButton();
});
await expect(customLogsPage.namespaceInput()).not.toBeInViewport();
await expect(customLogsPage.customConfigInput()).not.toBeInViewport();
});

test('Users should see a default namespace', async ({ pageObjects: { customLogsPage } }) => {
await expect(customLogsPage.namespaceInput()).toHaveValue('default');
});
test('Users should see a default namespace', async ({ pageObjects: { customLogsPage } }) => {
customLogsPage.clickAdvancedSettingsButton();

test('Users should not be able to continue if they do not specify a namespace', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.namespaceInput().fill('');
await expect(customLogsPage.continueButton()).toBeDisabled();
});
});
await expect(customLogsPage.namespaceInput()).toHaveValue('default');
});

test.describe('Custom config', () => {
test.beforeEach(async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.clickAdvancedSettingsButton();
});
test('Users should not be able to continue if they do not specify a namespace', async ({
pageObjects: { customLogsPage },
}) => {
customLogsPage.clickAdvancedSettingsButton();

test.afterEach(async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.clickAdvancedSettingsButton();
});
await customLogsPage.namespaceInput().fill('');
await expect(customLogsPage.continueButton()).toBeDisabled();
});

test('should be optional allowing user to continue if it is empty', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.logFilePathInput(0).fill('myLogs.log');
await expect(customLogsPage.customConfigInput()).toHaveValue('');
await expect(customLogsPage.continueButton()).not.toBeDisabled();
});
});
test('should be optional allowing user to continue if it is empty', async ({
pageObjects: { customLogsPage },
}) => {
await customLogsPage.clickAdvancedSettingsButton();
await customLogsPage.logFilePathInput(0).fill('myLogs.log');
await expect(customLogsPage.customConfigInput()).toHaveValue('');
await expect(customLogsPage.continueButton()).not.toBeDisabled();
});

test.describe('Integration name', () => {
Expand Down Expand Up @@ -195,19 +176,25 @@ test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@
});
});

test.describe('custom integration', () => {
test.describe('Custom integration', () => {
const CUSTOM_INTEGRATION_NAME = 'mylogs';

test.beforeEach(async ({ pageObjects: { customLogsPage }, browserAuth }) => {
await browserAuth.loginAsAdmin();
test.beforeEach(async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.deleteIntegration(CUSTOM_INTEGRATION_NAME);
});

test.describe('when user is missing privileges', () => {
test('installation fails', async ({ browserAuth, pageObjects: { customLogsPage }, page }) => {
test.beforeEach(async ({ browserAuth, page }) => {
await browserAuth.loginAsViewer();
await page.reload();
});

test.afterEach(async ({ browserAuth, page }) => {
await browserAuth.loginAsAdmin();
await page.reload();
});

test('installation fails', async ({ pageObjects: { customLogsPage } }) => {
await customLogsPage.logFilePathInput(0).fill(`${CUSTOM_INTEGRATION_NAME}.log`);
await customLogsPage.continueButton().click();

Expand All @@ -221,9 +208,6 @@ test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@
page,
pageObjects: { customLogsPage },
}) => {
await browserAuth.loginAsAdmin();
await page.reload();

await customLogsPage.logFilePathInput(0).fill(`${CUSTOM_INTEGRATION_NAME}.log`);
await customLogsPage.continueButton().click();

Expand All @@ -236,9 +220,6 @@ test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@
pageObjects: { customLogsPage },
page,
}) => {
await browserAuth.loginAsAdmin();
await page.reload();

await customLogsPage.installCustomIntegration(CUSTOM_INTEGRATION_NAME);
await customLogsPage.logFilePathInput(0).fill(`${CUSTOM_INTEGRATION_NAME}.log`);
await customLogsPage.continueButton().click();
Expand All @@ -257,9 +238,6 @@ test.describe('Onboarding app - Custom logs quickstart flow', { tag: ['@ess', '@
page,
kbnUrl,
}) => {
await browserAuth.loginAsAdmin();
await page.reload();

await page.route(kbnUrl.get('/api/fleet/epm/custom_integrations'), (route) => {
route.fulfill({
status: 500,
Expand Down
Loading

0 comments on commit 740b0d5

Please sign in to comment.