Skip to content
Open
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 @@ -488,6 +488,10 @@ class ModelCatalog {
return cy.findByTestId('register-model-button');
}

findRegisterCatalogModelTooltip() {
return cy.findByTestId('register-catalog-model-tooltip');
}

findModelTypeSelect() {
return cy.findByTestId('register-model-type-select');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,24 @@ describe('Model Catalog Details Page - Edge Cases', () => {
cy.findAllByText('N/A').should('have.length.at.least', 1);
});

it('should show disabled register button with tooltip when no model registries exist', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add a cy.testA11y() to double check all accessibility violations are gone?

cy.intercept('GET', '/model-registry/api/v1/model_registry*', mockModArchResponse([])).as(
'getEmptyModelRegistries',
);

setupModelCatalogIntercepts({});
interceptArtifactsList();

modelCatalog.visit();
modelCatalog.findLoadingState().should('not.exist');
modelCatalog.findModelCatalogDetailLink().first().click();
modelCatalog.findBreadcrumb().should('exist');

modelCatalog.findRegisterModelButton().should('have.attr', 'aria-disabled', 'true');
modelCatalog.findRegisterModelButton().trigger('mouseenter');
modelCatalog.findRegisterCatalogModelTooltip().should('be.visible');
});

it('should show error alert when artifacts fail to load', () => {
setupModelCatalogIntercepts({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
StackItem,
Button,
Popover,
Tooltip,
ActionListGroup,
Skeleton,
Label,
Expand Down Expand Up @@ -57,17 +58,24 @@ const ModelDetailsPage: React.FC<ModelDetailsPageProps> = ({ tab }) => {
encodeURIComponent(`${decodedParams.modelName}`),
);

const registerButtonPopover = (headerContent: string, bodyContent: string) => (
<Popover
headerContent={headerContent}
triggerAction="hover"
data-testid="register-catalog-model-popover"
bodyContent={<div>{bodyContent}</div>}
const registerButtonTooltip = (headerContent: string, bodyContent: string) => (
<Tooltip
content={
headerContent ? (
<div>
<strong>{headerContent}</strong>
<div>{bodyContent}</div>
</div>
) : (
bodyContent
)
}
data-testid="register-catalog-model-tooltip"
>
<Button variant="primary" isAriaDisabled data-testid="register-model-button">
Register model
</Button>
</Popover>
</Tooltip>
);

const registerModelButton = () => {
Expand All @@ -76,7 +84,7 @@ const ModelDetailsPage: React.FC<ModelDetailsPageProps> = ({ tab }) => {
}

if (artifactsLoadError) {
return registerButtonPopover(
return registerButtonTooltip(
'Unable to load model artifacts',
'Model registration is unavailable due to an error loading model artifacts. Please try again later.',
);
Expand All @@ -91,12 +99,12 @@ const ModelDetailsPage: React.FC<ModelDetailsPageProps> = ({ tab }) => {
}

return modelRegistries.length === 0 ? (
registerButtonPopover(
registerButtonTooltip(
'Request access to a model registry',
'To request a new model registry, or to request permission to access an existing model registry, contact your administrator.',
)
) : artifacts.items.length === 0 || !hasModelArtifacts(artifacts.items) ? (
registerButtonPopover('', 'Model location is unavailable')
registerButtonTooltip('', 'Model location is unavailable')
) : (
<Button
data-testid="register-model-button"
Expand Down
Loading