2020-07-29 01:30:51 +05:30
|
|
|
import { UserResponse } from 'app/services/api/accounts';
|
|
|
|
|
2019-12-29 17:57:44 +05:30
|
|
|
import { openSectionByName, confirmWithPassword } from './utils';
|
|
|
|
|
2019-12-29 18:56:07 +05:30
|
|
|
describe('Profile — Change Username', () => {
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should change username', () => {
|
|
|
|
cy.server();
|
|
|
|
|
|
|
|
cy.login({ accounts: ['default'] }).then(({ accounts: [account] }) => {
|
|
|
|
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,
|
2020-07-29 01:30:51 +05:30
|
|
|
isDeleted: false,
|
2020-05-24 04:38:24 +05:30
|
|
|
passwordChangedAt: 1476075696,
|
|
|
|
hasMojangUsernameCollision: true,
|
|
|
|
shouldAcceptRules: false,
|
2020-07-29 01:30:51 +05:30
|
|
|
} as UserResponse,
|
2020-05-24 04:38:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
cy.route({
|
|
|
|
method: 'POST',
|
|
|
|
url: `/api/v1/accounts/${account.id}/username`,
|
|
|
|
}).as('username');
|
|
|
|
|
|
|
|
cy.visit('/');
|
|
|
|
|
|
|
|
openSectionByName('Nickname');
|
|
|
|
|
|
|
|
cy.location('pathname').should('eq', '/profile/change-username');
|
|
|
|
|
|
|
|
cy.get('[name=username]').type(`{selectall}${account.username}{enter}`);
|
|
|
|
|
|
|
|
// unmock accounts route
|
|
|
|
cy.route({
|
|
|
|
method: 'GET',
|
|
|
|
url: `/api/v1/accounts/${account.id}`,
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.wait('@username')
|
|
|
|
.its('requestBody')
|
|
|
|
.should(
|
|
|
|
'eq',
|
|
|
|
new URLSearchParams({
|
|
|
|
username: account.username,
|
|
|
|
password: '',
|
|
|
|
}).toString(),
|
|
|
|
);
|
|
|
|
|
|
|
|
confirmWithPassword(account.password);
|
|
|
|
|
|
|
|
cy.wait('@username')
|
|
|
|
.its('requestBody')
|
|
|
|
.should(
|
|
|
|
'eq',
|
|
|
|
new URLSearchParams({
|
|
|
|
username: account.username,
|
|
|
|
password: account.password,
|
|
|
|
}).toString(),
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.location('pathname').should('eq', '/');
|
|
|
|
cy.findAllByTestId('profile-item').should('contain', account.username);
|
|
|
|
cy.findByTestId('toolbar').contains(account.username).click();
|
|
|
|
cy.findByTestId('active-account').should('contain', account.username);
|
|
|
|
});
|
2019-12-29 17:27:44 +05:30
|
|
|
});
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
it('should go back to profile', () => {
|
|
|
|
cy.login({ accounts: ['default'] });
|
2019-12-29 17:27:44 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.visit('/profile/change-username');
|
2019-12-29 17:27:44 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('back-to-profile').click();
|
2019-12-29 17:27:44 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.location('pathname').should('eq', '/');
|
|
|
|
});
|
2019-12-29 17:27:44 +05:30
|
|
|
});
|