diff --git a/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectCreation.yaml b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectCreation.yaml index 363a32ed32..5f90dc1c79 100644 --- a/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectCreation.yaml +++ b/frontend/src/__tests__/cypress/cypress/fixtures/e2e/dataScienceProjects/testProjectCreation.yaml @@ -2,3 +2,34 @@ projectDisplayName: "Cypress Test Project" projectDescription: "Cypress Test project description." projectResourceName: "cypress-test-project" +invalidResourceNames: + - Test-Project + - test project + - test.project + - test:project + - test/project + - test"project + - test[project] + - test(project) + - test&project + - test*project + - test?project + - largeprojectnametestthatshouldnotwork + - Test-Project-Invalid + - test project with spaces + - test.project.with.dots + - test:project:with:colons + - test/project/with/slashes + - test"project"with"quotes + - test[project]with[brackets] + - test(project)with(parentheses) + - test&project&with&ersands + - test*project*with*asterisks + - test?project?with?questions + - -testprojectstartshyphen + - testprojectendswithhyphen- + - TestProjectUpperCase + - $testprojectspecialstart + - ^testprojectspecialstart + - (testproject)parentheses + - testprojecttoooooooooooooooooooooooooooooooooooooooooooooooooooolong diff --git a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts index 5932620dbf..cda28def85 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/testProjectCreation.cy.ts @@ -92,4 +92,72 @@ describe('Verify Data Science Project - Creation and Deletion', () => { projectListPage.findEmptyResults(); }, ); + it( + 'Verify users cannot create a project with Empty title', + { tags: ['@Sanity', '@SanitySet1', '@ODS-1783', '@Dashboard', '@Tier1'] }, + () => { + // Authentication and navigation + cy.step('Log into the application'); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_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 + .findDescriptionInput() + .type(testData.projectDescription); + + // Confirm that the Submit button is disabled + cy.step('Verify the submit button is disabled'); + createProjectModal.findSubmitButton().should('be.disabled'); + }, + ); + it( + 'Verify User cannot create a project using special characters or long names in the Resource name field', + { tags: ['@Sanity', '@SanitySet1', '@ODS-1875', '@Dashboard', '@Tier1'] }, + () => { + // Authentication and navigation + cy.step('Log into the application'); + cy.visitWithLogin('/', HTPASSWD_CLUSTER_ADMIN_USER); + projectListPage.navigate(); + + // Initiate project creation + cy.step('Open Create Data Science Project modal'); + createProjectModal.shouldBeOpen(false); + projectListPage.findCreateProjectButton().click(); + + // Enter invalid resource details + cy.step( + 'Enter invalid resource details - iterate through the array defined in the fixtures file', + ); + createProjectModal.k8sNameDescription.findResourceEditLink().click(); + createProjectModal.k8sNameDescription + .findDisplayNameInput() + .type(testData.projectDisplayName); + + // Test each invalid resource name + cy.step('Test invalid resource name and verify that project creation is prevented'); + + testData.invalidResourceNames.forEach((invalidResourceName) => { + cy.log(`Testing invalid resource name: ${invalidResourceName}`); + + // Clear input, type invalid resource name, and validate behavior + createProjectModal.k8sNameDescription + .findResourceNameInput() + .clear() + .type(invalidResourceName); + createProjectModal.k8sNameDescription + .findResourceNameInput() + .should('have.attr', 'aria-invalid', 'true'); + createProjectModal.findSubmitButton().should('be.disabled'); + // Log success message for invalid resources names being rejected + cy.log(`✅ ${invalidResourceName}: not authorised as a Resource Name`); + }); + }, + ); }); diff --git a/frontend/src/__tests__/cypress/cypress/types.ts b/frontend/src/__tests__/cypress/cypress/types.ts index dc535c0e1b..b70f57ccd7 100644 --- a/frontend/src/__tests__/cypress/cypress/types.ts +++ b/frontend/src/__tests__/cypress/cypress/types.ts @@ -137,6 +137,7 @@ export type DataScienceProjectData = { pvStorageName: string; pvStorageDescription: string; pvStorageNameEdited: string; + invalidResourceNames: string[]; }; export type NotebookImageData = {