Skip to content

Commit

Permalink
added final component tests so all finished components/pages are prop…
Browse files Browse the repository at this point in the history
…erly tested now
  • Loading branch information
arnedierick committed May 16, 2024
1 parent a193b27 commit 9d3148c
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/cypress/components/GroupClusterDropdown.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import GroupClusterDropdown from '../../src/pages/projectCreate/components/GroupClusterDropdown'

describe('GroupClusterDropdown', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<GroupClusterDropdown courseId={1}/>).should("exist")
cy.get(".ant-select-selector").should("be.visible")
cy.get(".ant-select-selector").click()
cy.get("body").should("contain.text", "no")
})
})
14 changes: 14 additions & 0 deletions frontend/cypress/components/GroupClusterModalContent.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import GroupClusterModalContent from '../../src/pages/projectCreate/components/GroupClusterModalContent'

describe('GroupClusterModalContent', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<GroupClusterModalContent courseId={1} onClusterCreated={(c) => {}} onClose={()=>{}}/>).should("exist")
cy.get("#name").type("TEST")
cy.get("body").should("contain.text", "project.change.clusterName")
.and("contain.text", "project.change.amountOfGroups")
.and("contain.text", "project.change.groupSize")
cy.get(':nth-child(1) > .ant-btn').should("be.visible")
cy.get(':nth-child(2) > .ant-btn').should("be.visible")
})
})
15 changes: 15 additions & 0 deletions frontend/cypress/components/SubmitForm.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SubmitForm from '../../src/pages/submit/components/SubmitForm'

describe('SubmitForm', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<SubmitForm/>).should("exist")
cy.get("body").should("contain.text", "project.uploadAreaTitle")
.and("contain.text", "project.uploadAreaSubtitle")
})
it('opens a file window when clicked', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<SubmitForm />).should("exist")
cy.get('.ant-upload-drag-container').click()
});
})
48 changes: 48 additions & 0 deletions frontend/cypress/pages/ProjectCreate.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import ProjectCreate from '../../src/pages/projectCreate/ProjectCreate'
import {BrowserRouter} from "react-router-dom";

describe('ProjectCreate', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><ProjectCreate /></BrowserRouter>).should("exist")
cy.get("body").should("contain.text", "project.change.title")
})

it('shows message for empty required fields', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><ProjectCreate /></BrowserRouter>).should("exist")
cy.get("body").should("not.contain.text", "project.change.nameMessage")
cy.get("#name").click()
cy.get("body").click()
cy.get("body").should("contain.text", "project.change.nameMessage")
cy.get("#name").type("Test name")
cy.get("body").click()
cy.get("body").should("not.contain.text", "project.change.nameMessage")
})

it('shows the description in the preview', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><ProjectCreate /></BrowserRouter>).should("exist")
cy.get("#description").type("Test description")
cy.get('[data-node-key="preview"]').click()
cy.get("body").should("contain.text", "Test description")
})

it('can switch between tabs', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><ProjectCreate /></BrowserRouter>).should("exist")
cy.get("#name").should("be.visible")
cy.get(".ant-select-selector").should("not.be.visible")
cy.get("#structureTest").should("not.be.visible")
cy.get("#rc-tabs-6-tab-groups").click()
cy.get("#name").should("not.be.visible")
cy.get(".ant-select-selector").should("be.visible")
cy.get("#structureTest").should("not.be.visible")
// idk why maar als ik 1maal klik dan switcht hij niet
cy.get('#rc-tabs-6-tab-structure').click()
cy.get('#rc-tabs-6-tab-structure').click()
cy.get("#name").should("not.be.visible")
cy.get(".ant-select-selector").should("not.be.visible")
cy.get("#structureTest").should("be.visible")
})
})
9 changes: 9 additions & 0 deletions frontend/cypress/pages/Submission.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Submission from '../../src/pages/submission/Submission'

describe('Submission', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<Submission />).should("exist")
cy.get(".ant-spin-dot").should("be.visible")
})
})
16 changes: 16 additions & 0 deletions frontend/cypress/pages/Submit.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Submit from '../../src/pages/submit/Submit'
import {BrowserRouter} from "react-router-dom";

describe('Submit', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><Submit /></BrowserRouter>).should("exist")
cy.get("body").should("contain.text", "project.files")
})
it('disables submit button by default', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<BrowserRouter><Submit /></BrowserRouter>).should("exist")
cy.get('.ant-btn-default').should("be.visible").and("not.be.disabled")
cy.get('.ant-btn-primary').should("be.visible").and("be.disabled")
})
})

0 comments on commit 9d3148c

Please sign in to comment.