forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Add trained model list permission UI tests (elastic#174045)
## Summary This PR adds more functional ui tests around trained model listing and what a full access user vs a view only user can see and do. There is more of a focus on the Add Trained Model Flyout, as that is a newer feature. ### Details - Add data test subjects for: - space aware warning "copy" - add trained model button - trained model flyout - trained model flyout close button - trained model flyout Elser model "copy" - trained model flyout `Manual Download` tab - trained model flyout `Click to Download` tab - trained model flyout `Choose Model` panels - trained model flyout `Download` button - trained model flyout eland pip install code block - trained model flyout eland conda install code block - trained model flyout eland example import code block Note: Added a helper function to make the dynamic data test subjects for the `Click to Download` and `Manual Download` easy to reason about. It is used in the DOM and within the test service method. - Add tests to the `trained models` suite - Add new provider for `Add Trained Model` Flyout - add service methods: - asserting that while an ml power user can access two tabs within the flyout, a viewer user can only see 1, the manual download tab. - to open and close the flyout - assert the download button exists - assert e5 panels exist - assert eland python code blocks exist - assert elser model copy - assert elser panels exist - Modify the api's `deleteIngestPipeline` as it was failing in CI, when an `it` block failed - No you can choose whether to assert and it the assertion is made, the logging occurs as well. - Modify `trained models` provider, adding: - method to close the modal that pops up when a model requested to be deleted, cannot be - method to select a model by name - Modify `trained models table` provider, adding: - method asserting the contents of the warning for why a given model cannot be deleted, upon attempting to delete said model that resides in a space or spaces, that the current user cannot see. --------- Co-authored-by: Dima Arnautov <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Robert Oskamp <[email protected]>
- Loading branch information
1 parent
b4eed69
commit 92718c6
Showing
9 changed files
with
276 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
x-pack/test/functional/services/ml/add_trained_models_flyout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import type { AddModelFlyoutTabId } from '@kbn/ml-plugin/public/application/model_management/add_model_flyout'; | ||
import type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export function TrainedModelsFlyoutProvider({ getService }: FtrProviderContext) { | ||
const testSubjects = getService('testSubjects'); | ||
const retry = getService('retry'); | ||
|
||
return { | ||
async assertElserModelHeaderCopy(): Promise<void> { | ||
await testSubjects.existOrFail('mlAddTrainedModelFlyoutElserModelHeaderCopy', { | ||
timeout: 3_000, | ||
}); | ||
}, | ||
|
||
async assertElserPanelsExist(): Promise<void> { | ||
await testSubjects.existOrFail('mlAddTrainedModelFlyoutModelPanel-elser-.elser_model_2', { | ||
timeout: 3_000, | ||
}); | ||
await testSubjects.existOrFail( | ||
'mlAddTrainedModelFlyoutModelPanel-elser-.elser_model_2_linux-x86_64', | ||
{ | ||
timeout: 3_000, | ||
} | ||
); | ||
}, | ||
|
||
async assertE5PanelsExist(): Promise<void> { | ||
await testSubjects.existOrFail( | ||
'mlAddTrainedModelFlyoutModelPanel-e5-.multilingual-e5-small', | ||
{ | ||
timeout: 3_000, | ||
} | ||
); | ||
await testSubjects.existOrFail( | ||
'mlAddTrainedModelFlyoutModelPanel-e5-.multilingual-e5-small_linux-x86_64', | ||
{ | ||
timeout: 3_000, | ||
} | ||
); | ||
}, | ||
|
||
async assertDownloadButtonExists(): Promise<void> { | ||
await testSubjects.existOrFail('mlAddTrainedModelFlyoutDownloadButton', { | ||
timeout: 3_000, | ||
}); | ||
}, | ||
|
||
async assertOpen(expectOpen: boolean): Promise<void> { | ||
if (expectOpen) { | ||
await testSubjects.existOrFail('mlAddTrainedModelFlyout', { | ||
timeout: 3_000, | ||
}); | ||
} else { | ||
await testSubjects.missingOrFail('mlAddTrainedModelFlyout', { | ||
timeout: 3_000, | ||
}); | ||
} | ||
}, | ||
|
||
async open() { | ||
await retry.tryForTime(3_000, async () => { | ||
await testSubjects.click('mlModelsAddTrainedModelButton'); | ||
await this.assertOpen(true); | ||
}); | ||
}, | ||
|
||
async close(): Promise<void> { | ||
await retry.tryForTime(3_000, async () => { | ||
await testSubjects.click('euiFlyoutCloseButton'); | ||
await this.assertOpen(false); | ||
}); | ||
}, | ||
|
||
async assertFlyoutTabs(tabs: AddModelFlyoutTabId[]): Promise<void> { | ||
const expectedTabCount = tabs.length; | ||
const actualTabs = await testSubjects.findAll('~mlAddTrainedModelFlyoutTab', 3_000); | ||
const actualTabCount = actualTabs.length; | ||
|
||
expect(actualTabCount).to.be(expectedTabCount); | ||
|
||
for await (const tab of tabs) | ||
await testSubjects.existOrFail(`mlAddTrainedModelFlyoutTab ${tab}`, { | ||
timeout: 3_000, | ||
}); | ||
}, | ||
|
||
async assertElandPythonClientCodeBlocks() { | ||
expect(await testSubjects.getVisibleText('mlElandPipInstallCodeBlock')).to.match( | ||
/python -m pip install eland/ | ||
); | ||
expect(await testSubjects.getVisibleText('mlElandCondaInstallCodeBlock')).to.match( | ||
/conda install -c conda-forge eland/ | ||
); | ||
expect(await testSubjects.getVisibleText('mlElandExampleImportCodeBlock')).to.match( | ||
/eland_import_hub_model/ | ||
); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.