From de6d2c12b4c8c6c9b30ca4514010b39e65bb6871 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Date: Fri, 10 May 2024 14:44:23 -0400 Subject: [PATCH] [RHOAIENG-7073] Fix for cancel on spawn a notebook server page --- .../e2e/applications/NotebookServer.cy.ts | 19 ++++++++++++++++++- .../cypress/cypress/pages/notebookServer.ts | 4 ++++ .../screens/server/SpawnerPage.tsx | 7 +++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend/src/__tests__/cypress/cypress/e2e/applications/NotebookServer.cy.ts b/frontend/src/__tests__/cypress/cypress/e2e/applications/NotebookServer.cy.ts index 8a66b47dbb..f545f7e28b 100644 --- a/frontend/src/__tests__/cypress/cypress/e2e/applications/NotebookServer.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/e2e/applications/NotebookServer.cy.ts @@ -7,6 +7,7 @@ import { mockStartNotebookData } from '~/__mocks__/mockStartNotebookData'; import { notebookServer } from '~/__tests__/cypress/cypress/pages/notebookServer'; import { asProductAdminUser, asProjectEditUser } from '~/__tests__/cypress/cypress/utils/users'; import { notebookController } from '~/__tests__/cypress/cypress/pages/administration'; +import { homePage } from '~/__tests__/cypress/cypress/pages/home'; const groupSubjects: RoleBindingSubject[] = [ { @@ -31,7 +32,7 @@ const initIntercepts = () => { cy.interceptOdh('GET /api/status/openshift-ai-notebooks/allowedUsers', mockAllowedUsers({})); }; -it('Administartion tab should not be accessible for non-project admins', () => { +it('Administration tab should not be accessible for non-project admins', () => { initIntercepts(); asProjectEditUser(); notebookServer.visit(); @@ -93,4 +94,20 @@ describe('NotebookServer', () => { expect(interception.request.body).to.eql({ state: 'stopped', username: 'test-user' }); }); }); + + it('should return to the enabled page on cancel', () => { + homePage.initHomeIntercepts({ disableHome: false }); + notebookServer.visit(); + notebookServer.findCancelStartServerButton().should('be.visible'); + notebookServer.findCancelStartServerButton().click(); + + cy.findByTestId('app-page-title').should('have.text', 'Enabled'); + + homePage.initHomeIntercepts({ disableHome: true }); + notebookServer.visit(); + notebookServer.findCancelStartServerButton().should('be.visible'); + notebookServer.findCancelStartServerButton().click(); + + cy.findByTestId('app-page-title').should('have.text', 'Enabled'); + }); }); diff --git a/frontend/src/__tests__/cypress/cypress/pages/notebookServer.ts b/frontend/src/__tests__/cypress/cypress/pages/notebookServer.ts index dc51256c99..04c3b6c34f 100644 --- a/frontend/src/__tests__/cypress/cypress/pages/notebookServer.ts +++ b/frontend/src/__tests__/cypress/cypress/pages/notebookServer.ts @@ -25,6 +25,10 @@ class NotebookServer { return cy.findByTestId('start-server-button'); } + findCancelStartServerButton() { + return cy.findByTestId('cancel-start-server-button'); + } + findEventlog() { return cy.findByTestId('expand-logs').findByRole('button'); } diff --git a/frontend/src/pages/notebookController/screens/server/SpawnerPage.tsx b/frontend/src/pages/notebookController/screens/server/SpawnerPage.tsx index b5770a88fe..f05391d925 100644 --- a/frontend/src/pages/notebookController/screens/server/SpawnerPage.tsx +++ b/frontend/src/pages/notebookController/screens/server/SpawnerPage.tsx @@ -40,6 +40,7 @@ import useNamespaces from '~/pages/notebookController/useNamespaces'; import { fireTrackingEvent } from '~/utilities/segmentIOUtils'; import { getEnvConfigMap, getEnvSecret } from '~/services/envService'; import useNotebookAcceleratorProfile from '~/pages/projects/screens/detail/notebooks/useNotebookAcceleratorProfile'; +import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas'; import SizeSelectField from './SizeSelectField'; import useSpawnerNotebookModalState from './useSpawnerNotebookModalState'; import BrowserTabPreferenceCheckbox from './BrowserTabPreferenceCheckbox'; @@ -47,13 +48,14 @@ import EnvironmentVariablesRow from './EnvironmentVariablesRow'; import ImageSelector from './ImageSelector'; import { usePreferredNotebookSize } from './usePreferredNotebookSize'; import StartServerModal from './StartServerModal'; +import AcceleratorProfileSelectField from './AcceleratorProfileSelectField'; import '~/pages/notebookController/NotebookController.scss'; -import AcceleratorProfileSelectField from './AcceleratorProfileSelectField'; const SpawnerPage: React.FC = () => { const navigate = useNavigate(); const notification = useNotification(); + const isHomeAvailable = useIsAreaAvailable(SupportedArea.HOME).status; const { images, loaded, loadError } = useWatchImages(); const { buildStatuses } = useAppContext(); const { currentUserNotebook, requestNotebookRefresh, impersonatedUsername, setImpersonating } = @@ -358,12 +360,13 @@ const SpawnerPage: React.FC = () => {