diff --git a/frontend/e2e/admin/dashboard.cy.ts b/frontend/e2e/admin/dashboard.cy.ts new file mode 100644 index 0000000..eaa0b3e --- /dev/null +++ b/frontend/e2e/admin/dashboard.cy.ts @@ -0,0 +1,48 @@ +describe('Admin Dashboard', () => { + beforeEach(() => { + cy.visit('/login') + + cy.wait(1000) + + cy.get('input[type="email"]').type('test@example.com') + cy.get('input[type="password"]').type('password') + cy.get('button[type="submit"]').click() + + cy.wait(1000) + }) + + it('should load the list of companies', () => { + cy.contains("Firmy").click() + cy.url().should('include', '/dashboard/admin/companies') + cy.get("table").find("tr").should("have.length.greaterThan", 1) + }) + + it('should load the list of students', () => { + cy.contains("Študenti").click() + cy.url().should('include', '/dashboard/admin/students') + cy.get("table").find("tr").should("have.length.greaterThan", 1) + }) + + it('should load the list of internships', () => { + cy.contains("Praxe").click() + cy.url().should('include', '/dashboard/admin/internships') + cy.get("table").find("tr").should("have.length.greaterThan", 1) + }) + + it('should load the my account details', () => { + cy.contains("Môj profil").click() + cy.url().should('include', '/account') + + cy.contains("Môj profil") + cy.contains("Osobné údaje") + cy.contains("Meno") + cy.contains("Priezvisko") + + // check if the names match the default test user + cy.get('#page-container-card > div:nth-child(5) > div:nth-child(1) > div > div.v-list-item-subtitle').should('have.text', 'Test') + cy.get("#page-container-card > div:nth-child(5) > div:nth-child(2) > div > div.v-list-item-subtitle").should('have.text', 'User') + + // check if the "change my password" button is there + cy.get("#page-container-card > div:nth-child(6) > div > div > a > span.v-btn__content").invoke('text').then(text => text.trim()).should('equal', 'Zmeniť heslo') + }) +}) \ No newline at end of file diff --git a/frontend/e2e/admin/students/list.cy.ts b/frontend/e2e/admin/students/list.cy.ts new file mode 100644 index 0000000..79faa96 --- /dev/null +++ b/frontend/e2e/admin/students/list.cy.ts @@ -0,0 +1,104 @@ +describe('Admin Student CRUD', () => { + beforeEach(() => { + cy.visit('/login') + + cy.wait(1000) + + cy.get('input[type="email"]').type('test@example.com') + cy.get('input[type="password"]').type('password') + cy.get('button[type="submit"]').click() + + cy.wait(1000) + + cy.contains("Študenti").click() + cy.url().should('include', '/dashboard/admin/students') + }) + + it('should load the list of students in a proper format', () => { + cy.get('table').within(() => { + cy.contains('th', 'Meno').parent('tr').then(($headerRow) => { + const nameColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("Meno")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(nameColumnIndex).invoke('text').then((name) => { + const nameParts = name.trim().split(' ') + expect(nameParts).to.have.length.at.least(2) + expect(nameParts[0]).to.not.be.empty + expect(nameParts[1]).to.not.be.empty + }) + }) + }) + + cy.contains('th', 'E-mail').parent('tr').then(($headerRow) => { + const nameColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("E-mail")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(nameColumnIndex).invoke('text').then((email) => { + expect(email).to.include("@student.ukf.sk") + }) + }) + }) + + cy.contains('th', 'Telefón').parent('tr').then(($headerRow) => { + const phoneColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("Telefón")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(phoneColumnIndex).invoke('text').then((phone) => { + expect(phone.trim()).to.not.be.empty + }) + }) + }) + + cy.contains('th', 'Študijný program').parent('tr').then(($headerRow) => { + const programColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("Študijný program")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(programColumnIndex).invoke('text').then((program) => { + expect(program.trim()).to.not.be.empty + }) + }) + }) + + cy.contains('th', 'Osobný e-mail').parent('tr').then(($headerRow) => { + const personalEmailColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("Osobný e-mail")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(personalEmailColumnIndex).invoke('text').then((personalEmail) => { + expect(personalEmail.trim()).to.not.be.empty + expect(personalEmail.trim()).to.include("@") + }) + }) + }) + + cy.contains('th', 'Adresa').parent('tr').then(($headerRow) => { + const addressColumnIndex = $headerRow.find('th').index(cy.$$('th:contains("Adresa")')[0]) + + cy.get('tbody tr').each(($row) => { + cy.wrap($row).find('td').eq(addressColumnIndex).invoke('text').then((address) => { + expect(address.trim()).to.not.be.empty + }) + }) + }) + }) + }) + + it('should be able to delete a student', () => { + let initialRowCount = 0 + + cy.get('table tbody tr').its('length').then((count) => { + initialRowCount = count + }) + + cy.get('table tbody tr').first().within(() => { + cy.contains('Vymazať').click() + }) + + cy.contains("Potvrdiť vymazanie").parent().should('be.visible') + cy.contains("Potvrdiť vymazanie").parent().contains("Vymazať").click() + cy.contains("Potvrdiť vymazanie").should('not.exist') + + cy.get('table tbody tr').its('length').then((count) => { + expect(count).to.be.eq(initialRowCount - 1) + }) + }) +}) \ No newline at end of file diff --git a/frontend/e2e/home.cy.ts b/frontend/e2e/home.cy.ts new file mode 100644 index 0000000..96b62e8 --- /dev/null +++ b/frontend/e2e/home.cy.ts @@ -0,0 +1,17 @@ +describe('Home Page', () => { + it('should display the home page', () => { + cy.visit('/') + + cy.wait(1000) + + cy.contains("Domov") + cy.contains("Register") + cy.contains("Login") + + cy.contains("Informácie o odbornej praxi pre študentov") + cy.contains("Informácie o odbornej praxi pre firmy") + cy.contains("O aplikácii") + + cy.contains("(c) Fakulta prírodných vied a informatiky, UKF v Nitre") + }) +}) \ No newline at end of file diff --git a/frontend/e2e/info-pages.cy.ts b/frontend/e2e/info-pages.cy.ts new file mode 100644 index 0000000..2fffe7c --- /dev/null +++ b/frontend/e2e/info-pages.cy.ts @@ -0,0 +1,21 @@ +describe('Info Pages', () => { + it('should load the info page for students', () => { + cy.visit('/') + cy.contains("Informácie o odbornej praxi pre študentov").click() + cy.location('pathname').should('eq', '/info/student') + + cy.contains("Informácie o odbornej praxi pre študentov") + cy.contains("Podmienky absolvovania predmetu") + }) + + it('should load the info page for companies', () => { + cy.visit('/') + cy.contains("Informácie o odbornej praxi pre firmy").click() + cy.location('pathname').should('eq', '/info/company') + + cy.contains("Detaily a pravidlá odbornej praxe pre firmy") + cy.contains("Zmluvné podmienky") + cy.contains("Pravidlá a povinnost počas praxe") + cy.contains("Hodnotenie a ukončenie praxe") + }) +}) \ No newline at end of file diff --git a/frontend/e2e/login.cy.ts b/frontend/e2e/login.cy.ts new file mode 100644 index 0000000..8424ab4 --- /dev/null +++ b/frontend/e2e/login.cy.ts @@ -0,0 +1,24 @@ +describe('Log in as admin', () => { + it('should be able to log in as the default administrator', () => { + cy.visit('/login') + + cy.wait(1500) + + cy.contains("Prihlásenie") + cy.get('input[type="email"]').type('test@example.com') + cy.get('input[type="password"]').type('password') + cy.get('button[type="submit"]').click() + + cy.wait(1000) + + cy.contains("Vitajte") + cy.location('pathname').should('eq', '/dashboard/admin') + + cy.wait(1000) + + cy.contains("Logout").click() + cy.location('pathname').should('eq', '/') + + cy.wait(1000) + }) +}) \ No newline at end of file