From ed32e98bd759035b3418616f055fa3da1e65db99 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Date: Mon, 29 Apr 2024 15:51:25 -0400 Subject: [PATCH] [RHOAIENG-6606] Correctly nav to application from Jupyter card --- .../cypress/e2e/applications/enabled.cy.ts | 33 +++++++++++++++++++ .../cypress/cypress/pages/components/Card.ts | 4 +++ frontend/src/components/OdhAppCard.tsx | 6 +++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/frontend/src/__tests__/cypress/cypress/e2e/applications/enabled.cy.ts b/frontend/src/__tests__/cypress/cypress/e2e/applications/enabled.cy.ts index 1fa1d8741a..20408c6cf8 100644 --- a/frontend/src/__tests__/cypress/cypress/e2e/applications/enabled.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/e2e/applications/enabled.cy.ts @@ -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(() => { @@ -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'); + }); }); diff --git a/frontend/src/__tests__/cypress/cypress/pages/components/Card.ts b/frontend/src/__tests__/cypress/cypress/pages/components/Card.ts index a6f776658a..96197f4340 100644 --- a/frontend/src/__tests__/cypress/cypress/pages/components/Card.ts +++ b/frontend/src/__tests__/cypress/cypress/pages/components/Card.ts @@ -33,6 +33,10 @@ export class Card { return this.find().findByTestId('cardbody'); } + findApplicationLink(): Cypress.Chainable> { + return this.find().findByTestId('jupyter-app-link'); + } + findExploreCard(metadataName: string): Cypress.Chainable> { return cy.findByTestId(['card', metadataName]); } diff --git a/frontend/src/components/OdhAppCard.tsx b/frontend/src/components/OdhAppCard.tsx index cbd863e826..5f07c0d490 100644 --- a/frontend/src/components/OdhAppCard.tsx +++ b/frontend/src/components/OdhAppCard.tsx @@ -105,7 +105,11 @@ const OdhAppCard: React.FC = ({ odhApp }) => { {odhApp.metadata.name === 'jupyter' ? ( odhApp.spec.internalRoute ? ( - + Launch application ) : null