From 212c13fdc367a1494a5e095efdba15e820daa9ab Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Thu, 27 Apr 2023 20:32:35 +0200 Subject: [PATCH 01/33] feat: account test student --- web/cypress/e2e/administrator.cy.ts | 9 +++++++ web/cypress/e2e/student.cy.ts | 32 +++++++++++++++++++++++ web/cypress/e2e/superstudent.cy.ts | 7 +++++ web/cypress/e2e/syndicus.cy.ts | 7 +++++ web/src/components/forms/AddressForm.vue | 4 +++ web/src/components/forms/ContactForm.vue | 2 ++ web/src/layouts/MainLayout.vue | 1 + web/src/views/account/AccountSettings.vue | 4 +++ 8 files changed, 66 insertions(+) create mode 100644 web/cypress/e2e/administrator.cy.ts create mode 100644 web/cypress/e2e/student.cy.ts create mode 100644 web/cypress/e2e/superstudent.cy.ts create mode 100644 web/cypress/e2e/syndicus.cy.ts diff --git a/web/cypress/e2e/administrator.cy.ts b/web/cypress/e2e/administrator.cy.ts new file mode 100644 index 000000000..3be630b9a --- /dev/null +++ b/web/cypress/e2e/administrator.cy.ts @@ -0,0 +1,9 @@ +describe('admin tests', () => { + beforeEach(() => { + cy.login('administrator@trottoir.be', 'administrator') + cy.visit('/planning') + }) + + + +}) diff --git a/web/cypress/e2e/student.cy.ts b/web/cypress/e2e/student.cy.ts new file mode 100644 index 000000000..a496f13dd --- /dev/null +++ b/web/cypress/e2e/student.cy.ts @@ -0,0 +1,32 @@ +describe('student tests', () => { + beforeEach(() => { + cy.login('tudent@trottoir.be', 'student') + cy.visit('/planning') + }) + + + it('wijzig account, maar annuleer', () => { + // own db still rough, so based on selab2-1.ugent.be, + // there are still some bugs + cy.get('#account').click() + cy.get('#edit').click() + cy.get('#personal').then(() => { + cy.get('#phone').clear() + // cancel button should not be clickable when a field does not meet the requirements, + // this is still possible now + cy.get('#phone').type('0111111111') + cy.get('#email').type('{backspace}') // depends on position of cursor + }) + cy.get('#address').then(() => { + cy.get('#street').type('t') + cy.get('#streetnr').type('{backspace}') + cy.get('#city').type('olkn') + cy.get('#zipcode').type('1') + }) + cy.get('#cancel').click() + cy.get('#personal').get('#phone').should('not.contain.text', '0111111111') + // cancel keeps the changes, but doesn't push to db, so on reload the changes are gone + // obviously the changes should be gone once cancel is pushed, and not just on reload after cancel + }) + +}) diff --git a/web/cypress/e2e/superstudent.cy.ts b/web/cypress/e2e/superstudent.cy.ts new file mode 100644 index 000000000..25e52e4fa --- /dev/null +++ b/web/cypress/e2e/superstudent.cy.ts @@ -0,0 +1,7 @@ +describe('superstudent tests', () => { + beforeEach(() => { + cy.login('superstudent@trottoir.be', 'super_student') + cy.visit('/planning') + }) + +}) diff --git a/web/cypress/e2e/syndicus.cy.ts b/web/cypress/e2e/syndicus.cy.ts new file mode 100644 index 000000000..28aaff1db --- /dev/null +++ b/web/cypress/e2e/syndicus.cy.ts @@ -0,0 +1,7 @@ +describe('syndicus tests', () => { + beforeEach(() => { + cy.login('syndicusr@trottoir.be', 'syndicus') + cy.visit('/planning') + }) + +}) diff --git a/web/src/components/forms/AddressForm.vue b/web/src/components/forms/AddressForm.vue index daaf5da1d..ee0665c30 100644 --- a/web/src/components/forms/AddressForm.vue +++ b/web/src/components/forms/AddressForm.vue @@ -8,6 +8,7 @@ > Bewerk Account Date: Thu, 27 Apr 2023 22:47:11 +0200 Subject: [PATCH 02/33] feat: description of tests for every type of user --- web/cypress/e2e/administrator.cy.ts | 39 +++++++++++++++++++++++++++++ web/cypress/e2e/login.cy.ts | 8 +++--- web/cypress/e2e/student.cy.ts | 14 +++++++++-- web/cypress/e2e/superstudent.cy.ts | 34 ++++++++++++++++++++++++- web/cypress/e2e/syndicus.cy.ts | 18 ++++++++++++- 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/web/cypress/e2e/administrator.cy.ts b/web/cypress/e2e/administrator.cy.ts index 3be630b9a..a57fb6470 100644 --- a/web/cypress/e2e/administrator.cy.ts +++ b/web/cypress/e2e/administrator.cy.ts @@ -4,6 +4,45 @@ describe('admin tests', () => { cy.visit('/planning') }) + it('add new user', () => { + // go to user overview + // click new user + // add user data + // save + }) + + it('edit a user', () => { + // go to user overview + // click user + // press edit button + // alter user data + // save + }) + + it('delete a user', () => { + // go to user overview + // click user + // press edit button + // press delete + // press confirm + }) + + it('check the profitability statistics', () => { + // not yet implemented + }) + + it('add garbage schedule to a building', () => { + cy.visit('/gebouw') + // select building + }) + + it('edit garbage schedule of a building', () => { + cy.visit('/gebouw') + // select building + }) + + + }) diff --git a/web/cypress/e2e/login.cy.ts b/web/cypress/e2e/login.cy.ts index ff9001c4c..ed61bb7cb 100644 --- a/web/cypress/e2e/login.cy.ts +++ b/web/cypress/e2e/login.cy.ts @@ -3,10 +3,8 @@ describe('login tests', () => { cy.visit('/') }) - // TODO .only wegdoen wanneer api niet meer crasht bij foutieve login - it.only('log in succesfull', () =>{ + it('log in succesfull', () =>{ cy.login('administrator@trottoir.be', 'password') - cy.visit('/planning') }) it('log in failed: incorrect password', () =>{ @@ -24,4 +22,8 @@ describe('login tests', () => { cy.get('#login') }) + // TODO: user doesn't yet have a login + it('ask login data', () => { + }) + }) diff --git a/web/cypress/e2e/student.cy.ts b/web/cypress/e2e/student.cy.ts index a496f13dd..0dff3b01e 100644 --- a/web/cypress/e2e/student.cy.ts +++ b/web/cypress/e2e/student.cy.ts @@ -1,11 +1,21 @@ describe('student tests', () => { beforeEach(() => { cy.login('tudent@trottoir.be', 'student') - cy.visit('/planning') }) - it('wijzig account, maar annuleer', () => { + it('student performs a round', () => { + // we should already be at "/planning" + // student selects round which he/her wants to start + // student goes to first building, + // performs garbage tasks, takes pictures and or leaves a comment + // student indicates building as done + // repeat for all buildings + // student ends the round + }) + + + it('edit account, but cancel changes', () => { // own db still rough, so based on selab2-1.ugent.be, // there are still some bugs cy.get('#account').click() diff --git a/web/cypress/e2e/superstudent.cy.ts b/web/cypress/e2e/superstudent.cy.ts index 25e52e4fa..d958458b5 100644 --- a/web/cypress/e2e/superstudent.cy.ts +++ b/web/cypress/e2e/superstudent.cy.ts @@ -1,7 +1,39 @@ describe('superstudent tests', () => { beforeEach(() => { cy.login('superstudent@trottoir.be', 'super_student') - cy.visit('/planning') + }) + + // there is a lot of overlap for superstudents and admins, + // these overlaps will be tested with either a superstudent or an admin. There is no need to test them twice. + + it('create round', () => { + // go to round overview? + // press create button + // add buildings + // add name + // save + }) + + it('edit round', () => { + // go to round overview + cy.visit('/ronde') + // press on the round you wish to change + // add buildings + // add name + // save + }) + + it('give a round to a student', () => { + // go to the dedicated page + // select round + // select student + // save + }) + + it('observe students currently doing a round', () => { + // go to the overview page + cy.visit('/ronde/overzicht') + // click on the student/round to get more details }) }) diff --git a/web/cypress/e2e/syndicus.cy.ts b/web/cypress/e2e/syndicus.cy.ts index 28aaff1db..ec5f36da6 100644 --- a/web/cypress/e2e/syndicus.cy.ts +++ b/web/cypress/e2e/syndicus.cy.ts @@ -1,7 +1,23 @@ describe('syndicus tests', () => { beforeEach(() => { cy.login('syndicusr@trottoir.be', 'syndicus') - cy.visit('/planning') + }) + + it('check building', () => { + // syndicus checks for comments left on one of their buildings + }) + + it('add building', () => { + // press create button + // add building data + // save + }) + + it('edit building', () => { + // press building from buildings overview (right now a bit unclear as to how to do this, with the v-for element) + // press edit button + // alter building data + // save }) }) From b824be85f82de54586328cba8b2136d44f5aeab0 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Thu, 27 Apr 2023 23:12:20 +0200 Subject: [PATCH 03/33] chore: test component buildingcard with correct props --- web/cypress/component/test.cy.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/cypress/component/test.cy.ts b/web/cypress/component/test.cy.ts index f3d702d10..46eba40fe 100644 --- a/web/cypress/component/test.cy.ts +++ b/web/cypress/component/test.cy.ts @@ -1,5 +1,6 @@ import RoundedButton from '../../src/components/buttons/RoundedButton.vue' import AddButton from '../../src/components/buttons/AddButton.vue' +import BuildingCard from '../../src/components/building/BuildingCard' describe("test", () => { it('uses custom text for the button label', () => { @@ -21,4 +22,13 @@ describe("test", () => { }) cy.get('#menu-activator').click() }) + + it('buildingcard', () => { + cy.mount(BuildingCard, { + props: { + building: {id: 6, name: "testgebouw", address:{street: "teststraat", number: 5, zip_code: 9000, city: "Gent"}} + }, + }) + // can't really click on it, as there is no active router to perform router.push(...) + }) }) From 5fb92f785d2a634afcd4a9a844572a582fef773e Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Fri, 28 Apr 2023 11:25:43 +0200 Subject: [PATCH 04/33] test: component garbageschedule --- web/cypress/component/test.cy.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/cypress/component/test.cy.ts b/web/cypress/component/test.cy.ts index 46eba40fe..ec69bb923 100644 --- a/web/cypress/component/test.cy.ts +++ b/web/cypress/component/test.cy.ts @@ -1,6 +1,7 @@ import RoundedButton from '../../src/components/buttons/RoundedButton.vue' import AddButton from '../../src/components/buttons/AddButton.vue' import BuildingCard from '../../src/components/building/BuildingCard' +import GarbageSchedule from '../../src/components/building/GarbageSchedule' describe("test", () => { it('uses custom text for the button label', () => { @@ -31,4 +32,16 @@ describe("test", () => { }) // can't really click on it, as there is no active router to perform router.push(...) }) + + it.only('garbageschedule', ()=>{ + cy.mount(GarbageSchedule, { + props: { + schedule: [{id: 6, user: {first_name: "test", last_name: "user"}}, { + id: 7, + user: {first_name: "one", last_name: "two"} + }] + } + }) + // not exactly correct + }) }) From 5f1700f35dc0f65b4076f844e9c0003be8fc6770 Mon Sep 17 00:00:00 2001 From: Arnout_Allaert Date: Fri, 28 Apr 2023 17:45:42 +0200 Subject: [PATCH 05/33] feat: admin user tests + table component test --- web/cypress.config.ts | 2 +- web/cypress/component/table.cy.ts | 48 ++++++++++++++++++++ web/cypress/component/test.cy.ts | 8 ++-- web/cypress/e2e/administrator.cy.ts | 54 ++++++++++++++++++++++- web/cypress/e2e/student.cy.ts | 5 ++- web/cypress/support/commands.ts | 6 +-- web/src/components/forms/RolesForm.vue | 3 ++ web/src/components/table/Table.vue | 2 +- web/src/layouts/MainLayout.vue | 1 + web/src/views/account/AccountSettings.vue | 7 ++- web/src/views/account/UserCreation.vue | 9 +++- web/src/views/dashboard/Users.vue | 3 +- 12 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 web/cypress/component/table.cy.ts diff --git a/web/cypress.config.ts b/web/cypress.config.ts index 977510690..a5cb9a4e3 100644 --- a/web/cypress.config.ts +++ b/web/cypress.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from "cypress"; export default defineConfig({ e2e: { supportFile: "cypress/support/e2e.ts", - baseUrl: "http://localhost:3000/", + baseUrl: "http://sel2-1.ugent.be/", setupNodeEvents(on, config) { // implement node event listeners here require('@cypress/code-coverage/task')(on, config) diff --git a/web/cypress/component/table.cy.ts b/web/cypress/component/table.cy.ts new file mode 100644 index 000000000..c8da14ba7 --- /dev/null +++ b/web/cypress/component/table.cy.ts @@ -0,0 +1,48 @@ +import Table from '../../src/components/table/Table.vue' +import {Header} from "../../src/components/table/Header"; +import {RowType} from "../../src/components/table/RowType"; +import {BuildingQuery, Result} from "@selab-2/groep-1-query"; + +describe("custom table test", () => { + it('', () => { + // TODO test sorting + cy.mount(Table, { + props: { + entries: [ + {id: 6, name: "testgebouw", address: + {street: "teststraat", number: 5, zip_code: 9000, city: "Gent"}}, + {id: 1, name: "andergebouw", address: + {street: "anderestraat", number: 7, zip_code: 9000, city: "Gent"}}, + ], + headers: [{ + id: 0, + name: "Gebouw", + fit: false, + get: (e) => e.name, + type: RowType.TEXT, + sortable: false, + }, + { + id: 1, + name: "Adres", + fit: false, + get: (e) => + e.address.street + " " + e.address.number, + type: RowType.TEXT, + sortable: false, + } + ], + }, + }) + cy.get('#table').then( () => { + // cy.contains('th, Gebouw') + // cy.contains('th, Adres') // table heads aren't just plain text, so this doesn't work + cy.contains('td', 'testgebouw') + cy.contains('td', 'andergebouw') + cy.contains('td', 'teststraat 5') + cy.contains('td', 'anderestraat 7') + // for this test, there is no City header, so cities shouldn't be displayed in the table + cy.contains('td', 'Gent').should('not.exist') + }) + }) +}) diff --git a/web/cypress/component/test.cy.ts b/web/cypress/component/test.cy.ts index ec69bb923..7009222de 100644 --- a/web/cypress/component/test.cy.ts +++ b/web/cypress/component/test.cy.ts @@ -1,10 +1,10 @@ import RoundedButton from '../../src/components/buttons/RoundedButton.vue' import AddButton from '../../src/components/buttons/AddButton.vue' -import BuildingCard from '../../src/components/building/BuildingCard' -import GarbageSchedule from '../../src/components/building/GarbageSchedule' +import BuildingCard from '../../src/components/building/BuildingCard.vue' +import GarbageSchedule from '../../src/components/building/GarbageSchedule.vue' describe("test", () => { - it('uses custom text for the button label', () => { + it('roundedbutton', () => { cy.mount(RoundedButton, { props: { icon: 'mdi-domain', @@ -33,7 +33,7 @@ describe("test", () => { // can't really click on it, as there is no active router to perform router.push(...) }) - it.only('garbageschedule', ()=>{ + it('garbageschedule', ()=>{ cy.mount(GarbageSchedule, { props: { schedule: [{id: 6, user: {first_name: "test", last_name: "user"}}, { diff --git a/web/cypress/e2e/administrator.cy.ts b/web/cypress/e2e/administrator.cy.ts index a57fb6470..f78ea8d0f 100644 --- a/web/cypress/e2e/administrator.cy.ts +++ b/web/cypress/e2e/administrator.cy.ts @@ -1,30 +1,80 @@ describe('admin tests', () => { beforeEach(() => { cy.login('administrator@trottoir.be', 'administrator') - cy.visit('/planning') + cy.visit('/ronde/overzicht') }) it('add new user', () => { // go to user overview + cy.get('#users').click() // click new user + cy.get('#new').click() // add user data - // save + cy.get('#firstname').type('test') + cy.get('#lastname').type('naam') + cy.get('#personal').then(() => { + cy.get('#phone').type('0123456789') + cy.get('#email').type('test@trottoir.be') + }) + cy.get('#address').then(() => { + cy.get('#street').type('teststraat') + cy.get('#streetnr').type('1') + cy.get('#city').type('Teststad') + cy.get('#zipcode').type('1234') + }) + cy.get('#password').type('testwachtwoord') + cy.get('#repeat').type('testwachtwoord') + cy.get('#roles').then(() => { + cy.get('#student').check() + cy.get('#superstudent').check() + cy.get('#administrator').check() + }) + cy.get('#create').click() + // check if user in userlist + cy.get('#usertable').get('#table').contains('td', 'test naam') + }) it('edit a user', () => { // go to user overview + cy.get('#users').click() // click user + cy.get('#usertable').get('#table').contains('td', 'test naam').click() // press edit button + cy.get('#edit').click() // alter user data + // most of this has been tested in the student tests, + // however only admins can change name, roles or password of a user + cy.get("#firstname").clear().type("nieuwe") + cy.get("#lastname").clear().type("gebruiker") + cy.get('#roles').then(() => { + cy.get('#administrator').uncheck() + }) + cy.get('#password').type('nieuwwachtwoord') + cy.get('#repeat').type('nieuwwachtwoord') // save + cy.get('#save').click() + // confirm + cy.get('#submit').click() + // check if user is updated in the table + // cy.get('#users').click() + cy.get('#usertable').get('#table').contains('td', 'nieuwe gebruiker') }) it('delete a user', () => { // go to user overview + cy.get('#users').click() // click user + cy.get('#usertable').get('#table').contains('td', 'nieuwe gebruiker').click() // press edit button + cy.get('#edit').click() // press delete + cy.get('#delete').click() // press confirm + cy.get('#submit').click() + // user should not be present in the table + // cy.get('#users').click() + cy.get('#usertable').get('#table').contains('td', 'nieuwe gebruiker').should('not.exist') }) it('check the profitability statistics', () => { diff --git a/web/cypress/e2e/student.cy.ts b/web/cypress/e2e/student.cy.ts index 0dff3b01e..1448eba6f 100644 --- a/web/cypress/e2e/student.cy.ts +++ b/web/cypress/e2e/student.cy.ts @@ -1,6 +1,7 @@ describe('student tests', () => { beforeEach(() => { - cy.login('tudent@trottoir.be', 'student') + cy.login('student@trottoir.be', 'student') + cy.visit('/planning') }) @@ -30,7 +31,7 @@ describe('student tests', () => { cy.get('#address').then(() => { cy.get('#street').type('t') cy.get('#streetnr').type('{backspace}') - cy.get('#city').type('olkn') + cy.get('#city').type('blabla') cy.get('#zipcode').type('1') }) cy.get('#cancel').click() diff --git a/web/cypress/support/commands.ts b/web/cypress/support/commands.ts index c49d4af65..609449353 100644 --- a/web/cypress/support/commands.ts +++ b/web/cypress/support/commands.ts @@ -50,10 +50,10 @@ Cypress.Commands.add('login' as any, (email: string, password:string) => { cy.session([email, password], () => { cy.visit('/') - cy.get('#email').type('administrator@trottoir.be') - cy.get('#password').type('password') + cy.get('#email').type(email) + cy.get('#password').type(password) cy.get('#login').click() - cy.get('#logout').should('be.visible') + // cy.get('#logout').should('be.visible') }, { cacheAcrossSpecs: true diff --git a/web/src/components/forms/RolesForm.vue b/web/src/components/forms/RolesForm.vue index 443c89d38..bc6033817 100644 --- a/web/src/components/forms/RolesForm.vue +++ b/web/src/components/forms/RolesForm.vue @@ -4,6 +4,7 @@ - +
Annuleer - + {{ popupSubmitMsg }} diff --git a/web/src/views/account/UserCreation.vue b/web/src/views/account/UserCreation.vue index 84ae62ba0..f2c31cddc 100644 --- a/web/src/views/account/UserCreation.vue +++ b/web/src/views/account/UserCreation.vue @@ -12,6 +12,7 @@ > Wachtwoord - +
-
+