forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into rhoai-2.16
- Loading branch information
Showing
40 changed files
with
958 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...nd/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/dataScienceProject.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# testProjectCreation.cy.ts Test Data # | ||
dsProjectName: "Cypress Test Project 1" | ||
dsProjectDescription: "Cypress Test project 1 description." | ||
dsOCProjectName: "cypress-test-project-1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...end/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import yaml from 'js-yaml'; | ||
import { ADMIN_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; | ||
import { | ||
projectListPage, | ||
createProjectModal, | ||
projectDetails, | ||
} from '~/__tests__/cypress/cypress/pages/projects'; | ||
import { | ||
verifyOpenShiftProjectExists, | ||
deleteOpenShiftProject, | ||
} from '~/__tests__/cypress/cypress/utils/oc_commands/project'; | ||
import { deleteModal } from '~/__tests__/cypress/cypress/pages/components/DeleteModal'; | ||
import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; | ||
|
||
describe('Verify Data Science Project - Creation and Deletion', () => { | ||
let testData: DataScienceProjectData; | ||
|
||
// Setup: Load test data and ensure clean state | ||
before(() => { | ||
return cy | ||
.fixture('e2e/dataScienceProjects/dataScienceProject.yaml', 'utf8') | ||
.then((yamlContent: string) => { | ||
testData = yaml.load(yamlContent) as DataScienceProjectData; | ||
const projectName = testData.dsOCProjectName; | ||
|
||
if (!projectName) { | ||
throw new Error('Project name is undefined or empty'); | ||
} | ||
|
||
return verifyOpenShiftProjectExists(projectName); | ||
}) | ||
.then((exists: boolean) => { | ||
const projectName = testData.dsOCProjectName; | ||
// Clean up existing project if it exists | ||
if (exists) { | ||
cy.log(`Project ${projectName} exists. Deleting before test.`); | ||
return deleteOpenShiftProject(projectName); | ||
} | ||
cy.log(`Project ${projectName} does not exist. Proceeding with test.`); | ||
// Return a resolved promise to ensure a value is always returned | ||
return cy.wrap(null); | ||
}); | ||
}); | ||
|
||
it('Create and Delete a Data Science Project in RHOAI', () => { | ||
// Authentication and navigation | ||
cy.step('Log into the application'); | ||
cy.visitWithLogin('/', ADMIN_USER); | ||
projectListPage.navigate(); | ||
|
||
// Initiate project creation | ||
cy.step('Open Create Data Science Project modal'); | ||
createProjectModal.shouldBeOpen(false); | ||
projectListPage.findCreateProjectButton().click(); | ||
|
||
// Input project details | ||
cy.step('Enter valid project information'); | ||
createProjectModal.k8sNameDescription.findDisplayNameInput().type(testData.dsProjectName); | ||
createProjectModal.k8sNameDescription | ||
.findDescriptionInput() | ||
.type(testData.dsProjectDescription); | ||
|
||
// Submit project creation | ||
cy.step('Save the project'); | ||
createProjectModal.findSubmitButton().click(); | ||
|
||
// Verify project creation | ||
cy.step(`Verify that the project ${testData.dsProjectName} has been created`); | ||
cy.url().should('include', `/projects/${testData.dsOCProjectName}`); | ||
projectDetails.verifyProjectName(testData.dsProjectName); | ||
projectDetails.verifyProjectDescription(testData.dsProjectDescription); | ||
|
||
// Initiate project deletion | ||
cy.step('Deleting the project - clicking actions'); | ||
projectDetails.findActions().click(); | ||
projectDetails.findDeleteProjectAction().click(); | ||
|
||
// Confirm project deletion | ||
cy.step('Entering project details for deletion'); | ||
deleteModal.shouldBeOpen(); | ||
deleteModal.findInput().type(testData.dsProjectName); | ||
deleteModal.findSubmitButton().should('be.enabled').click(); | ||
|
||
// Verify project deletion | ||
cy.step(`Verify that the project ${testData.dsProjectName} has been deleted`); | ||
projectListPage.filterProjectByName(testData.dsProjectName); | ||
projectListPage.findEmptyResults(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
frontend/src/__tests__/cypress/cypress/utils/errorHandling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Handles the result of an OpenShift (oc) command execution. | ||
* @param result The result of the command execution. | ||
* @throws Error if the command fails with an unexpected exit code. | ||
*/ | ||
export function handleOCCommandResult(result: Cypress.Exec): void { | ||
if (result.code !== 0 && result.code !== 1) { | ||
// When some resources e.g. projects don't exist | ||
cy.log(`ERROR: Command execution failed | ||
stdout: ${result.stdout} | ||
stderr: ${result.stderr}`); | ||
throw new Error(`Command failed with code ${result.code}`); | ||
} | ||
} |
Oops, something went wrong.