From 20ef620478c118ab821440aab1ebd6e937e62709 Mon Sep 17 00:00:00 2001 From: Conor O'Malley Date: Thu, 12 Dec 2024 16:35:01 +0000 Subject: [PATCH] add improvements --- .../testNotebookCreation.yaml | 2 ++ .../testLaunchStandaloneNotebook.cy.ts | 27 ++++++++++++------- .../src/__tests__/cypress/cypress/types.ts | 4 +++ .../cypress/utils/oc_commands/baseCommands.ts | 8 ++++-- 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testNotebookCreation.yaml diff --git a/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testNotebookCreation.yaml b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testNotebookCreation.yaml new file mode 100644 index 0000000000..f64ab4470f --- /dev/null +++ b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testNotebookCreation.yaml @@ -0,0 +1,2 @@ +# testLaunchStandaloneNotebook.cy.ts Test Data # +codeserverImageName: "code-server-notebook:2024.1" \ No newline at end of file diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testLaunchStandaloneNotebook.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testLaunchStandaloneNotebook.cy.ts index c1952bd141..34642d1d37 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testLaunchStandaloneNotebook.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testLaunchStandaloneNotebook.cy.ts @@ -1,15 +1,24 @@ +import yaml from 'js-yaml'; import { HTPASSWD_CLUSTER_ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; import { projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; import { notebookServer } from '~/__tests__/cypress/cypress/pages/notebookServer'; +import type { NotebookImageData } from '~/__tests__/cypress/cypress/types'; import { waitForPodReady, deleteNotebook, } from '~/__tests__/cypress/cypress/utils/oc_commands/baseCommands'; describe('Verify a Jupyter Notebook can be launched directly from the Data Science Project List View', () => { + let testData: NotebookImageData; + before(() => { - // Check if a notebook is running and delete if it is - deleteNotebook('jupyter-nb'); + return cy + .fixture('e2e/dataScienceProjects/testNotebookCreation.yaml', 'utf8') + .then((yamlContent: string) => { + testData = yaml.load(yamlContent) as NotebookImageData; + // Check if a notebook is running and delete if it is + deleteNotebook('jupyter-nb'); + }); }); it('Verify User Can Access Jupyter Launcher From DS Project Page', () => { @@ -28,11 +37,11 @@ describe('Verify a Jupyter Notebook can be launched directly from the Data Scien // Select the versions dropdown cy.step('Select the code server versions dropdown'); - notebookServer.findVersionsDropdown('code-server-notebook:2024.1').click(); + notebookServer.findVersionsDropdown(testData.codeserverImageName).click(); - // Select a image version - cy.step('Select an image version'); - notebookServer.findNotebookVersion('code-server-notebook:2024.1').click(); + // Select an image version + cy.step('Select the codeserver image version'); + notebookServer.findNotebookVersion(testData.codeserverImageName).click(); // Verify that 'Start Server button' is enabled cy.step('Check Start server button is enabled'); @@ -44,11 +53,11 @@ describe('Verify a Jupyter Notebook can be launched directly from the Data Scien // Verify that the server is running cy.step('Verify the Jupyter Notebook pod is ready'); - waitForPodReady('jupyter-nb', '1000s'); - + waitForPodReady('jupyter-nb', '300s'); + // Expand the log cy.step('Expand the Event log'); - notebookServer.findEventlog().should('be.visible').click(); + notebookServer.findEventlog().should('be.visible').click(); // Wait for the success alert cy.step('Waits for the Success alert'); diff --git a/frontend/src/__tests__/cypress/cypress/types.ts b/frontend/src/__tests__/cypress/cypress/types.ts index e494a45e81..f516f66ff0 100644 --- a/frontend/src/__tests__/cypress/cypress/types.ts +++ b/frontend/src/__tests__/cypress/cypress/types.ts @@ -102,6 +102,10 @@ export type DataScienceProjectData = { projectContributorResourceName: string; }; +export type NotebookImageData = { + codeserverImageName: string; +}; + export type NimServingResponse = { body: { body: ConfigMapKind | SecretKind; diff --git a/frontend/src/__tests__/cypress/cypress/utils/oc_commands/baseCommands.ts b/frontend/src/__tests__/cypress/cypress/utils/oc_commands/baseCommands.ts index 2aa24da75f..43f4d2c4c2 100644 --- a/frontend/src/__tests__/cypress/cypress/utils/oc_commands/baseCommands.ts +++ b/frontend/src/__tests__/cypress/cypress/utils/oc_commands/baseCommands.ts @@ -69,7 +69,7 @@ export const waitForPodReady = ( const ocCommand = `oc get pods ${namespaceFlag} --no-headers | awk '$2 ~ /^${podNameContains}/ {print $1, $2}' | xargs -tn2 oc wait --for=condition=Ready pod --timeout=${timeout} -n`; cy.log(`Executing: ${ocCommand}`); - return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result: CommandLineResult) => { + return cy.exec(ocCommand, { failOnNonZeroExit: false, timeout: 300000 }).then((result: CommandLineResult) => { if (result.code !== 0) { throw new Error(`Pod readiness check failed: ${result.stderr}`); } @@ -93,6 +93,10 @@ export const deleteNotebook = ( if (result.code !== 0) { throw new Error(`Command failed with code ${result.stderr}`); } - cy.log(`Notebook deletion: ${result.stdout}`); + if (result.stdout.trim() === '') { + cy.log('No notebooks found'); + } else { + cy.log(`Notebook deletion: ${result.stdout}`); + } }); };