client: use testsetup for frontend tests

This commit is contained in:
Jesse Chan
2020-12-02 22:34:50 +08:00
parent b80b2e6477
commit 0bbc48fd89
3 changed files with 60 additions and 1 deletions
+1 -1
View File
@@ -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
+38
View File
@@ -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');
});
});
+21
View File
@@ -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');
});
});