Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Web: e2e testen #542

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
212c13f
feat: account test student
ArnoutAllaert Apr 27, 2023
f538638
feat: description of tests for every type of user
ArnoutAllaert Apr 27, 2023
b824be8
chore: test component buildingcard with correct props
ArnoutAllaert Apr 27, 2023
5fb92f7
test: component garbageschedule
ArnoutAllaert Apr 28, 2023
5f1700f
feat: admin user tests + table component test
ArnoutAllaert Apr 28, 2023
7d5bde9
feat: superstudent round tests
ArnoutAllaert Apr 29, 2023
94438ae
chore: re-order component tests
ArnoutAllaert Apr 29, 2023
61782c7
feat: card test + added some TODO's
ArnoutAllaert Apr 29, 2023
10d88df
feat: component tests cards, filter, forms
ArnoutAllaert Apr 30, 2023
a093c1d
feat: component tests images and popups
ArnoutAllaert May 1, 2023
c9ad473
feat: component tests round + general
ArnoutAllaert May 1, 2023
eaadb1e
Merge branch 'develop' into web/test/UI_routing
ArnoutAllaert May 3, 2023
d60b303
feat: table sort test + finalising component tests
ArnoutAllaert May 3, 2023
8deeb41
Merge branch 'develop' into web/test/UI_routing
ArnoutAllaert May 4, 2023
663d02a
chore: addbutton test and little tweaks component testing
ArnoutAllaert May 5, 2023
bc5f30f
chore: correct formatting + extra comments
ArnoutAllaert May 6, 2023
167e294
Merge branch 'develop' into web/test/UI_routing
ArnoutAllaert May 8, 2023
ed9bf7a
chore: new branch for e2e tests
ArnoutAllaert May 8, 2023
bbaa09a
chore: resolve merge conflicts
ArnoutAllaert May 10, 2023
c976f16
chore: update to dev
ArnoutAllaert May 10, 2023
51daa3b
chore: update from develop
ArnoutAllaert May 10, 2023
d2b60d3
chore: updated login tests
ArnoutAllaert May 10, 2023
192b490
chore: updated e2e tests
ArnoutAllaert May 10, 2023
81b43c6
chore: resolve merge conflicts
ArnoutAllaert May 10, 2023
07995ed
chore: resolve merge conflicts
ArnoutAllaert May 13, 2023
29f7a50
feat: added student roun and admin building tests
ArnoutAllaert May 13, 2023
27476f2
feat: administrator building tests
ArnoutAllaert May 14, 2023
682d96b
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 15, 2023
e36d135
chore: merge develop
ArnoutAllaert May 16, 2023
963f2f5
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 19, 2023
a161947
feat: student test
ArnoutAllaert May 19, 2023
822cbd2
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 20, 2023
8884fb1
test: admin
ArnoutAllaert May 20, 2023
b8931ad
test: superstudent
ArnoutAllaert May 20, 2023
441467a
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 20, 2023
051d226
test: superstudent
ArnoutAllaert May 20, 2023
725d1ef
test: student
ArnoutAllaert May 20, 2023
9baf5c3
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 21, 2023
e28ad9f
tests: superstudent
ArnoutAllaert May 21, 2023
51d1563
test: admin
ArnoutAllaert May 21, 2023
15f9c85
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 21, 2023
4636b22
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 21, 2023
544e786
test: administrator garbage schedule
ArnoutAllaert May 21, 2023
41e0c6f
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 21, 2023
54334db
test: delete building
ArnoutAllaert May 21, 2023
69e7732
chore: fix build problems
ArnoutAllaert May 21, 2023
b26a864
chore: small changes
ArnoutAllaert May 21, 2023
84e333d
chore: extra comments
ArnoutAllaert May 21, 2023
12cf02e
chore: deleted outdated tests
ArnoutAllaert May 21, 2023
5b077b2
Merge branch 'develop' into web/test/e2e
ArnoutAllaert May 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions api/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 api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"eslint-config-prettier": "^8.6.0",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"prisma": "^4.14.0",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"typescript": "^5.0.4"
Expand Down
1 change: 1 addition & 0 deletions web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
supportFile: "cypress/support/e2e.ts",
//baseUrl: "https://sel2-1.ugent.be/",
baseUrl: "http://localhost:3000/",
setupNodeEvents(on, config) {
// implement node event listeners here
Expand Down
14 changes: 0 additions & 14 deletions web/cypress/component/test.cy.ts

This file was deleted.

211 changes: 211 additions & 0 deletions web/cypress/e2e/administrator.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
describe('admin tests', () => {
beforeEach(() => {
cy.visit('/')
cy.get('#email').type('[email protected]')
cy.get('#password').type('administrator')
cy.get('#login').click()
})

it('add new user', () => {
// go to user overview
cy.get('#users').click()
// click new user
cy.get('#newuser').click()
// add user data
cy.get('#firstname').type('test')
cy.get('#lastname').type('naam')
cy.get('#personal').then(() => {
cy.get('#phone').type('0123456789')
cy.get('#email').type('[email protected]')
})
cy.get('#address').then(() => {
cy.get('#street').type('teststraat')
cy.get('#streetnr').type('{backspace}1')
cy.get('#city').type('Teststad')
cy.get('#zipcode').type('{backspace}1234')
})
cy.get('#password').type('t3stw@chtwOord')
cy.get('#repeat').type('t3stw@chtwOord')
cy.get('#roles').then(() => {
cy.get('#student').check()
cy.get('#superstudent').check()
cy.get('#administrator').check()
})
cy.get('#create').click()
// confirm
// cy.get('#submit').click()
// we are now at the new user page
cy.contains('test naam')
cy.contains('Persoonlijke gegevens')
// check if user in userlist
cy.get('#users').click()
cy.contains('test naam')
})

it('edit a user', () => {
// go to user overview
cy.get('#users').click()
// click user
cy.contains('test naam').click()
// press edit button
cy.get('#editcancel').click()
// alter user data
// most of this has been tested in the student tests,
// however only admins can change name or roles of a user
cy.get("#firstname").clear().type("nieuwe")
cy.get("#lastname").clear().type("gebruiker")
cy.get('#roles').then(() => {
cy.get('#administrator').uncheck()
})
// save
cy.get('#save').click()
// confirm
cy.get('#submit').click()
// check if user is updated in the table
// cy.get('#users').click()
cy.contains('nieuwe gebruiker')
})

it('delete a user', () => {
// go to user overview
cy.get('#users').click()
// click user
cy.contains('nieuwe gebruiker').click()
// press edit button
cy.get('#editcancel').click()
// press delete
cy.get('#delete').click()
// press confirm
cy.get('#submit').click()
cy.contains('Deze account is verwijderd')
// user should not be present in the table
cy.get('#users').click()
cy.contains('nieuwe gebruiker').should('not.exist')
})

it('restore deleted user', () => {
// go to user overview
cy.get('#users').click()
// see hidden users
cy.get('#hidden').check()
// click user
cy.contains('nieuwe gebruiker').click()
cy.get('#restore').click()
// messaeg saying user is deleted should be gone
cy.contains('Deze account is verwijderd').should('not.exist')
})

it('check the profitability statistics user', () => {
// go to user overview
cy.get('#users').click()
// click user
cy.contains('nieuwe gebruiker').click()
// check if stats are present
cy.contains('Prestaties').should('be.visible')
cy.contains('Bekijk het aantal gepresteerde uren per maand.').should('be.visible')
cy.get('#year').should('have.value', 2023)
})

it('check the profitability statistics building', () => {
// go to building overview
cy.get('#buildings').click()
// click building
cy.contains('Building 1').click()
// it can take a while to load all the schedules
cy.wait(10000)
// check if stats are present
cy.contains('Prestaties').should('be.visible')
cy.contains('Bekijk het aantal gepresteerde uren per maand.').should('be.visible')
cy.get('#year').should('have.value', 2023)
})

it('add garbage schedule to a building', () => {
cy.get('#buildings').click()
// select building
cy.contains('Building 1').click()
// it can take a while to load all the schedules
cy.wait(10000)
// add garbage
cy.get('#addgarbage').click()
cy.get('#action').type('buiten zetten')
cy.get('#frequency').parent().click()
cy.contains('wekelijks').click()
cy.get('#startdate').type('2023-05-22')
cy.get('#enddate').type('2023-06-22')
cy.get('#starttime').type('20:00')
cy.get('#addtoschedule').click()
cy.get('#schedule').click()
// check if schedule is added
cy.get('#buildings').click()
cy.contains('Building 1').click()
// it can take a while to load all the schedules
cy.wait(10000)
cy.contains('buiten zetten')
// onder Taken bij het gebouw, of nee toch niet, dus waar kan je dit zien? wss zo bij het aanmaken van een ronde
})

it('delete garbage schedule of a building', () => {
cy.get('#buildings').click()
// it can take a while to load all the schedules
cy.wait(10000)
// select building
cy.contains('test building').click()
cy.get('#addgarbage').click()
cy.contains('Voorlopig schema').click()
// remove first task
cy.get('#remove').click()
//edit garbage
})

// editing garbage schedule is just deleting the old one and creating a new one,
// so no need to test add and delete again

it('delete building', () => {
cy.contains('Building 1').click()
// it can take a while to load all the schedules
cy.wait(10000)
// delete
cy.get('#delete').click()
cy.contains('Dit gebouw is verwijderd.').should('be.visible')
cy.get('#buildings').click()
cy.contains('Building 1').should('not.exist')
})

it('add new template', () => {
// go to template list
cy.get('#templates').click()
// click add button
cy.get('#addtemplate').click()
// fill in the fields
cy.get('#templatename').type('test template')
cy.get('#subject').type('test the templates')
cy.get('#templatebody').type('This is a test template and should not be used for real emails/messages!')
// save
cy.get('#savetemplate').click()
// check if template is in the list
cy.get('#templates').click()
cy.contains('test template')
})

it('edit template', () => {
cy.get('#templates').click()
cy.get(':nth-child(4) > :nth-child(2) > .v-btn').click()
cy.get('#templatename').clear()
cy.get('#templatename').type('new template')
cy.get('#subject').type('.')
cy.get('#templatebody').type('Delete this template.')
// save
cy.get('#savetemplate').click()
// check if template is in the list
cy.get('#templates').click()
cy.contains('new template')

})

it.only('delete templete', () => {
cy.get('#templates').click()
cy.get(':nth-child(4) > :nth-child(3) > .v-btn').click()
cy.contains('new template').should('not.exist')
})

})
19 changes: 14 additions & 5 deletions web/cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ describe('login tests', () => {
cy.visit('/')
})

// TODO .only wegdoen wanneer api niet meer crasht bij foutieve login
it.only('log in succesfull', () =>{
cy.login('[email protected]', 'password')
cy.visit('/planning')
it('log in and out succesfull', () =>{
cy.get('#email').type('[email protected]')
cy.get('#password').type('administrator')
cy.get('#login').click()
cy.get('#logout').click()
// we should be back at the log in
cy.get('#login')
})

it('log in failed: incorrect password', () =>{
Expand All @@ -19,9 +22,15 @@ describe('login tests', () => {

it('log in failed: incorrect email', () =>{
cy.get('#email').type('[email protected]')
cy.get('#password').type('password')
cy.get('#password').type('administrator')
cy.get('#login').click()
// we should have stayed on the login screen
cy.get('#login')
})

it('ask login data', () => {
cy.get('#contact').click()
cy.get('#popup').should('be.visible')
})

})
7 changes: 5 additions & 2 deletions web/cypress/e2e/navbar.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
describe('navigation bar tests', () => {
beforeEach(() => {
cy.login('[email protected]', 'password')
cy.visit('/planning')
cy.visit('/')
cy.get('#email').type('[email protected]')
cy.get('#password').type('administrator')
cy.get('#login').click()
})

it('collapse and expand', () => {
cy.get('#navbar-visible').click()
cy.get('#logout').should('not.be.visible')
cy.get('#navbar-visible').click()
cy.get('#logout').should('be.visible')
cy.get('#logout').click()
})
})
Loading