Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHOAIENG-7073] Fix for cancel on spawn a notebook server page #2807

Merged
Merged
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 @@ -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
Loading