Skip to content

Commit

Permalink
Merge pull request opendatahub-io#2807 from jeff-phillips-18/jupyter-…
Browse files Browse the repository at this point in the history
…cancel

[RHOAIENG-7073] Fix for cancel on spawn a notebook server page
  • Loading branch information
openshift-merge-bot[bot] authored May 13, 2024
2 parents 54f4402 + de6d2c1 commit 97b878a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
{
Expand All @@ -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();
Expand Down Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ 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';
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 } =
Expand Down Expand Up @@ -358,12 +360,13 @@ const SpawnerPage: React.FC = () => {
</Button>
<Button
data-id="cancel-button"
data-testid="cancel-start-server-button"
variant="secondary"
onClick={() => {
if (impersonatedUsername) {
setImpersonating();
} else {
navigate('/');
navigate(isHomeAvailable ? '/enabled' : '/');
}
}}
>
Expand Down

0 comments on commit 97b878a

Please sign in to comment.