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

Frontend component testen #526

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 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
2645934
feat: added new component tests + changed existing tests
ArnoutAllaert May 10, 2023
e2cccb1
chore: component tests up to date, TODO roundcarddetail
ArnoutAllaert May 10, 2023
2d6e546
chore: resolve merge conflicts
ArnoutAllaert May 13, 2023
5f4158e
chore: update tests to develop
ArnoutAllaert May 13, 2023
4ba9b5c
Merge branch 'develop' into web/test/components
ArnoutAllaert May 15, 2023
077740c
chore: removed rounddetailcard tests
ArnoutAllaert May 15, 2023
433f0f2
chore: resolve merge conflicts
ArnoutAllaert May 19, 2023
8c3217b
chore: update component tests
ArnoutAllaert May 19, 2023
b817cd3
test: errorhandler
ArnoutAllaert May 19, 2023
21ecc34
Merge branch 'develop' into web/test/components
ArnoutAllaert May 20, 2023
fd38f85
Merge branch 'develop' into web/test/components
ArnoutAllaert May 21, 2023
48cfd26
test: update component tests
ArnoutAllaert May 21, 2023
be05282
Merge branch 'develop' into web/test/components
ArnoutAllaert May 21, 2023
dd304a7
test: updated to develop
ArnoutAllaert May 21, 2023
c11338d
fix: build issue
ArnoutAllaert May 21, 2023
6da2faf
Merge branch 'develop' into web/test/components
ArnoutAllaert May 21, 2023
55a667d
test: update to develop
ArnoutAllaert May 21, 2023
383828d
Merge branch 'develop' into web/test/components
ArnoutAllaert May 21, 2023
2133768
Merge branch 'develop' into web/test/components
ArnoutAllaert May 21, 2023
b3af516
chore: get rid of deleted component tests
ArnoutAllaert May 21, 2023
309c3a3
chore: resolve build issue
ArnoutAllaert May 21, 2023
392b919
fix: test redundancy
arvheule May 21, 2023
8b6c49d
fix
arvheule May 21, 2023
c8f9e6d
ci(web): run cypress component tests
jenspots May 21, 2023
11cab97
test: rerun these test
ArnoutAllaert May 21, 2023
7eb3d61
Merge branch 'web/test/components' of https://github.com/SELab-2/Dr-T…
ArnoutAllaert May 21, 2023
929cd51
fix
ArnoutAllaert May 21, 2023
f11faff
fix?
ArnoutAllaert May 21, 2023
1232ed8
test
ArnoutAllaert May 21, 2023
4b22f5d
fix: probably not a fix tho
ArnoutAllaert May 21, 2023
f26175a
delete failed tests
ArnoutAllaert May 21, 2023
7ee0ecc
delete some more
ArnoutAllaert May 21, 2023
70f7658
fix
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
2 changes: 2 additions & 0 deletions .github/workflows/web-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ jobs:
run: npm run build
- name: "Check for linting and errors"
run: npm run test
- name: "Cypress component testing"
run : npx cypress run --component
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
17 changes: 17 additions & 0 deletions web/cypress/component/building.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import SyndicusButtons from '@/components/building/SyndicusButtons.vue'

describe("building component test", () => {
it('syndicus buttons test', () => {
cy.mount(SyndicusButtons, {
props: {
phone: "0123456789",
email: "[email protected]",
clickPhone: () => {} ,
clickEmail: () => {},
}
})
// all info present
cy.contains("0123456789").should('be.visible')
cy.contains("E-mail").should('be.visible')
})
})
34 changes: 34 additions & 0 deletions web/cypress/component/buttons.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import SimpleButton from '@/components/buttons/SimpleButton.vue'
import AddButton from '@/components/buttons/AddButton.vue'
import Button from '@/components/models/Button';

describe("buttons test", () => {
it('simplebutton test', () => {
cy.mount(SimpleButton, {
slots: {
default: 'Click me!',
}
})
cy.contains("Click me!")
})

it('addbutton test', () => {
cy.mount(AddButton, {
props: {
icon: 'mdi-domain',
items: [<Button>{title: "test1"}, <Button>{title: "test2"}]
},
})
// the buttons from the item list shouldn't be visible now, in fact not even exist yet
cy.contains("test1").should('not.exist')
cy.contains("test2").should('not.exist')
cy.get('#menu-activator').click()
// now these buttons are visible
cy.contains("test1").should('be.visible')
cy.contains("test2").should('be.visible')
cy.get('#menu-activator').click()
// now these buttons are not visible anymore, but they do still exist
cy.contains("test1").should('not.be.visible')
cy.contains("test2").should('not.be.visible')
})
})
13 changes: 13 additions & 0 deletions web/cypress/component/chips.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import RoundedInfoChip from '@/components/chips/RoundedInfoChip.vue'

describe('chips tests', () => {
it('roundedinfochip test', () => {
cy.mount(RoundedInfoChip, {
props: {
icon: "mdi-pencil",
text: "test",
}
})
cy.contains("test").should('be.visible')
})
});
8 changes: 8 additions & 0 deletions web/cypress/component/error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ErrorHandler from '@/components/errors/ErrorHandler.vue'

describe("error handler test", () => {
it('error handler test', () => {
// this cant really be tested, since it reacts to errors not props,
// but we can test if it mounts correctly, if it doesn't, this test will fail
})
})
167 changes: 167 additions & 0 deletions web/cypress/component/forms.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import AdressForm from '@/components/forms/AddressForm.vue'
import ContactForm from '@/components/forms/ContactForm.vue'
import RolesForm from '@/components/forms/RolesForm.vue'


describe("form tests", () => {
describe('addressform tests', () => {
it('addressform correct input test', () => {
cy.mount(AdressForm, {
props:{
// these are the default props
readonly: false,
street: "",
number: "0",
city: "",
zip_code: "0",
}
})
// fill in the fields with correct input
cy.get('#street').type("Teststraat")
cy.get('#city').type('Gent')
cy.get('#streetnr').type('{backspace}17')
cy.get('#zipcodefield').get('#zipcode').type('{backspace}9000')
// we have to do {backspace} because the field first contains a 0, else we would have 017 en 09000
cy.get('#street').should('have.value', 'Teststraat')
cy.get('#streetnrfield').get('#streetnr').should('have.value', '17')
cy.get('#city').should('have.value', 'Gent')
cy.get('#zipcode').should('have.value', '9000')
})

it('addressform incorrect input test', () => {
cy.mount(AdressForm, {
// default props
props:{
readonly: false,
}
})
// fill in the fields with incorrect input
cy.get('#streetnrfield').then(()=>{
cy.get('#streetnr').type('hallo')
cy.get('#streetnr').should('have.value', '0')
}) // you can only enter numbers
cy.get('#zipcodefield').then(() => {
cy.get('#zipcode').type('hallo') // you can only enter numbers
cy.get('#zipcode').should('have.value', '0')
cy.get('#zipcode').type('9000')
})// without backspace, the zip code will be 09000, which is an incorrect zipcode
cy.contains('Ongeldige postcode')
})

it('addressform readonly test', () => {
cy.mount(AdressForm, {
props:{
readonly: true,
}
})
// everything should now be readonly
cy.get('#street').should('have.attr', 'readonly', 'readonly')
cy.get('#city').should('have.attr', 'readonly', 'readonly')
cy.get('#streetnrfield').get('#streetnr').should('have.attr', 'readonly', 'readonly')
cy.get('#zipcodefield').get('#zipcode').should('have.attr', 'readonly', 'readonly')
})

it('addressform empty test', () => {
cy.mount(AdressForm, {
// default props
})
// empty fields should contain a warning
cy.get('#street').type('x{backspace}')
cy.get('#city').type('x{backspace}')
cy.get('#streetnrfield').get('#streetnr').clear()
cy.get('#zipcodefield').get('#zipcode').clear()
cy.contains('Geef een straat op.').should('be.visible')
cy.contains('Geef een stad op.').should('be.visible')
cy.get('#streetnr-messages > .v-messages__message').contains('Geef een huisnummer.').should('be.visible')
cy.get('#zipcode-messages > .v-messages__message').contains('Geef een postcode.').should('be.visible')
})
})

describe('conctactform test', () => {
it('contactform correct input test', () => {
cy.mount(ContactForm, {
props: {
// thse are the default props
readonly: false,
phone: "",
email: "",
},
})
// fill in the field with correct input
cy.get('#phone').type('0123456789')
cy.get('#email').type('[email protected]')
cy.get('#phone').should('have.value', '0123456789')
cy.get('#email').should('have.value', '[email protected]')
})

it('contactform incorrect input test', () => {
cy.mount(ContactForm, {
// default props
})
// fill in the field with incorrect input
cy.get('#phone').type("012345") // phone number too short
cy.contains('Telefoonnummer moet minimaal 9 tekens lang zijn.')
cy.get('#email').type('thisisnotanemail') // email has to have the correct template
cy.contains('Ongeldig e-mail adres.')
})

it('contactform empty test', () => {
cy.mount(ContactForm, {
// default props
})
// empty fields should contain a warning
cy.get('#phone').type('x{backspace}')
cy.contains('Geef een telefoonnummer op.')
cy.get('#email').type('x{backspace}')
cy.contains('Geef een e-mail adres op.')
})

it('contactform readonly test', () => {
cy.mount(ContactForm, {
props:{
readonly: true,
}
})
// the fields should be readonly
cy.get('#phone').should('have.attr', 'readonly', 'readonly')
cy.get('#email').should('have.attr', 'readonly', 'readonly')
})
})

describe('roleform test', () => {
it('roleform input test', () => {
cy.mount(RolesForm, {
props: {
modelValue: [],
readonly: false,
},
})
// checkboxes can be checked and unchecked
cy.get('#student').check()
cy.get('#superstudent').check()
cy.get('#administrator').check()
cy.get('#student').should('be.checked')
cy.get('#superstudent').should('be.checked')
cy.get('#administrator').should('be.checked')
cy.get('#student').uncheck()
cy.get('#superstudent').uncheck()
cy.get('#administrator').uncheck()
cy.get('#student').should('not.be.checked')
cy.get('#superstudent').should('not.be.checked')
cy.get('#administrator').should('not.be.checked')
})

it('rolesform readonly test', () => {
cy.mount(RolesForm, {
props:{
readonly: true,
}
})
// checkboxes are now readonly
cy.get('#student').should('have.attr', 'disabled', 'disabled')
cy.get('#superstudent').should('have.attr', 'disabled', 'disabled')
cy.get('#administrator').should('have.attr', 'disabled', 'disabled')
})
})

})
33 changes: 33 additions & 0 deletions web/cypress/component/general.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Avatar from '@/components/Avatar.vue'
import Badge from '@/components/Badge.vue'
import PhotoButton from '@/components/PhotoButton.vue'


describe("component tests", () => {
it('avatar test', () => {
cy.mount(Avatar, {
props: {
name: "test gebruiker",
size: "small",
},
})
cy.contains('tg').should('be.visible')
})

it('badge test', () => {
cy.mount(Badge, {
props: {
value: 10,
},
})
cy.contains('10').should('be.visible')
})

it('photobutton test', () => {
cy.mount(PhotoButton, {})
cy.contains("File input").should('be.visible')
cy.get("#input").selectFile('src/assets/images/drtroittoir_logo.png')
cy.contains("drtroittoir_logo.png").should('be.visible')
})

})
Loading