2021-11-08 14:15:37 +00:00
|
|
|
import { Chance } from 'chance';
|
|
|
|
const chance = new Chance();
|
|
|
|
|
2021-11-09 13:21:41 +00:00
|
|
|
const url = `${Cypress.env('URL')}:${Cypress.env('PORT')}`;
|
2021-11-08 14:15:37 +00:00
|
|
|
let token: string;
|
|
|
|
|
|
|
|
Cypress.Commands.add('register', (email = chance.email(), password = chance.string()) => {
|
|
|
|
cy.visit(url);
|
|
|
|
cy.get('a[href*="/login"]').first().click();
|
|
|
|
cy.contains('Register').click();
|
|
|
|
cy.get('input[name=email]').type(email);
|
|
|
|
cy.get('input[name=username]').type(chance.name());
|
|
|
|
cy.get('input[name=password]').type(password);
|
|
|
|
cy.contains('Register').click();
|
|
|
|
cy.wait(2000);
|
|
|
|
|
|
|
|
cy.url()
|
|
|
|
.should('equal', `${url}/channels/@me`)
|
|
|
|
.then(() => token = localStorage.getItem('token')!);
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add('createGuild', () => {
|
|
|
|
cy.visit(url + '/channels/@me');
|
|
|
|
cy.get('#createGuildButton').click();
|
|
|
|
cy.get('input[name=name]').type(chance.tv());
|
|
|
|
cy.get('button').contains('Create').click();
|
|
|
|
cy.wait(1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
Cypress.Commands.add('logout', () => cy.visit(url + '/logout'));
|
|
|
|
|
|
|
|
|
|
|
|
export {}
|