From 75c1b02760195c7c6054945a4120260bd080cdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 2 Jul 2020 17:38:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=EF=B8=8F=20e2e:=20Add=20c?= =?UTF-8?q?onnection=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/fixtures/with_acl/config.yaml | 2 ++ tests/cypress/integration/connect.js | 46 +++++++++++++++++++++++++++ tests/cypress/integration/login.js | 8 ++--- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tests/cypress/integration/connect.js diff --git a/.github/fixtures/with_acl/config.yaml b/.github/fixtures/with_acl/config.yaml index 1b8a97f98..76cd71aad 100644 --- a/.github/fixtures/with_acl/config.yaml +++ b/.github/fixtures/with_acl/config.yaml @@ -1,6 +1,8 @@ accessControl: salt: zXmvzI3uWuTLkSPOEfA2ZLwn3f3sGUNS plugins: + virtual_printer: + enabled: true tracking: enabled: false server: diff --git a/tests/cypress/integration/connect.js b/tests/cypress/integration/connect.js new file mode 100644 index 000000000..264c1f988 --- /dev/null +++ b/tests/cypress/integration/connect.js @@ -0,0 +1,46 @@ +describe('Connection test against virtual printer', () => { + const username = 'admin'; + const password = 'test'; + + beforeEach(() => { + cy.request({ + method: 'POST', + url: '/api/login', + body: { + "user": username, + "pass": password + } + }); + + cy.visit('/'); + + cy.get('#navbar', {timeout: 10000}) + .should('be.visible'); + }); + + it('connects', () => { + cy.get('#state .accordion-inner strong:first') + .should('contain', 'Offline'); + + cy.get('#connection_ports') + .select('VIRTUAL'); + cy.get('#printer_connect') + .click(); + + cy.get('#state .accordion-inner strong:first') + .should('contain', 'Operational'); + }); + + it('disconnects', () => { + cy.get('#state .accordion-inner strong:first') + .should('contain', 'Operational'); + + cy.get('#connection_wrapper a.accordion-toggle') + .click(); + cy.get('#printer_connect') + .click(); + + cy.get('#state .accordion-inner strong:first') + .should('contain', 'Offline'); + }); +}); diff --git a/tests/cypress/integration/login.js b/tests/cypress/integration/login.js index b79bd9d0e..3b4abf17a 100644 --- a/tests/cypress/integration/login.js +++ b/tests/cypress/integration/login.js @@ -13,9 +13,7 @@ describe('Login tests', () => { cy.get('#login-button') .click(); - cy.wait(5000); // wait 5s for the page load before continuing - - cy.get('#navbar') + cy.get('#navbar', {timeout: 10000}) .should('be.visible'); cy.get('#navbar_login a.dropdown-toggle span') .should('contain', username); @@ -39,7 +37,7 @@ describe('Login tests', () => { cy.get('#login-button') .click(); - cy.get('#navbar') + cy.get('#navbar', {timeout: 10000}) .should('be.visible'); cy.get('#navbar_login a.dropdown-toggle span') .should('contain', username); @@ -64,7 +62,7 @@ describe('Login tests', () => { cy.get('#login-button') .click(); - cy.get('#navbar') + cy.get('#navbar', {timeout: 10000}) .should('be.visible'); cy.get('#navbar_login a.dropdown-toggle')