client: initial integration tests

This commit is contained in:
Jesse Chan
2020-10-18 21:50:49 +08:00
parent ae536b4b75
commit f0daebbf41
15 changed files with 1396 additions and 189 deletions

View File

@@ -0,0 +1,83 @@
context('Register', () => {
beforeEach(() => {
cy.visit('http://127.0.0.1:4200/register');
cy.url().should('include', 'register');
});
it('Client selection menu', () => {
cy.get('.select').click();
cy.get('.context-menu').should('be.visible');
cy.get('.select__item').contains('rTorrent').click();
cy.get('.context-menu').should('not.be.visible');
cy.get('.input[name="client"]').should('have.value', 'rTorrent');
});
it('Connection type selection', () => {
cy.get('.toggle-input__label').contains('TCP').click();
cy.get('.toggle-input__element[value="tcp"]').should('be.checked');
cy.get('.toggle-input__element[value="socket"]').should('not.be.checked');
cy.get('.input--text[name="host"]').should('be.visible');
cy.get('.input--text[name="port"]').should('be.visible');
cy.get('.input--text[name="socket"]').should('not.be.visible');
cy.get('.toggle-input__label').contains('Socket').click();
cy.get('.toggle-input__element[value="tcp"]').should('not.be.checked');
cy.get('.toggle-input__element[value="socket"]').should('be.checked');
cy.get('.input--text[name="host"]').should('not.be.visible');
cy.get('.input--text[name="port"]').should('not.be.visible');
cy.get('.input--text[name="socket"]').should('be.visible');
});
it('Register without username', () => {
cy.get('.input[name="password"]').type('test');
cy.get('.select').click();
cy.get('.select__item').contains('rTorrent').click();
cy.get('.toggle-input__label').contains('Socket').click();
cy.get('.input--text[name="socket"]').type('/data/rtorrent.sock');
cy.get('.button[type="submit"]').click();
cy.get('.application__view--auth-form').should('be.visible');
cy.get('.application__content').should('not.be.visible');
cy.get('.application__loading-overlay').should('not.be.visible');
});
it('Register without password', () => {
cy.get('.input[name="username"]').type('test');
cy.get('.select').click();
cy.get('.select__item').contains('rTorrent').click();
cy.get('.toggle-input__label').contains('TCP').click();
cy.get('.input--text[name="host"]').type('127.0.0.1');
cy.get('.input--text[name="port"]').type('5000');
cy.get('.button[type="submit"]').click();
cy.get('.application__view--auth-form').should('be.visible');
cy.get('.application__content').should('not.be.visible');
cy.get('.application__loading-overlay').should('not.be.visible');
});
it('Register without connection settings', () => {
cy.get('.input[name="username"]').type('test');
cy.get('.input[name="password"]').type('test');
cy.get('.button[type="submit"]').click();
cy.get('.application__view--auth-form').should('be.visible');
cy.get('.application__content').should('not.be.visible');
cy.get('.application__loading-overlay').should('not.be.visible');
});
it('Register with socket connection settings', () => {
cy.get('.input[name="username"]').type('test');
cy.get('.input[name="password"]').type('test');
cy.get('.select').click();
cy.get('.select__item').contains('rTorrent').click();
cy.get('.toggle-input__label').contains('Socket').click();
cy.get('.input--text[name="socket"]').type('/data/rtorrent.sock');
cy.server();
cy.route({method: 'POST', url: 'http://127.0.0.1:4200/api/auth/register', response: {}, status: 403}).as(
'register-request',
);
cy.get('.button[type="submit"]').click();
cy.get('.application__view--auth-form').should('not.be.visible');
cy.get('.application__content').should('be.visible');
});
});

21
cypress/plugins/index.js Normal file
View File

@@ -0,0 +1,21 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

View File

@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

20
cypress/support/index.js Normal file
View File

@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')

9
cypress/tsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": ["**/*.ts"],
"resolveJsonModule": true
}