mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Cover delete/restore account forms with E2E tests
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { UserResponse } from 'app/services/api/accounts';
|
||||
|
||||
import { openSectionByName, confirmWithPassword } from './utils';
|
||||
|
||||
describe('Profile — Change Username', () => {
|
||||
@@ -18,10 +20,11 @@ describe('Profile — Change Username', () => {
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: false,
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
},
|
||||
} as UserResponse,
|
||||
});
|
||||
|
||||
cy.route({
|
||||
|
75
tests-e2e/cypress/integration/profile/delete-account.test.ts
Normal file
75
tests-e2e/cypress/integration/profile/delete-account.test.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { openSectionByName, confirmWithPassword } from './utils';
|
||||
import { UserResponse } from 'app/services/api/accounts';
|
||||
|
||||
describe('Profile — Delete account', () => {
|
||||
it('should delete account', () => {
|
||||
cy.login({ accounts: ['default'] }).then(({ accounts: [account] }) => {
|
||||
cy.server();
|
||||
cy.route({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
}).as('deleteAccount');
|
||||
cy.route({
|
||||
method: 'GET',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
});
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
openSectionByName('Account deletion');
|
||||
|
||||
cy.location('pathname').should('eq', '/profile/delete');
|
||||
|
||||
cy.get('[type=submit]').click();
|
||||
|
||||
cy.wait('@deleteAccount')
|
||||
.its('requestBody')
|
||||
.should(
|
||||
'eq',
|
||||
new URLSearchParams({
|
||||
password: '',
|
||||
}).toString(),
|
||||
);
|
||||
|
||||
cy.route({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
response: { success: true },
|
||||
}).as('deleteAccount');
|
||||
cy.route({
|
||||
method: 'GET',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
response: {
|
||||
id: 7,
|
||||
uuid: '522e8c19-89d8-4a6d-a2ec-72ebb58c2dbe',
|
||||
username: 'SleepWalker',
|
||||
isOtpEnabled: false,
|
||||
registeredAt: 1475568334,
|
||||
lang: 'en',
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: true, // mock deleted state since the delete will not perform the real request
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
} as UserResponse,
|
||||
});
|
||||
|
||||
confirmWithPassword(account.password);
|
||||
|
||||
cy.wait('@deleteAccount')
|
||||
.its('requestBody')
|
||||
.should(
|
||||
'eq',
|
||||
new URLSearchParams({
|
||||
password: account.password,
|
||||
}).toString(),
|
||||
);
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.findByTestId('deletedAccount').should('contain', 'Account is deleted');
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,3 +1,5 @@
|
||||
import { UserResponse } from 'app/services/api/accounts';
|
||||
|
||||
import { openSectionByName, getSectionByName, confirmWithPassword } from './utils';
|
||||
|
||||
describe('Profile — mfa', () => {
|
||||
@@ -63,10 +65,11 @@ describe('Profile — mfa', () => {
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: false,
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
},
|
||||
} as UserResponse,
|
||||
});
|
||||
|
||||
confirmWithPassword(account.password);
|
||||
@@ -104,10 +107,11 @@ describe('Profile — mfa', () => {
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: false,
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
},
|
||||
} as UserResponse,
|
||||
});
|
||||
cy.route({
|
||||
method: 'DELETE',
|
||||
|
@@ -0,0 +1,63 @@
|
||||
import { UserResponse } from 'app/services/api/accounts';
|
||||
|
||||
describe('Profile — Restore account', () => {
|
||||
it('should restore account', () => {
|
||||
cy.login({ accounts: ['default'] }).then(({ accounts: [account] }) => {
|
||||
cy.server();
|
||||
cy.route({
|
||||
method: 'GET',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
response: {
|
||||
id: 7,
|
||||
uuid: '522e8c19-89d8-4a6d-a2ec-72ebb58c2dbe',
|
||||
username: 'FooBar',
|
||||
isOtpEnabled: false,
|
||||
registeredAt: 1475568334,
|
||||
lang: 'en',
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: true, // force deleted state
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
} as UserResponse,
|
||||
});
|
||||
cy.route({
|
||||
method: 'POST',
|
||||
url: `/api/v1/accounts/${account.id}/restore`,
|
||||
response: { success: true },
|
||||
}).as('restoreAccount');
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.route({
|
||||
method: 'GET',
|
||||
url: `/api/v1/accounts/${account.id}`,
|
||||
response: {
|
||||
id: 7,
|
||||
uuid: '522e8c19-89d8-4a6d-a2ec-72ebb58c2dbe',
|
||||
username: 'SleepWalker',
|
||||
isOtpEnabled: false,
|
||||
registeredAt: 1475568334,
|
||||
lang: 'en',
|
||||
elyProfileLink: 'http://ely.by/u7',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
isActive: true,
|
||||
isDeleted: false, // force deleted state
|
||||
passwordChangedAt: 1476075696,
|
||||
hasMojangUsernameCollision: true,
|
||||
shouldAcceptRules: false,
|
||||
} as UserResponse,
|
||||
});
|
||||
|
||||
cy.findByTestId('deletedAccount').contains('Restore account').click();
|
||||
|
||||
cy.wait('@restoreAccount');
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.findByTestId('profile-index').should('contain', account.username);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user