Skip to content

Commit

Permalink
[RHOAIENG-6606] Correctly nav to application from Jupyter card
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Apr 29, 2024
1 parent 9d58a69 commit 7089120
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { RoleBindingSubject } from '~/types';
import { mockComponents } from '~/__mocks__/mockComponents';
import { enabledPage } from '~/__tests__/cypress/cypress/pages/enabled';
import { jupyterCard } from '~/__tests__/cypress/cypress/pages/components/JupyterCard';
import { mockDashboardConfig, mockK8sResourceList } from '~/__mocks__';
import { mockRoleBindingK8sResource } from '~/__mocks__/mockRoleBindingK8sResource';

describe('Enabled Page', () => {
beforeEach(() => {
Expand All @@ -20,4 +23,34 @@ describe('Enabled Page', () => {
'A multi-user version of the notebook designed for companies, classrooms and research labs.',
);
});
it('should navigate to the notebook controller spawner page', () => {
const groupSubjects: RoleBindingSubject[] = [
{
kind: 'Group',
apiGroup: 'rbac.authorization.k8s.io',
name: 'group-1',
},
];
cy.interceptOdh(
'GET /api/rolebindings/opendatahub/openshift-ai-notebooks-image-pullers',
mockK8sResourceList([
mockRoleBindingK8sResource({
name: 'group-1',
subjects: groupSubjects,
roleRefName: 'edit',
}),
]),
);

enabledPage.visit();
jupyterCard.findApplicationLink().click();
cy.findByTestId('app-page-title').should('have.text', 'Start a notebook server');

// Now validate with the home page feature flag enabled
cy.interceptOdh('GET /api/config', mockDashboardConfig({ disableHome: false }));

enabledPage.visit(true);
jupyterCard.findApplicationLink().click();
cy.findByTestId('app-page-title').should('have.text', 'Start a notebook server');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class Card {
return this.find().findByTestId('cardbody');
}

findApplicationLink(): Cypress.Chainable<JQuery<HTMLElement>> {
return this.find().findByTestId('jupyter-app-link');
}

findExploreCard(metadataName: string): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.findByTestId(['card', metadataName]);
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/OdhAppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {
<CardFooter className="odh-card__footer">
{odhApp.metadata.name === 'jupyter' ? (
odhApp.spec.internalRoute ? (
<Link to={odhApp.spec.internalRoute} className="odh-card__footer__link">
<Link
data-testid="jupyter-app-link"
to={`/${odhApp.spec.internalRoute}`}
className="odh-card__footer__link"
>
Launch application
</Link>
) : null
Expand Down

0 comments on commit 7089120

Please sign in to comment.