This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from hanshs/testing-cypress
Closes #53
- Loading branch information
Showing
25 changed files
with
15,390 additions
and
114 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} | ||
"root": true, | ||
"extends": [ | ||
"plugin:cypress/recommended", | ||
"next/core-web-vitals" | ||
], | ||
"env": { | ||
"cypress/globals": true | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Automated Tests | ||
|
||
on: [push, pull_request] | ||
on: [push] | ||
|
||
jobs: | ||
run_automated_tests: | ||
|
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,19 @@ | ||
name: Integration Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
cypress-run: | ||
runs-on: ubuntu-latest | ||
container: cypress/browsers:node12.18.3-chrome87-ff82 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cypress run | ||
uses: cypress-io/github-action@v2 | ||
env: | ||
DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }} | ||
with: | ||
build: npm run build | ||
start: npm start |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"chromeWebSecurity": false | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,145 @@ | ||
describe("Testing theorem creation, UC-2, UC-6", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("checks that the user is signed in", () => { | ||
cy.get('[data-cy=signout]').should("exist"); | ||
cy.get('[data-cy=create-link]').should("exist"); | ||
}); | ||
|
||
it("navigates to create page and checks if elements exist", () => { | ||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div]').should("exist"); | ||
cy.get('[data-cy=steps-div]').should("exist"); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').should("exist"); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').should("exist"); | ||
cy.get('[data-cy=claim-div] [data-cy=add-btn]').should("exist"); | ||
cy.get('[data-cy=steps-div] [data-cy=add-btn]').should("exist"); | ||
cy.get('[data-cy=add-step]').should("exist"); | ||
}); | ||
|
||
it("shows theorem preview and creation button", () => { | ||
let claim = "Cypress testing theorem preview"; | ||
let step = "Cypress testing theorem preview step1"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step); | ||
|
||
cy.get('[data-cy=preview-div]').should("exist"); | ||
cy.get('[data-cy=preview-div]').within(() => { | ||
cy.get('[data-cy=theorem-claim]').contains(claim); | ||
cy.get('ol>li').within(() => { | ||
cy.get('[data-cy=claim]').contains(step); | ||
}); | ||
}); | ||
}); | ||
|
||
it("creates a theorem", () => { | ||
let claim = "Cypress testing theorem creation"; | ||
let step1 = "Cypress testing theorem creation step1"; | ||
let subStep1 = "Cypress testing theorem creation subStep1"; | ||
let step2 = "Cypress testing theorem creation step2"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step1); | ||
cy.get('[data-cy=steps-div] [data-cy=add-btn]').click(); | ||
|
||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').eq(1).type(subStep1); | ||
|
||
cy.get('[data-cy=add-step]').click(); | ||
cy.get('[data-cy=steps-div]>ol>li').eq(1).within(() => { | ||
cy.get('[data-cy=claim-field]').type(step2); | ||
}); | ||
cy.get('[data-cy=create-btn]').click(); | ||
|
||
cy.get('[data-cy=theorem-claim]').contains(claim) | ||
cy.get('[data-cy=delete-theorem]').click(); | ||
cy.on('window:confirm', () => true); | ||
cy.visit("/"); | ||
}); | ||
|
||
it("deletes step during theorem creation", () => { | ||
let claim = "Cypress testing theorem creation"; | ||
let step1 = "Cypress testing theorem creation step1"; | ||
let step2 = "Cypress testing theorem creation step2"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step1); | ||
cy.get('[data-cy=add-step]').click(); | ||
cy.get('[data-cy=steps-div]>ol>li').eq(1).within(() => { | ||
cy.get('[data-cy=claim-field]').type(step2); | ||
}); | ||
cy.get('[data-cy=delete-step]').should("exist"); | ||
cy.get('[data-cy=delete-step]').click(); | ||
cy.get('[data-cy=steps-div]').within(() => { | ||
cy.get(step2).should("have.length", 0); | ||
}); | ||
cy.visit("/"); | ||
}); | ||
|
||
it("does not create a theorem with an empty statement", () => { | ||
let claim = "Cypress testing theorem creation"; | ||
let step1 = "Cypress testing theorem creation step1"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step1); | ||
cy.get('[data-cy=add-step]').click(); | ||
cy.get('[data-cy=create-btn]').click(); | ||
cy.on('window:alert', (text) => { | ||
expect(text).to.contains('Please delete or fill empty proof steps and statements!'); | ||
return true; | ||
}); | ||
cy.get('[data-cy=back]').click(); | ||
cy.get('[data-cy=main-ol]').within(() => { | ||
cy.get(claim).should("have.length", 0); | ||
}); | ||
}); | ||
|
||
it("creates a theorem with a step that has a subproof", () => { | ||
let claim = "Cypress testing theorem creation"; | ||
let step1 = "Cypress testing theorem creation step1"; | ||
let subProof = "Cypress testing theorem creation subProof"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step1); | ||
|
||
cy.get('[data-cy=add-subproof]').click(); | ||
cy.get('[data-cy=subproof]').within(() => { | ||
cy.get('[data-cy=claim-field]').type(subProof); | ||
}); | ||
cy.get('[data-cy=create-btn]').click(); | ||
cy.wait(2000); | ||
cy.get('[data-cy=theorem-ol]').contains(subProof); | ||
cy.url().then((urlString) => { | ||
let url = '/api' + urlString.replace('http://localhost:3000', ''); | ||
cy.request('DELETE', url); | ||
}) | ||
cy.visit("/"); | ||
}); | ||
|
||
it("deletes a subproof during theorem creation", () => { | ||
let claim = "Cypress testing theorem creation"; | ||
let step1 = "Cypress testing theorem creation step1"; | ||
let subProof = "Cypress testing theorem creation subProof"; | ||
|
||
cy.get('[data-cy=create-link]').click(); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step1); | ||
|
||
cy.get('[data-cy=add-subproof]').click(); | ||
cy.get('[data-cy=subproof]').within(() => { | ||
cy.get('[data-cy=claim-field]').type(subProof); | ||
}); | ||
|
||
cy.get('[data-cy=del-subproof]').click(); | ||
cy.get(subProof).should("have.length", 0); | ||
|
||
cy.visit("/"); | ||
}); | ||
}); |
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,45 @@ | ||
describe("Deleting theorem, UC-11", () => { | ||
|
||
let claim = "Cypress testing theorem deletion"; | ||
let step = "Cypress testing theorem deletion step1"; | ||
|
||
beforeEach(() => { | ||
cy.visit("/create"); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step); | ||
cy.get('[data-cy=create-btn]').click(); | ||
cy.visit("/"); | ||
}); | ||
|
||
it("deletes a theorem", () => { | ||
cy.get('[data-cy=signout]').should("exist"); | ||
cy.get('[data-cy=main-ol]>li').eq(-1).within(() => { | ||
cy.get('[data-cy=theorem-title]').click(); | ||
}); | ||
cy.get('[data-cy=delete-theorem]').click(); | ||
cy.on('window:confirm', (text) => { | ||
expect(text).to.contains('Are you sure'); | ||
return true; | ||
}); | ||
cy.url().should('eq', 'http://localhost:3000/'); | ||
}); | ||
|
||
it("keeps the theorem if deletion is not confirmed", () => { | ||
cy.get('[data-cy=signout]').should("exist"); | ||
cy.get('[data-cy=main-ol]>li').eq(-1).within(() => { | ||
cy.get('[data-cy=theorem-title]').click(); | ||
}); | ||
cy.get('[data-cy=delete-theorem]').click(); | ||
cy.on('window:confirm', () => false); | ||
|
||
cy.get('[data-cy=theorem-claim]').contains(claim); | ||
|
||
cy.url().then(urlString => { | ||
let url = '/api' + urlString.replace('http://localhost:3000', ''); | ||
cy.request('DELETE', url); | ||
}); | ||
|
||
cy.visit("/"); | ||
cy.get(claim).should("have.length", 0); | ||
}); | ||
}); |
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,43 @@ | ||
describe("Search theorems, UC-12", () => { | ||
|
||
let claim = "Cypress testing searching theorem"; | ||
let step = "Cypress testing searching theorem step1"; | ||
|
||
let id = ''; | ||
|
||
beforeEach(() => { | ||
cy.visit("/create"); | ||
cy.get('[data-cy=claim-div] [data-cy=claim-field]').type(claim); | ||
cy.get('[data-cy=steps-div] [data-cy=claim-field]').type(step); | ||
cy.get('[data-cy=create-btn]').click() | ||
cy.wait(2000); | ||
cy.url().then(urlString => { | ||
id = urlString.replace('http://localhost:3000/theorem/', ''); | ||
}); | ||
cy.visit("/"); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.get('[data-cy=search]').clear(); | ||
cy.request('DELETE', 'api/theorem/' + id); | ||
}); | ||
|
||
it("finds the correct theorem by claim", () => { | ||
cy.get('[data-cy=search]').type(claim); | ||
cy.get('[data-cy=main-ol]').within(() => { | ||
cy.get('[data-cy=theorem-title]').contains(claim).should("have.length", 1); | ||
}); | ||
}); | ||
|
||
it("finds the correct theorem by step", () => { | ||
cy.get('[data-cy=search]').type(step); | ||
cy.get('[data-cy=main-ol]').within(() => { | ||
cy.get('[data-cy=theorem-title]').contains(claim).should("have.length", 1); | ||
}); | ||
}); | ||
|
||
it("does not find a theorem by random search phrase", () => { | ||
cy.get('[data-cy=search]').type('asöfiawenawkljflsduhaöslkrnal'); | ||
cy.get('[data-cy=main-ol]>li').should("have.length", 0); | ||
}); | ||
}); |
Oops, something went wrong.
3cb3131
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: