Skip to content

Commit

Permalink
update dfa model check and fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Oct 12, 2023
1 parent b0fbc64 commit cd69987
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
Expand Up @@ -538,7 +538,7 @@ export function useModelActions({
isPrimary: true,
available: isTestable,
onClick: (item) => {
if (isDfaTrainedModel(item)) {
if (isDfaTrainedModel(item) && !isBuiltInModel(item)) {
onDfaTestAction(item);
} else {
onTestAction(item);
Expand Down
Expand Up @@ -164,14 +164,12 @@ export default function ({ getService }: FtrProviderContext) {
true
);
await ml.testExecution.logTestStep('should show deploy action for the model in the table');
await ml.trainedModelsTable.assertModelDeployActionButtonExists(
await ml.trainedModelsTable.assertModelDeployActionButtonEnabled(
modelWithoutPipelineData.modelId,
true
);
await ml.testExecution.logTestStep('should open the deploy model flyout');
await ml.trainedModelsTable.openTrainedModelsInferenceFlyout(
modelWithoutPipelineData.modelId
);
await ml.trainedModelsTable.clickDeployAction(modelWithoutPipelineData.modelId);
await ml.testExecution.logTestStep('should complete the deploy model Details step');
await ml.deployDFAModelFlyout.completeTrainedModelsInferenceFlyoutDetails({
name: modelWithoutPipelineDataExpectedValues.name,
Expand Down Expand Up @@ -216,17 +214,15 @@ export default function ({ getService }: FtrProviderContext) {
);
await ml.trainedModelsTable.assertModelCollapsedActionsButtonExists(
modelWithoutPipelineData.modelId,
false
true
);
await ml.testExecution.logTestStep('should show deploy action for the model in the table');
await ml.trainedModelsTable.assertModelDeployActionButtonExists(
modelWithoutPipelineData.modelId,
true
false
);
await ml.testExecution.logTestStep('should open the deploy model flyout');
await ml.trainedModelsTable.openTrainedModelsInferenceFlyout(
modelWithoutPipelineData.modelId
);
await ml.trainedModelsTable.clickDeployAction(modelWithoutPipelineData.modelId);
await ml.testExecution.logTestStep('should complete the deploy model Details step');
await ml.deployDFAModelFlyout.completeTrainedModelsInferenceFlyoutDetails(
{
Expand Down
51 changes: 42 additions & 9 deletions x-pack/test/functional/services/ml/trained_models_table.ts
Expand Up @@ -254,15 +254,6 @@ export function TrainedModelsTableProvider(
await trainedModelsActions.testModelOutput(modelType, inputParams, expectedResult);
}

public async openTrainedModelsInferenceFlyout(modelId: string) {
await mlCommonUI.invokeTableRowAction(
this.rowSelector(modelId),
'mlModelsTableRowDeployAction',
false
);
await this.assertDeployModelFlyoutExists();
}

public async deleteModel(modelId: string) {
const fromContextMenu = await this.doesModelCollapsedActionsButtonExist(modelId);
await mlCommonUI.invokeTableRowAction(
Expand All @@ -276,6 +267,33 @@ export function TrainedModelsTableProvider(
await this.assertModelDisplayedInTable(modelId, false);
}

public async assertModelDeployActionButtonEnabled(modelId: string, expectedValue: boolean) {
const actionsButtonExists = await this.doesModelCollapsedActionsButtonExist(modelId);

let isEnabled = null;

if (actionsButtonExists) {
await this.toggleActionsContextMenu(modelId, true);
const panelElement = await find.byCssSelector('.euiContextMenuPanel');
const actionButton = await panelElement.findByTestSubject('mlModelsTableRowDeployAction');
isEnabled = await actionButton.isEnabled();
// escape popover
await browser.pressKeys(browser.keys.ESCAPE);
} else {
await this.assertModelDeployActionButtonExists(modelId, true);
isEnabled = await testSubjects.isEnabled(
this.rowSelector(modelId, 'mlModelsTableRowDeployAction')
);
}

expect(isEnabled).to.eql(
expectedValue,
`Expected row deploy action button for trained model '${modelId}' to be '${
expectedValue ? 'enabled' : 'disabled'
}' (got '${isEnabled ? 'enabled' : 'disabled'}')`
);
}

public async assertModelDeleteActionButtonEnabled(modelId: string, expectedValue: boolean) {
const actionsButtonExists = await this.doesModelCollapsedActionsButtonExist(modelId);

Expand Down Expand Up @@ -393,6 +411,21 @@ export function TrainedModelsTableProvider(
await this.assertDeleteModalExists();
}

public async clickDeployAction(modelId: string) {
const actionsButtonExists = await this.doesModelCollapsedActionsButtonExist(modelId);

if (actionsButtonExists) {
await this.toggleActionsContextMenu(modelId, true);
const panelElement = await find.byCssSelector('.euiContextMenuPanel');
const actionButton = await panelElement.findByTestSubject('mlModelsTableRowDeployAction');
await actionButton.click();
} else {
await testSubjects.click(this.rowSelector(modelId, 'mlModelsTableRowDeployAction'));
}

await this.assertDeployModelFlyoutExists();
}

async assertNumOfAllocations(expectedValue: number) {
const actualValue = await testSubjects.getAttribute(
'mlModelsStartDeploymentModalNumOfAllocations',
Expand Down

0 comments on commit cd69987

Please sign in to comment.