diff --git a/x-pack/test/functional/apps/aiops/log_rate_analysis.ts b/x-pack/test/functional/apps/aiops/log_rate_analysis.ts index fec1156b76d43..f13ac5133325d 100644 --- a/x-pack/test/functional/apps/aiops/log_rate_analysis.ts +++ b/x-pack/test/functional/apps/aiops/log_rate_analysis.ts @@ -20,6 +20,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const elasticChart = getService('elasticChart'); const aiops = getService('aiops'); const retry = getService('retry'); + const cases = getService('cases'); // AIOps / Log Rate Analysis lives in the ML UI so we need some related services. const ml = getService('ml'); @@ -323,6 +324,92 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { } describe('log rate analysis', function () { + describe('attachments', function () { + const testData = logRateAnalysisTestData[0]; + + before(async () => { + await aiops.logRateAnalysisDataGenerator.generateData(testData.dataGenerator); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); + await ml.testResources.createDataViewIfNeeded( + testData.sourceIndexOrSavedSearch, + '@timestamp' + ); + await ml.navigation.navigateToMl(); + }); + + after(async () => { + await elasticChart.setNewChartUiDebugFlag(false); + await ml.testResources.deleteDataViewByTitle(testData.sourceIndexOrSavedSearch); + await aiops.logRateAnalysisDataGenerator.removeGeneratedData(testData.dataGenerator); + await cases.api.deleteAllCases(); + }); + + it('attaches log rate analysis to a dashboard', async () => { + await aiops.logRateAnalysisPage.navigateToDataViewSelection(); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} loads the log rate analysis page with selected data source` + ); + await ml.jobSourceSelection.selectSourceForLogRateAnalysis( + testData.sourceIndexOrSavedSearch + ); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} starting dashboard attachment process` + ); + await aiops.logRateAnalysisPage.attachToDashboard(); + }); + + it('attaches log rate analysis to a case', async () => { + await ml.navigation.navigateToMl(); + + await aiops.logRateAnalysisPage.navigateToDataViewSelection(); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} loads the log rate analysis page with selected data source` + ); + await ml.jobSourceSelection.selectSourceForLogRateAnalysis( + testData.sourceIndexOrSavedSearch + ); + + await ml.testExecution.logTestStep('asserts the attach to case button is disabled'); + await aiops.logRateAnalysisPage.openAttachmentsMenu(); + await aiops.logRateAnalysisPage.assertAttachToCaseButtonDisabled(); + + await ml.testExecution.logTestStep(`${testData.suiteTitle} loads data for full time range`); + + await aiops.logRateAnalysisPage.clickUseFullDataButton( + testData.expected.totalDocCountFormatted + ); + + await ml.testExecution.logTestStep('clicks the document count chart to start analysis'); + await aiops.logRateAnalysisPage.clickDocumentCountChart(testData.chartClickCoordinates); + + if (!testData.autoRun) { + await aiops.logRateAnalysisPage.assertNoAutoRunButtonExists(); + await aiops.logRateAnalysisPage.clickNoAutoRunButton(); + } + + await aiops.logRateAnalysisPage.assertAnalysisSectionExists(); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} starting cases attachment process` + ); + + const caseParams = { + title: testData.suiteTitle, + description: `Description for ${testData.suiteTitle}`, + tag: 'ml_log_rate_analysis', + reporter: USER.ML_POWERUSER, + }; + + await aiops.logRateAnalysisPage.attachToCase(caseParams); + + await ml.cases.assertCaseWithLogRateAnalysisAttachment(caseParams); + }); + }); + for (const testData of logRateAnalysisTestData) { describe(`with '${testData.sourceIndexOrSavedSearch}'`, function () { before(async () => { @@ -349,72 +436,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await elasticChart.setNewChartUiDebugFlag(true); }); - it(`${testData.suiteTitle} attaches log rate analysis to a dashboard`, async () => { - await aiops.logRateAnalysisPage.navigateToDataViewSelection(); - - await ml.testExecution.logTestStep( - `${testData.suiteTitle} loads the log rate analysis page with selected data source` - ); - await ml.jobSourceSelection.selectSourceForLogRateAnalysis( - testData.sourceIndexOrSavedSearch - ); - - await ml.testExecution.logTestStep( - `${testData.suiteTitle} starting dashboard attachment process` - ); - await aiops.logRateAnalysisPage.attachToDashboard(); - - await ml.navigation.navigateToMl(); - }); - - it(`${testData.suiteTitle} attaches log rate analysis to a case`, async () => { - await aiops.logRateAnalysisPage.navigateToDataViewSelection(); - - await ml.testExecution.logTestStep( - `${testData.suiteTitle} loads the log rate analysis page with selected data source` - ); - await ml.jobSourceSelection.selectSourceForLogRateAnalysis( - testData.sourceIndexOrSavedSearch - ); - - await ml.testExecution.logTestStep('asserts the attach to case button is disabled'); - await aiops.logRateAnalysisPage.openAttachmentsMenu(); - await aiops.logRateAnalysisPage.assertAttachToCaseButtonDisabled(); - - await ml.testExecution.logTestStep( - `${testData.suiteTitle} loads data for full time range` - ); - - await aiops.logRateAnalysisPage.clickUseFullDataButton( - testData.expected.totalDocCountFormatted - ); - - await ml.testExecution.logTestStep('clicks the document count chart to start analysis'); - await aiops.logRateAnalysisPage.clickDocumentCountChart(testData.chartClickCoordinates); - - if (!testData.autoRun) { - await aiops.logRateAnalysisPage.assertNoAutoRunButtonExists(); - await aiops.logRateAnalysisPage.clickNoAutoRunButton(); - } - - await aiops.logRateAnalysisPage.assertAnalysisSectionExists(); - - await ml.testExecution.logTestStep( - `${testData.suiteTitle} starting dashboard attachment process` - ); - const caseParams = { - title: testData.suiteTitle, - description: `Description for ${testData.suiteTitle}`, - tag: 'ml_log_rate_analysis', - reporter: USER.ML_POWERUSER, - }; - await aiops.logRateAnalysisPage.attachToCase(caseParams); - - await ml.cases.assertCaseWithLogRateAnalysisAttachment(caseParams); - - await ml.navigation.navigateToMl(); - }); - runTests(testData); }); }