diff --git a/e2e/cypress/fixtures/codebase/codebasetestimage.png b/e2e/cypress/fixtures/codebase/codebasetestimage.png new file mode 100644 index 000000000..96a5268e8 Binary files /dev/null and b/e2e/cypress/fixtures/codebase/codebasetestimage.png differ diff --git a/e2e/cypress/fixtures/codebase/testNarrativeDocumentation.txt b/e2e/cypress/fixtures/codebase/testNarrativeDocumentation.txt new file mode 100644 index 000000000..bff092200 --- /dev/null +++ b/e2e/cypress/fixtures/codebase/testNarrativeDocumentation.txt @@ -0,0 +1 @@ +//test narative documentation diff --git a/e2e/cypress/fixtures/codebase/testSimulationOutput.txt b/e2e/cypress/fixtures/codebase/testSimulationOutput.txt new file mode 100644 index 000000000..9f1541be1 --- /dev/null +++ b/e2e/cypress/fixtures/codebase/testSimulationOutput.txt @@ -0,0 +1 @@ +//testSimulationOutput diff --git a/e2e/cypress/fixtures/codebase/testSourceCode.txt b/e2e/cypress/fixtures/codebase/testSourceCode.txt new file mode 100644 index 000000000..003a0b85d --- /dev/null +++ b/e2e/cypress/fixtures/codebase/testSourceCode.txt @@ -0,0 +1,2 @@ +//test source code + diff --git a/e2e/cypress/fixtures/codebase/testUploadData.txt b/e2e/cypress/fixtures/codebase/testUploadData.txt new file mode 100644 index 000000000..89786372e --- /dev/null +++ b/e2e/cypress/fixtures/codebase/testUploadData.txt @@ -0,0 +1 @@ +//test upload data diff --git a/e2e/cypress/tests/codebase.spec.ts b/e2e/cypress/tests/codebase.spec.ts index 278433bdb..e86798abb 100644 --- a/e2e/cypress/tests/codebase.spec.ts +++ b/e2e/cypress/tests/codebase.spec.ts @@ -1,10 +1,11 @@ import { loginBeforeEach } from "./setup.spec"; +import 'cypress-file-upload' //login - +/* describe("Login", () => { it("should log into comses homepage with test user", () => { - loginBeforeEach('testuser', 'test12345'); + loginBeforeEach('testuser', '123456'); assert(cy.get("h1").contains("A growing collection of resources for computational model-based science.")); }) }) @@ -87,7 +88,7 @@ describe("Visit events page", () =>{ //EVENTS PAGE }) it("should be able to submit an event", () =>{ - loginBeforeEach('testuser', 'test12345'); + loginBeforeEach('testuser', '123456'); cy.visit("/events"); cy.get('#djHideToolBarButton').click(); cy.get('.text-white').first().click({force:true}); @@ -129,7 +130,7 @@ describe("Visit jobs page", () =>{ //JOBS PAGE }) it("should be able to submit a job posting", () =>{ - loginBeforeEach('testuser', 'test12345'); + loginBeforeEach('testuser', '123456'); cy.visit("/jobs"); cy.get('#djHideToolBarButton').click(); cy.get('.text-white').first().click({force:true}); @@ -149,6 +150,89 @@ describe("Visit jobs page", () =>{ //JOBS PAGE cy.get('.card-body').first().find('a').first().click(); assert(cy.get("h1").contains("Job Title")); assert(cy.get("p").contains("Job Description")); + }) + +}) + +*/ + + +describe("Visit codebases page", () =>{ //codebases PAGE + + it("should visit the codebases page", () =>{ + cy.visit("/codebases"); + assert(cy.get("h1").contains("Computational Model Library")); + }) + + it("should be able to download a codebase", () => { + cy.visit("/codebases"); + cy.get('.search-result').first().find('a').first().click(); + cy.get('#djHideToolBarButton').click(); + cy.get('button.btn.btn-primary.my-1.w-100[rel="nofollow"]').click(); + cy.get('#form-field-industry').select('College/University'); + cy.get('#form-field-affiliation').type("Arizona State University{enter}", {force: true}); + cy.get('#form-field-reason').select('Research'); + cy.get('button[type="submit"][form="download-request-form"].btn.btn-success').click(); + }) + + it("should be able to upload a codebase", () =>{ + loginBeforeEach('test_user', '123456'); + cy.visit("/codebases"); + assert(cy.get("h1").contains("Computational Model Library")); + cy.get('#djHideToolBarButton').click(); + cy.contains('Publish a model').click(); + cy.get('[data-cy="codebase title"]').type("Codebase Title"); + cy.get('[data-cy="codebase description"]').type("Codebase Description"); + cy.get('[data-cy="codebase replication-text"]').type("Codebase Replication Text"); + cy.get('[data-cy="codebase associated publications"]').type("Codebase Associated Publications"); + cy.get('[data-cy="codebase references"]').type("Codebase References"); + cy.get('[data-cy="next"]').click(); + //add images + cy.get('[data-cy="add image"]').click(); //add image + cy.get('[data-cy="upload-image"]').first().selectFile('cypress/fixtures/codebase/codebasetestimage.png', {force: true}); + cy.get('button.btn.btn-outline-gray[data-bs-dismiss="modal"]').get("button").first().click( {force: true} ); + cy.get('button.btn.btn-outline-gray[data-bs-dismiss="modal"]') + .should('be.visible') + .and('not.be.disabled') + .first(). + click( {force: true} ); + cy.get('body').click(0, 0); + cy.get('body').click(0, 0); //FIX: find a more precise way of closing the image upload modal + + //add source code files + cy.get('[data-cy="upload-code"]').first().selectFile('cypress/fixtures/codebase/testSourceCode.txt', {force: true}); + cy.get('[data-cy="upload-docs"]').first().selectFile('cypress/fixtures/codebase/testNarrativeDocumentation.txt', {force: true}); + cy.get('[data-cy="upload-data"]').first().selectFile('cypress/fixtures/codebase/testUploadData.txt', {force: true}); + cy.get('[data-cy="upload-results"]').first().selectFile('cypress/fixtures/codebase/testSimulationOutput.txt', {force: true}); + cy.get('[data-cy="add metadata"]').click(); + cy.get('[data-cy="release-notes"] textarea').type("Release notes"); + cy.get('[data-cy="embargo-end-date"]').click(); + cy.get('[data-cy="embargo-end-date"]').contains('29').click(); + cy.get('[data-cy="operating-system"] select').select('Operating System Independent'); + cy.get('[data-cy="software-frameworks"]').type("NetLogo {enter} "); + cy.get('body').click(0, 0); + cy.get('[data-cy="programming-languages"').type("Net Logo {enter}"); + cy.get('body').click(0, 0); + cy.get('[data-cy="license"] .multiselect__select').click(); + cy.get('[data-cy="license"] .multiselect__element').contains('GPL-2.0').click(); + cy.get('[data-cy="save-and-continue"]').click(); + cy.get('button.btn.btn-danger[rel="nofollow"]').click(); + cy.get('button[type="submit"].btn.btn-danger[form="publish-form"]').click(); + + + + + + + + + + + + + + + }) }) diff --git a/e2e/package-lock.json b/e2e/package-lock.json index fa61ddfdf..f70c54e0b 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.1", "devDependencies": { "cypress": "^13.6.2", + "cypress-file-upload": "^5.0.8", "typescript": "~4.8.4" }, "engines": { @@ -609,6 +610,18 @@ "node": "^16.0.0 || ^18.0.0 || >=20.0.0" } }, + "node_modules/cypress-file-upload": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz", + "integrity": "sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==", + "dev": true, + "engines": { + "node": ">=8.2.1" + }, + "peerDependencies": { + "cypress": ">3.0.0" + } + }, "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", diff --git a/e2e/package.json b/e2e/package.json index 228185d79..8b3ce8ea6 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -8,6 +8,7 @@ }, "devDependencies": { "cypress": "^13.6.2", + "cypress-file-upload": "^5.0.8", "typescript": "~4.8.4" }, "engines": { diff --git a/frontend/src/components/CodebaseEditForm.vue b/frontend/src/components/CodebaseEditForm.vue index e4605a0ab..02dac3d1a 100644 --- a/frontend/src/components/CodebaseEditForm.vue +++ b/frontend/src/components/CodebaseEditForm.vue @@ -5,6 +5,7 @@ name="title" label="Title" help="A short title describing this computational model, limited to 300 characters" + data-cy="codebase title" required /> @@ -13,6 +14,7 @@ name="description" label="Description" help="A summary description of your model similar to an abstract. There is no limit on length but it should be kept as succinct as possible." + data-cy="codebase description" required /> - diff --git a/frontend/src/components/CodebaseListSidebar.vue b/frontend/src/components/CodebaseListSidebar.vue index 8601924c3..909e12a27 100644 --- a/frontend/src/components/CodebaseListSidebar.vue +++ b/frontend/src/components/CodebaseListSidebar.vue @@ -3,6 +3,7 @@ create-label="Publish a model" create-url="/codebases/add/" search-label="Apply Filters" + data-cy="publish" :search-url="query" >