From c68ee3cf9d8faa60a78f8f1e3a61bad992fb4f08 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 May 2024 17:29:43 +0200 Subject: [PATCH] Test di integrazione homepage --- frontend/README.md | 5 ++ frontend/cypress.json | 3 +- frontend/src/components/InputFile.vue | 4 +- frontend/src/views/HomePage.vue | 79 ++++++++++++------------ frontend/tests/e2e/specs/int_homepage.js | 34 ++++++++++ frontend/tests/e2e/specs/test.js | 8 --- 6 files changed, 82 insertions(+), 51 deletions(-) create mode 100644 frontend/tests/e2e/specs/int_homepage.js delete mode 100644 frontend/tests/e2e/specs/test.js diff --git a/frontend/README.md b/frontend/README.md index 2367eaf..a05772e 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -42,3 +42,8 @@ npx jest ``` npx jest --coverage ``` + +## Cypress +``` +npx cypress open +``` \ No newline at end of file diff --git a/frontend/cypress.json b/frontend/cypress.json index 470c720..acac844 100644 --- a/frontend/cypress.json +++ b/frontend/cypress.json @@ -1,3 +1,4 @@ { + "baseUrl": "http://localhost:8080", "pluginsFile": "tests/e2e/plugins/index.js" -} +} \ No newline at end of file diff --git a/frontend/src/components/InputFile.vue b/frontend/src/components/InputFile.vue index b095c70..8f55421 100644 --- a/frontend/src/components/InputFile.vue +++ b/frontend/src/components/InputFile.vue @@ -1,8 +1,8 @@ diff --git a/frontend/src/views/HomePage.vue b/frontend/src/views/HomePage.vue index d807157..c51703f 100644 --- a/frontend/src/views/HomePage.vue +++ b/frontend/src/views/HomePage.vue @@ -1,48 +1,47 @@ - - - \ No newline at end of file + + \ No newline at end of file diff --git a/frontend/tests/e2e/specs/int_homepage.js b/frontend/tests/e2e/specs/int_homepage.js new file mode 100644 index 0000000..f44811a --- /dev/null +++ b/frontend/tests/e2e/specs/int_homepage.js @@ -0,0 +1,34 @@ +describe('HomePage', () => { + beforeEach(() => { + cy.visit('/'); + }); + + it('renders the Gestione dizionario dati card', () => { + cy.get('[data-cy=gestione-dizionario]').should('exist'); + }); + + it('displays the correct title and description for Gestione dizionario dati', () => { + cy.get('[data-cy=gestione-dizionario] .card-title').should('have.text', 'Gestione dizionario dati'); + cy.get('[data-cy=gestione-dizionario] .card-text').should('contain', 'visualizzare e gestire i dizionari dati'); + }); + + it('renders the ChatSQL card', () => { + cy.get('[data-cy=chatsql]').should('exist'); + }); + + it('displays the correct title and description for ChatSQL', () => { + cy.get('[data-cy=chatsql] .card-title').should('have.text', 'ChatSQL'); + cy.get('[data-cy=chatsql] .card-text').should('contain', 'fare una richiesta in linguaggio naturale'); + }); + + + it('navigates to the Request page when ChatSQL button is clicked', () => { + cy.get('[data-cy=chatsql-button]').click(); + cy.url().should('include', '/request'); + }); + + it('navigates to the Manager page when Gestione dizionario dati button is clicked', () => { + cy.get('[data-cy=gestione-dizionario-button]').click(); + cy.url().should('include', '/manager'); + }); +}); diff --git a/frontend/tests/e2e/specs/test.js b/frontend/tests/e2e/specs/test.js deleted file mode 100644 index 155e302..0000000 --- a/frontend/tests/e2e/specs/test.js +++ /dev/null @@ -1,8 +0,0 @@ -// https://docs.cypress.io/api/table-of-contents - -describe('My First Test', () => { - it('Visits the app root url', () => { - cy.visit('/') - cy.contains('h1', 'Welcome to Your Vue.js App') - }) -})