diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml index 667f8683..0791cd1e 100644 --- a/.github/workflows/test-frontend.yml +++ b/.github/workflows/test-frontend.yml @@ -27,8 +27,8 @@ jobs: - run: npm ci - run: npm run build - - run: npm run start -- -p 4200 & + - run: node scripts/testsetup.js -p 4200 & echo $! > testenv.pid - run: wait-on tcp:4200 - run: npm link cypress diff --git a/cypress/integration/overview.spec.ts b/cypress/integration/overview.spec.ts new file mode 100644 index 00000000..3e050f53 --- /dev/null +++ b/cypress/integration/overview.spec.ts @@ -0,0 +1,38 @@ +context('Overview', () => { + beforeEach(() => { + cy.visit('http://127.0.0.1:4200/overview'); + cy.url().should('include', 'overview'); + cy.get('.application__loading-overlay').should('not.exist'); + }); + + it('Overview', () => { + cy.get('.application__view--auth-form').should('not.exist'); + cy.get('.application__content').should('be.visible'); + cy.get('.sidebar__actions').should('be.visible'); + cy.get('.view--torrent-list').should('be.visible'); + }); + + it('Switch theme', () => { + cy.get('.icon--theme-switch').should('be.visible'); + cy.get('.icon--theme-switch').parent().click(); + cy.screenshot('dark'); + cy.get('.icon--theme-switch').parent().click(); + cy.screenshot('light'); + }); + + it('Tooltip', () => { + cy.get('.icon--settings').should('be.visible'); + cy.get('.icon--settings').trigger('mouseover'); + cy.get('.tooltip__content').contains('Settings').should('exist'); + cy.get('.tooltip__content').contains('Settings').parent().should('have.class', 'is-open'); + cy.get('.icon--settings').trigger('mouseout'); + cy.get('.tooltip__content').contains('Settings').parent().should('not.have.class', 'is-open'); + + cy.get('.icon--add').should('be.visible'); + cy.get('.icon--add').trigger('mouseover'); + cy.get('.tooltip__content').contains('Add Torrent').should('exist'); + cy.get('.tooltip__content').contains('Add Torrent').parent().should('have.class', 'is-open'); + cy.get('.icon--add').trigger('mouseout'); + cy.get('.tooltip__content').contains('Add Torrent').parent().should('not.have.class', 'is-open'); + }); +}); diff --git a/cypress/integration/register.spec.ts b/cypress/integration/register.spec.ts index 1d99f2e3..ceb0d35d 100644 --- a/cypress/integration/register.spec.ts +++ b/cypress/integration/register.spec.ts @@ -1,3 +1,6 @@ +import {AuthAuthenticationResponse} from '../../shared/schema/api/auth'; +import {AccessLevel} from '../../shared/schema/constants/Auth'; + context('Register', () => { beforeEach(() => { cy.server(); @@ -109,6 +112,24 @@ context('Register', () => { cy.get('.input--text[name="qbt-username"]').type('admin'); cy.get('.input--text[name="qbt-password"]').type('adminadmin'); + cy.server(); + + const response: AuthAuthenticationResponse = { + success: true, + username: 'test', + level: AccessLevel.ADMINISTRATOR, + }; + + cy.route({ + method: 'POST', + url: 'http://127.0.0.1:4200/api/auth/register', + response, + status: 200, + }).as('register-request'); + cy.get('.button[type="submit"]').click(); + + cy.get('.application__view--auth-form').should('not.exist'); + cy.get('.application__content').should('be.visible'); }); });