Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support incoming Preconfigured Endpoints #203473

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ describe('Delete Action', () => {
it('renders', () => {
render(<Wrapper item={mockItem} />);

expect(screen.getByTestId('inferenceUIDeleteAction')).toBeEnabled();
expect(screen.getByTestId(/inferenceUIDeleteAction/)).toBeEnabled();
});

it('disable the delete action for preconfigured endpoint', () => {
const preconfiguredMockItem = { ...mockItem, endpoint: '.multilingual-e5-small-elasticsearch' };
render(<Wrapper item={preconfiguredMockItem} />);

expect(screen.getByTestId('inferenceUIDeleteAction')).toBeDisabled();
expect(screen.getByTestId(/inferenceUIDeleteAction/)).toBeDisabled();
});

it('loads confirm delete modal', () => {
render(<Wrapper item={mockItem} />);

fireEvent.click(screen.getByTestId('inferenceUIDeleteAction'));
fireEvent.click(screen.getByTestId(/inferenceUIDeleteAction/));
expect(screen.getByTestId('deleteModalForInferenceUI')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export const DeleteAction: React.FC<DeleteActionProps> = ({ selectedEndpoint })
});
};

const isPreconfigured = isEndpointPreconfigured(selectedEndpoint.endpoint);
const testSubj = `inferenceUIDeleteAction-${isPreconfigured ? 'preconfigured' : 'user-defined'}`;

return (
<>
<EuiButtonIcon
aria-label={i18n.translate('xpack.searchInferenceEndpoints.actions.deleteEndpoint', {
defaultMessage: 'Delete inference endpoint {selectedEndpointName}',
values: { selectedEndpointName: selectedEndpoint.endpoint },
})}
data-test-subj="inferenceUIDeleteAction"
disabled={isEndpointPreconfigured(selectedEndpoint.endpoint)}
data-test-subj={testSubj}
disabled={isPreconfigured}
key="delete"
iconType="trash"
color="danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('When the tabular page is loaded', () => {
it('should only disable delete action for preconfigured endpoints', () => {
render(<TabularPage inferenceEndpoints={inferenceEndpoints} />);

const deleteActions = screen.getAllByTestId('inferenceUIDeleteAction');
const deleteActions = screen.getAllByTestId(/inferenceUIDeleteAction/);

expect(deleteActions[0]).toBeDisabled();
expect(deleteActions[1]).toBeDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,29 @@ export function SvlSearchInferenceManagementPageProvider({ getService }: FtrProv

const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');
expect(rows.length).to.equal(2);
// we need at least one (ELSER) otherwise index_mapping might experience some issues
expect(rows.length).to.greaterThan(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check that one of the entries contains an ELSER endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const elserEndpointCell = await rows[0].findByTestSubject('endpointCell');
const elserEndpointName = await elserEndpointCell.getVisibleText();
expect(elserEndpointName).to.contain('.elser-2-elasticsearch');
const texts = await Promise.all(rows.map((row) => row.getVisibleText()));
const hasElser2 = texts.some((text) => text.includes('.elser-2'));
const hasE5 = texts.some((text) => text.includes('.multilingual-e5'));

const elserProviderCell = await rows[0].findByTestSubject('providerCell');
const elserProviderName = await elserProviderCell.getVisibleText();
expect(elserProviderName).to.contain('Elasticsearch');
expect(elserProviderName).to.contain('.elser_model_2');

const elserTypeCell = await rows[0].findByTestSubject('typeCell');
const elserTypeName = await elserTypeCell.getVisibleText();
expect(elserTypeName).to.contain('sparse_embedding');

const e5EndpointCell = await rows[1].findByTestSubject('endpointCell');
const e5EndpointName = await e5EndpointCell.getVisibleText();
expect(e5EndpointName).to.contain('.multilingual-e5-small-elasticsearch');

const e5ProviderCell = await rows[1].findByTestSubject('providerCell');
const e5ProviderName = await e5ProviderCell.getVisibleText();
expect(e5ProviderName).to.contain('Elasticsearch');
expect(e5ProviderName).to.contain('.multilingual-e5-small');

const e5TypeCell = await rows[1].findByTestSubject('typeCell');
const e5TypeName = await e5TypeCell.getVisibleText();
expect(e5TypeName).to.contain('text_embedding');
expect(hasElser2).to.be(true);
expect(hasE5).to.be(true);
},

async expectPreconfiguredEndpointsCannotBeDeleted() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const elserDeleteAction = await rows[0].findByTestSubject('inferenceUIDeleteAction');
const e5DeleteAction = await rows[1].findByTestSubject('inferenceUIDeleteAction');

expect(await elserDeleteAction.isEnabled()).to.be(false);
expect(await e5DeleteAction.isEnabled()).to.be(false);
const preconfigureEndpoints = await testSubjects.findAll(
'inferenceUIDeleteAction-preconfigured'
);
for (const endpoint of preconfigureEndpoints) {
expect(await endpoint.isEnabled()).to.be(false);
}
},

async expectEndpointWithoutUsageTobeDelete() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const userCreatedEndpoint = await rows[2].findByTestSubject('inferenceUIDeleteAction');

await userCreatedEndpoint.click();
const userDefinedEdnpoint = await testSubjects.find('inferenceUIDeleteAction-user-defined');
await userDefinedEdnpoint.click();
await testSubjects.existOrFail('deleteModalForInferenceUI');
await testSubjects.existOrFail('deleteModalInferenceEndpointName');

Expand All @@ -83,12 +59,8 @@ export function SvlSearchInferenceManagementPageProvider({ getService }: FtrProv
},

async expectEndpointWithUsageTobeDelete() {
const table = await testSubjects.find('inferenceEndpointTable');
const rows = await table.findAllByClassName('euiTableRow');

const userCreatedEndpoint = await rows[2].findByTestSubject('inferenceUIDeleteAction');

await userCreatedEndpoint.click();
const userDefinedEdnpoint = await testSubjects.find('inferenceUIDeleteAction-user-defined');
await userDefinedEdnpoint.click();
await testSubjects.existOrFail('deleteModalForInferenceUI');
await testSubjects.existOrFail('deleteModalInferenceEndpointName');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.svlCommonPage.loginWithRole('developer');
});

after(async () => {
await ml.api.cleanMlIndices();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why are we removing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally added as part of the cleanup process, but now it feels excessive. Since we didn’t create any ml-* indices as part of the tests, I have decided to remove that step. Do you think it’s still necessary or good to have as part of the cleanup process?

});

beforeEach(async () => {
await svlSearchNavigation.navigateToInferenceManagementPage();
});
Expand Down
Loading