Skip to content

Commit

Permalink
feat: add smoketests for downloading / upload codebases
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesSheelam committed Jun 24, 2024
1 parent efdabed commit d0dec6b
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//test narative documentation
1 change: 1 addition & 0 deletions e2e/cypress/fixtures/codebase/testSimulationOutput.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//testSimulationOutput
2 changes: 2 additions & 0 deletions e2e/cypress/fixtures/codebase/testSourceCode.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//test source code

1 change: 1 addition & 0 deletions e2e/cypress/fixtures/codebase/testUploadData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//test upload data
92 changes: 88 additions & 4 deletions e2e/cypress/tests/codebase.spec.ts
Original file line number Diff line number Diff line change
@@ -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."));
})
})
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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});
Expand All @@ -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();















})

})
Expand Down
13 changes: 13 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"devDependencies": {
"cypress": "^13.6.2",
"cypress-file-upload": "^5.0.8",
"typescript": "~4.8.4"
},
"engines": {
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/CodebaseEditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
/>
<HoneypotField />
Expand All @@ -13,27 +14,32 @@
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
/>
<TextareaField
class="mb-3"
name="replicationText"
label="Replication of an existing model?"
help="Is this model a replication of a previously published computational model? Please enter a DOI or other permanent identifier to the model, or citation text. Separate multiple entries with newlines."
data-cy="codebase replication-text"

:rows="3"
/>
<TextareaField
class="mb-3"
name="associatedPublicationText"
label="Associated Publications"
help="Is this model associated with any publications? Please enter a DOI or other permanent identifier, or citation text. Separate multiple entries with newlines."
data-cy="codebase associated publications"
:rows="3"
/>
<TextareaField
class="mb-3"
name="referencesText"
label="References"
help="Other related publications. Please enter a DOI or other permanent identifier, or citation text. Separate multiple entries with newlines."
data-cy="codebase references"
:rows="3"
/>
<TaggerField
Expand All @@ -49,7 +55,7 @@
help="Is this model being developed on GitHub, BitBucket, GitLab, or other Git-based version control repository? Enter its root repository URL (e.g., https://github.com/comses/water-markets-model) for future CoMSES and Git integration."
/>
<FormAlert :validation-errors="Object.values(errors)" :server-errors="serverErrors" />
<button v-if="!asModal" type="submit" class="btn btn-primary" :disabled="isLoading">
<button v-if="!asModal" type="submit" class="btn btn-primary" :disabled="isLoading" data-cy="next">
{{ props.identifier ? "Update" : "Next" }}
</button>
</form>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/CodebaseListSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
create-label="Publish a model"
create-url="/codebases/add/"
search-label="Apply Filters"
data-cy="publish"
:search-url="query"
>
<template #form>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/releaseEditor/CommonImagesModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<button type="button" :class="buttonClass" rel="nofollow" @click="imagesModal?.show()">
<button type="button" :class="buttonClass" data-cy="add image" rel="nofollow" @click="imagesModal?.show()">
<i class="fas fa-image"></i> Add Images
</button>
<BootstrapModal id="images-modal" title="Upload Images" ref="imagesModal" size="lg" centered>
Expand All @@ -11,6 +11,7 @@
:upload-url="uploadUrl"
instructions="Upload media files here. Images are displayed on the detail page of every release for this codebase. GIF, JPEG and PNG files only."
:originals="files"
category="image"
@delete-file="handleDeleteFile"
@clear="handleClear"
@upload-done="getMediaFiles"
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/releaseEditor/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<div class="text-muted mb-1" v-if="instructions">{{ instructions }}</div>
<div class="d-flex justify-content-between mb-2">
<div>
<label :for="uploadId"><div class="btn btn-primary">Upload a file</div></label>
<label :for="uploadId"><div class="btn btn-primary" >Upload a file</div></label>
<input
class="invisible"
:data-cy="`upload-${category}`"
:id="uploadId"
type="file"
@change="handleFiles($event)"
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface FileUploadProps {
instructions: string;
uploadUrl: string;
acceptedFileTypes: string;
category: string;
originals: { name: string; identifier: string }[];
}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/releaseEditor/MetadataFormPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<form @submit="handleSubmit">
<MarkdownField
class="mb-3"
data-cy="release-notes"
name="releaseNotes"
label="Release Notes"
help="Details about this specific release: what's new, improvements to existing features, bug fixes, etc."
Expand All @@ -16,12 +17,14 @@
/>
<DatepickerField
class="mb-3"
data-cy="embargo-end-date"
name="embargoEndDate"
label="Embargo End Date"
help="The date your private release will be automatically made public"
/>
<SelectField
class="mb-3"
data-cy="operating-system"
name="os"
label="Operating System"
help="The operating system(s) this model is compatible with, e.g., Linux, MacOS, Windows"
Expand All @@ -30,13 +33,15 @@
/>
<TaggerField
class="mb-3"
data-cy="software-frameworks"
name="platforms"
label="Software Framework(s)"
help=" Modeling software frameworks (e.g., NetLogo, RePast, Mason, CORMAS, Mesa, etc.) used by this model"
required
/>
<TaggerField
class="mb-3"
data-cy="programming-languages"
name="programmingLanguages"
label="Programming Language(s)"
help=" Programming languages used in this model"
Expand All @@ -50,6 +55,7 @@
/>
<MultiSelectField
class="mb-3"
data-cy="license"
name="license"
label="License"
track-by="name"
Expand Down Expand Up @@ -81,7 +87,7 @@
</template>
</MultiSelectField>
<FormAlert :validation-errors="Object.values(errors)" :server-errors="serverErrors" />
<button type="submit" class="btn btn-primary mt-3">Save and Continue</button>
<button type="submit" data-cy="save-and-continue" class="btn btn-primary mt-3">Save and Continue</button>
</form>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/releaseEditor/ProgressSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
>
<div
class="card-header nav-link d-flex justify-content-between align-items-center text-decoration-none"
data-cy="add metadata"
>
<b>Add Metadata</b>
<i class="fas fa-angle-right text-secondary"></i>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/releaseEditor/UploadFormPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
:originals="store.getFilesInCategory(config.uploadType)"
:upload-url="uploadUrl(config.uploadType)"
:title="config.title"
:category="config.uploadType"
@delete-file="handleDeleteFile(config.uploadType, $event)"
@clear="handleClear(config.uploadType)"
@upload-done="handleUploadDone(config.uploadType)"
Expand Down

0 comments on commit d0dec6b

Please sign in to comment.