-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into RHOAIENG-1101
- Loading branch information
Showing
17 changed files
with
407 additions
and
104 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
...nd/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/dataScienceProject.yaml
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectAdminPermissions.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,2 @@ | ||
# testProjectAdminPermissions.cy.ts Test Data # | ||
projectPermissionResourceName: "cypress-user-perm-test" |
2 changes: 2 additions & 0 deletions
2
..._/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectContributorPermissions.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,2 @@ | ||
# testProjectContributorPermissions.cy.ts Test Data # | ||
projectContributorResourceName: "cypress-user-perm-contr-test" |
4 changes: 4 additions & 0 deletions
4
...d/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectCreation.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 # | ||
projectDisplayName: "Cypress Test Project" | ||
projectDescription: "Cypress Test project description." | ||
projectResourceName: "cypress-test-project" |
76 changes: 76 additions & 0 deletions
76
...__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectAdminPermissions.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,76 @@ | ||
import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; | ||
import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; | ||
import { permissions } from '~/__tests__/cypress/cypress/pages/permissions'; | ||
import { ADMIN_USER, TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; | ||
import { loadFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; | ||
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; | ||
import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; | ||
|
||
describe('Verify that users can provide admin project permissions to non-admin users', () => { | ||
let testData: DataScienceProjectData; | ||
let projectName: string; | ||
|
||
// Setup: Load test data and ensure clean state | ||
before(() => { | ||
return loadFixture('e2e/dataScienceProjects/testProjectAdminPermissions.yaml') | ||
.then((fixtureData: DataScienceProjectData) => { | ||
testData = fixtureData; | ||
projectName = testData.projectPermissionResourceName; | ||
if (!projectName) { | ||
throw new Error('Project name is undefined or empty in the loaded fixture'); | ||
} | ||
cy.log(`Loaded project name: ${projectName}`); | ||
return createCleanProject(projectName); | ||
}) | ||
.then(() => { | ||
cy.log(`Project ${projectName} confirmed to be created and verified successfully`); | ||
}); | ||
}); | ||
after(() => { | ||
// Delete provisioned Project | ||
if (projectName) { | ||
cy.log(`Deleting Project ${projectName} after the test has finished.`); | ||
deleteOpenShiftProject(projectName); | ||
} | ||
}); | ||
|
||
it('Verify that user can be added as an Admin for a Project', () => { | ||
// Authentication and navigation | ||
cy.step('Log into the application'); | ||
cy.visitWithLogin('/', ADMIN_USER); | ||
|
||
// Project navigation, add user and provide admin permissions | ||
cy.step( | ||
`Navigate to the Project list tab and search for ${testData.projectPermissionResourceName}`, | ||
); | ||
projectListPage.navigate(); | ||
projectListPage.filterProjectByName(testData.projectPermissionResourceName); | ||
projectListPage.findProjectLink(testData.projectPermissionResourceName).click(); | ||
projectDetails.findSectionTab('permissions').click(); | ||
|
||
cy.step('Assign admin user Project Permissions'); | ||
permissions.findAddUserButton().click(); | ||
permissions.getUserTable().findAddInput().type(TEST_USER.USERNAME); | ||
permissions | ||
.getUserTable() | ||
.selectPermission(TEST_USER.USERNAME, 'Admin Edit the project and manage user access'); | ||
|
||
cy.step( | ||
`Save the user and validate that ${TEST_USER.USERNAME} has been saved with admin permissions`, | ||
); | ||
permissions.getUserTable().findSaveNewButton().should('exist').and('be.visible').click(); | ||
cy.contains(TEST_USER.USERNAME).should('exist'); | ||
}); | ||
it('Verify that user can access the created project with Admin rights', () => { | ||
// Authentication and navigation | ||
cy.step(`Log into the application with ${TEST_USER.USERNAME}`); | ||
cy.visitWithLogin('/', TEST_USER); | ||
|
||
// Project navigation and validate permissions tab is accessible | ||
cy.step('Verify that the user has access to the created project and can access Permissions'); | ||
projectListPage.navigate(); | ||
projectListPage.filterProjectByName(testData.projectPermissionResourceName); | ||
projectListPage.findProjectLink(testData.projectPermissionResourceName).click(); | ||
projectDetails.findSectionTab('permissions').click(); | ||
}); | ||
}); |
78 changes: 78 additions & 0 deletions
78
...s__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectContributorPermissions.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,78 @@ | ||
import { deleteOpenShiftProject } from '~/__tests__/cypress/cypress/utils/oc_commands/project'; | ||
import { projectDetails, projectListPage } from '~/__tests__/cypress/cypress/pages/projects'; | ||
import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; | ||
import { permissions } from '~/__tests__/cypress/cypress/pages/permissions'; | ||
import { ADMIN_USER, TEST_USER } from '~/__tests__/cypress/cypress/utils/e2eUsers'; | ||
import { loadFixture } from '~/__tests__/cypress/cypress/utils/dataLoader'; | ||
import { createCleanProject } from '~/__tests__/cypress/cypress/utils/projectChecker'; | ||
|
||
describe('Verify that users can provide contributor project permissions to non-admin users', () => { | ||
let testData: DataScienceProjectData; | ||
let projectName: string; | ||
|
||
// Setup: Load test data and ensure clean state | ||
before(() => { | ||
return loadFixture('e2e/dataScienceProjects/testProjectContributorPermissions.yaml') | ||
.then((fixtureData: DataScienceProjectData) => { | ||
testData = fixtureData; | ||
projectName = testData.projectContributorResourceName; | ||
if (!projectName) { | ||
throw new Error('Project name is undefined or empty in the loaded fixture'); | ||
} | ||
cy.log(`Loaded project name: ${projectName}`); | ||
return createCleanProject(projectName); | ||
}) | ||
.then(() => { | ||
cy.log(`Project ${projectName} confirmed to be created and verified successfully`); | ||
}); | ||
}); | ||
after(() => { | ||
// Delete provisioned Project | ||
if (projectName) { | ||
cy.log(`Deleting Project ${projectName} after the test has finished.`); | ||
deleteOpenShiftProject(projectName); | ||
} | ||
}); | ||
|
||
it('Verify that user can be added as a Contributor for a Project', () => { | ||
// Authentication and navigation | ||
cy.step('Log into the application'); | ||
cy.visitWithLogin('/', ADMIN_USER); | ||
|
||
// Project navigation, add user and provide contributor permissions | ||
cy.step( | ||
`Navigate to the Project list tab and search for ${testData.projectContributorResourceName}`, | ||
); | ||
projectListPage.navigate(); | ||
projectListPage.filterProjectByName(testData.projectContributorResourceName); | ||
projectListPage.findProjectLink(testData.projectContributorResourceName).click(); | ||
projectDetails.findSectionTab('permissions').click(); | ||
|
||
cy.step('Assign contributor user Project Permissions'); | ||
permissions.findAddUserButton().click(); | ||
permissions.getUserTable().findAddInput().type(TEST_USER.USERNAME); | ||
cy.debug(); | ||
permissions | ||
.getUserTable() | ||
.selectPermission(TEST_USER.USERNAME, 'Contributor View and edit the project components'); | ||
|
||
cy.step( | ||
`Save the user and validate that ${TEST_USER.USERNAME} has been saved with Contributor permissions`, | ||
); | ||
permissions.getUserTable().findSaveNewButton().should('exist').and('be.visible').click(); | ||
cy.contains(TEST_USER.USERNAME).should('exist'); | ||
}); | ||
it('Verify that user can access the created project as a Contributor', () => { | ||
// Authentication and navigation | ||
cy.step(`Log into the application with ${TEST_USER.USERNAME}`); | ||
cy.visitWithLogin('/', TEST_USER); | ||
|
||
// Project navigation and validate permissions tab is accessible | ||
cy.step('Verify that the user has access to the created project but cannot access Permissions'); | ||
projectListPage.navigate(); | ||
projectListPage.filterProjectByName(testData.projectContributorResourceName); | ||
projectListPage.findProjectLink(testData.projectContributorResourceName).click(); | ||
cy.log('Attempting to find permissions tab which should not be visible'); | ||
projectDetails.findSectionTab('permissions').should('not.exist'); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
frontend/src/__tests__/cypress/cypress/utils/dataLoader.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,11 @@ | ||
import yaml from 'js-yaml'; | ||
import type { DataScienceProjectData } from '~/__tests__/cypress/cypress/types'; | ||
|
||
// Load fixture function that returns a specific type | ||
export const loadFixture = (fixturePath: string): Cypress.Chainable<DataScienceProjectData> => { | ||
return cy.fixture(fixturePath, 'utf8').then((yamlContent: string) => { | ||
const data = yaml.load(yamlContent) as DataScienceProjectData; | ||
|
||
return data; | ||
}); | ||
}; |
28 changes: 28 additions & 0 deletions
28
frontend/src/__tests__/cypress/cypress/utils/projectChecker.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,28 @@ | ||
import { | ||
verifyOpenShiftProjectExists, | ||
deleteOpenShiftProject, | ||
createOpenShiftProject, | ||
} from '~/__tests__/cypress/cypress/utils/oc_commands/project'; | ||
|
||
export const createAndVerifyProject = (projectName: string): void => { | ||
createOpenShiftProject(projectName).then((result) => { | ||
expect(result.code).to.equal(0); | ||
}); | ||
|
||
verifyOpenShiftProjectExists(projectName).then((exists) => { | ||
if (!exists) { | ||
throw new Error(`Expected project ${projectName} to exist, but it does not.`); | ||
} | ||
}); | ||
}; | ||
|
||
export const createCleanProject = (projectName: string): void => { | ||
verifyOpenShiftProjectExists(projectName).then((exists) => { | ||
if (exists) { | ||
cy.log(`Project ${projectName} already exists. Deleting it.`); | ||
deleteOpenShiftProject(projectName); | ||
} | ||
cy.log(`Creating project ${projectName}`); | ||
createAndVerifyProject(projectName); | ||
}); | ||
}; |
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
Oops, something went wrong.