E2e tests for activation and password reset pages with keys in url

This commit is contained in:
SleepWalker 2019-12-29 15:33:48 +02:00
parent 8af40aed47
commit 73d2baeb3a
2 changed files with 69 additions and 0 deletions

View File

@ -218,4 +218,45 @@ describe('Forgot / reset password', () => {
}).toString(),
);
});
it('should read key from an url', () => {
const key = 'key';
const newPassword = 'newPassword';
cy.server();
cy.login({
accounts: ['default'],
updateState: false,
rawApiResp: true,
}).then(({ accounts: [account] }) => {
cy.route({
method: 'POST',
url: '/api/authentication/recover-password',
response: account,
}).as('recover');
});
cy.visit('/');
cy.visit(`/recover-password/${key}`);
cy.get('[name=key]').should('have.value', key);
cy.get('[name=key]').should('have.attr', 'readonly');
cy.get('[name=newPassword]').type(newPassword);
cy.get('[name=newRePassword]').type(newPassword);
cy.get('[type=submit]')
.should('have.length', 1)
.click();
cy.wait('@recover')
.its('requestBody')
.should(
'eq',
new URLSearchParams({
key,
newPassword,
newRePassword: newPassword,
}).toString(),
);
});
});

View File

@ -108,6 +108,34 @@ describe('Register', () => {
cy.location('pathname').should('eq', '/');
});
it('should read activation key from url', () => {
const activationKey = 'activationKey';
cy.server();
cy.login({
accounts: ['default'],
updateState: false,
rawApiResp: true,
}).then(({ accounts: [account] }) => {
cy.route({
method: 'POST',
url: '/api/signup/confirm',
response: account,
}).as('activate');
});
cy.visit(`/activation/${activationKey}`);
cy.get('[name=key]').should('have.value', activationKey);
cy.get('[name=key]').should('have.attr', 'readonly');
cy.get('[type=submit]').click();
cy.wait('@activate')
.its('requestBody')
.should('eq', `key=${activationKey}`);
cy.location('pathname').should('eq', '/');
});
it('should allow resend code', () => {
const email = `${Date.now()}@gmail.com`;
const captchaCode = 'captchaCode';