Skip to content

Commit

Permalink
feat: add final smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesSheelam committed Jul 16, 2024
1 parent 2e8049c commit 273ee20
Show file tree
Hide file tree
Showing 17 changed files with 325 additions and 157 deletions.
34 changes: 15 additions & 19 deletions e2e/cypress/tests/beforeLoginTests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@

/*
//test ability to browse/download codebases
describe("Browse Codebases", () => {
it("should browse the model library and be able to enter a search query", () =>{
cy.visit('/'); // visit homepage
cy.visit('/codebases');
assert(cy.get("h1").contains("Computational Model Library"));


})
})
it("should browse the model library and be able to enter a search query", () => {
cy.visit("/"); // visit homepage
cy.visit("/codebases");
assert(cy.get("h1").contains("Computational Model Library"));
});
});

//download codebase
describe("Download Codebases", () =>{
it("should download a codebase", () => {
// Navigate to the first 'search-result', find the 'a' tag within the 'title' div, and click it
cy.get('.search-result', {timeout: 10000}).first().find('.title a').click();


})
})
/*
describe("Download Codebases", () => {
it("should download a codebase", () => {
// Navigate to the first 'search-result', find the 'a' tag within the 'title' div, and click it
cy.get(".search-result", { timeout: 10000 })
.first()
.find(".title a")
.click();
});
});
208 changes: 86 additions & 122 deletions e2e/cypress/tests/codebase.spec.ts
Original file line number Diff line number Diff line change
@@ -1,157 +1,121 @@
import { loginBeforeEach } from "./setup.spec";
import 'cypress-file-upload'
import "cypress-file-upload";

//login
describe("Login", () => {
it("should log into comses homepage with test user", () => {
loginBeforeEach('testuser', '123456');
})
})

describe("Visit events page", () =>{ //EVENTS PAGE
loginBeforeEach("test_user", "123456");
});
});

it("should visit the events page", () =>{
cy.visit("/events");
assert(cy.get("h1").contains("Community Events"));
cy.get('.card-body').first().find('a').first().click();
assert(cy.get("h1").contains("Title"));

})

it("should be able to search for a specific event", () =>{
cy.visit("/events");
cy.get('input[class="form-control"]').type("Call for applications to organize a 2022 CECAM-Lorentz funded workshop on modeling");
cy.get('button.btn.btn-primary').click();
})

it("should be able to submit an event", () =>{
loginBeforeEach('test_user', '123456');
cy.visit("/events");
cy.get('#djHideToolBarButton').click();
cy.get('.text-white').first().click({force:true});
cy.get('[data-cy="event title"]').type("Title");
cy.get('[data-cy="event location"]').type("Location");
cy.get('[data-cy="event start date"]').first().click(); //event start date
cy.get('[data-cy="event start date"]').contains('22').click();
cy.get('[data-cy="event end date"]').first().click(); //event end date
cy.get('[data-cy="event end date"]').contains('27').click();
cy.get('[data-cy="early registration deadline"]').first().click(); //early registration deadline
cy.get('[data-cy="early registration deadline"]').contains('22').click();
cy.get('[data-cy="registration deadline"]').first().click(); //registration deadline
cy.get('[data-cy="registration deadline"]').contains('25').click();
cy.get('[data-cy="submission deadline"]').first().click(); //submission deadline
cy.get('[data-cy="submission deadline"]').contains('22').click();
cy.get('[data-cy="description"]').type('Description');
cy.get('[data-cy="summary"]').type('Summary');
cy.get('[data-cy="external url"]').type('https://www.comses.net/');
cy.get('[data-cy="create button"]').click();
})
describe("Visit codebases page", () => {
//codebases PAGE

it("should be able to verify event was submitted correctly", () =>{
cy.visit("/events");
cy.get('#djHideToolBarButton').click();
assert(cy.get("h1").contains("Community Events"));
cy.get('.card-body').first().find('a').first().click();
assert(cy.get("h1").contains("Title"));
assert(cy.get("p").contains("Description"));
assert(cy.get("p").contains("Location"));
})
})

describe("Visit jobs page", () =>{ //JOBS PAGE

it("should visit the jobs page", () =>{
cy.visit("/jobs");
assert(cy.get("h1").contains("Jobs & Appointments"));
})

it("should be able to submit a job posting", () =>{
loginBeforeEach('test_user', '123456');
cy.visit("/jobs");
cy.get('#djHideToolBarButton').click();
cy.get('.text-white').first().click({force:true});
cy.get('[data-cy="job title"]').type("Job Title");
cy.get('[data-cy="job description"]').type('Job Description');
cy.get('[data-cy="job summary"]').type('Job Summary');
cy.get('[data-cy="external url"]').type('https://www.comses.net/');
cy.get('[data-cy="application deadline"]').first().click();
cy.get('[data-cy="application deadline"]').contains('29').click();
cy.get('[data-cy="create button"]').click();
})

it("should be able to verify job was submitted correctly", () =>{
cy.visit("/jobs");
cy.get('#djHideToolBarButton').click();
assert(cy.get("h1").contains("Jobs & Appointments"));
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", () =>{
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(".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.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("#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 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
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="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="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("body").click(0, 0);
cy.get('[data-cy="programming-languages"').type("Net Logo {enter}");
cy.get('body').click(0, 0);
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="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();
});

})
})
it("should verify that the codebase was uploaded correctly", () => {
cy.visit("/codebases");
cy.get(".search-result").first().find("a").first().click();
assert(cy.get("h1").contains("Codebase Title"));
assert(cy.get("p").contains("Codebase Description"));
assert(cy.get("p").contains("Codebase Replication Text"));
assert(cy.get("p").contains("Codebase Associated Publications"));
assert(cy.get("p").contains("Codebase References"));

})
});
55 changes: 55 additions & 0 deletions e2e/cypress/tests/event.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { loginBeforeEach } from "./setup.spec";
import "cypress-file-upload";


describe("Visit events page", () => {
//EVENTS PAGE

it("should visit the events page", () => {
cy.visit("/events");
assert(cy.get("h1").contains("Community Events"));
cy.get(".card-body").first().find("a").first().click();
assert(cy.get("h1").contains("Title"));
});

it("should be able to search for a specific event", () => {
cy.visit("/events");
cy.get('input[class="form-control"]').type(
"Call for applications to organize a 2022 CECAM-Lorentz funded workshop on modeling"
);
cy.get("button.btn.btn-primary").click();
});

it("should be able to submit an event", () => {
loginBeforeEach("test_user", "123456");
cy.visit("/events");
cy.get("#djHideToolBarButton").click();
cy.get(".text-white").first().click({ force: true });
cy.get('[data-cy="event title"]').type("Title");
cy.get('[data-cy="event location"]').type("Location");
cy.get('[data-cy="event start date"]').first().click(); //event start date
cy.get('[data-cy="event start date"]').contains("22").click();
cy.get('[data-cy="event end date"]').first().click(); //event end date
cy.get('[data-cy="event end date"]').contains("27").click();
cy.get('[data-cy="early registration deadline"]').first().click(); //early registration deadline
cy.get('[data-cy="early registration deadline"]').contains("22").click();
cy.get('[data-cy="registration deadline"]').first().click(); //registration deadline
cy.get('[data-cy="registration deadline"]').contains("25").click();
cy.get('[data-cy="submission deadline"]').first().click(); //submission deadline
cy.get('[data-cy="submission deadline"]').contains("22").click();
cy.get('[data-cy="description"]').type("Description");
cy.get('[data-cy="summary"]').type("Summary");
cy.get('[data-cy="external url"]').type("https://www.comses.net/");
cy.get('[data-cy="create button"]').click();
});

it("should be able to verify event was submitted correctly", () => {
cy.visit("/events");
cy.get("#djHideToolBarButton").click();
assert(cy.get("h1").contains("Community Events"));
cy.get(".card-body").first().find("a").first().click();
assert(cy.get("h1").contains("Title"));
assert(cy.get("p").contains("Description"));
assert(cy.get("p").contains("Location"));
});
});
35 changes: 35 additions & 0 deletions e2e/cypress/tests/job.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { loginBeforeEach } from "./setup.spec";
import "cypress-file-upload";

describe("Visit jobs page", () => {
//JOBS PAGE

it("should visit the jobs page", () => {
cy.visit("/jobs");
assert(cy.get("h1").contains("Jobs & Appointments"));
});

it("should be able to submit a job posting", () => {
loginBeforeEach("test_user", "123456");
cy.visit("/jobs");
cy.get("#djHideToolBarButton").click();
cy.get(".text-white").first().click({ force: true });
cy.get('[data-cy="job title"]').type("Job Title");
cy.get('[data-cy="job description"]').type("Job Description");
cy.get('[data-cy="job summary"]').type("Job Summary");
cy.get('[data-cy="external url"]').type("https://www.comses.net/");
cy.get('[data-cy="application deadline"]').first().click();
cy.get('[data-cy="application deadline"]').contains("29").click();
cy.get('[data-cy="create button"]').click();
});

it("should be able to verify job was submitted correctly", () => {
cy.visit("/jobs");
cy.get("#djHideToolBarButton").click();
assert(cy.get("h1").contains("Jobs & Appointments"));
cy.get(".card-body").first().find("a").first().click();
assert(cy.get("h1").contains("Job Title"));
assert(cy.get("p").contains("Job Description"));
});
});

12 changes: 6 additions & 6 deletions e2e/cypress/tests/setup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//contains setup function for smoke tests
export const loginBeforeEach = (username, password) => {
cy.visit('/accounts/login/?next=/')
assert(cy.get("h1").contains("Sign In")); //simply goes to sign in page
cy.get('input[name="login"]').type(username)
cy.get('input[name="password"]').type(password)
cy.contains('button', 'Sign In').click();
}
cy.visit("/accounts/login/?next=/");
assert(cy.get("h1").contains("Sign In")); //simply goes to sign in page
cy.get('input[name="login"]').type(username);
cy.get('input[name="password"]').type(password);
cy.contains("button", "Sign In").click();
};
Loading

0 comments on commit 273ee20

Please sign in to comment.