2020-11-22 00:09:38 +06:00
|
|
|
describe('Username input field', () => {
|
|
|
|
beforeEach(() => {
|
2021-06-24 12:50:36 +03:00
|
|
|
cy.login();
|
2021-12-11 10:04:16 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
function goToSettings() {
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.visit('/settings');
|
|
|
|
|
|
|
|
// Setting aliases here
|
|
|
|
cy.get('input[name=username-settings]').as('usernameInput');
|
|
|
|
cy.get('form#usernameSettings').as('usernameForm');
|
2021-12-11 10:04:16 +01:00
|
|
|
}
|
2020-11-22 00:09:38 +06:00
|
|
|
|
|
|
|
it('Should be possible to type', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('twaha', { force: true })
|
|
|
|
.should('have.attr', 'value', 'twaha');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should show message when validating name', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('twaha', { force: true });
|
|
|
|
|
|
|
|
cy.contains('Validating username...')
|
|
|
|
.should('have.attr', 'role', 'alert')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should('have.class', 'alert alert-info');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should show username is available if it is', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('brad', { force: true });
|
|
|
|
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available')
|
2020-11-22 00:09:38 +06:00
|
|
|
.should('be.visible')
|
|
|
|
.should('have.attr', 'role', 'alert')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should('have.class', 'alert alert-success');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should info message if username is available', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('mrugesh', { force: true });
|
|
|
|
|
|
|
|
cy.contains(
|
|
|
|
'Please note, changing your username will also change ' +
|
|
|
|
'the URL to your profile and your certifications.'
|
|
|
|
)
|
|
|
|
.should('be.visible')
|
|
|
|
.should('have.attr', 'role', 'alert')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should('have.class', 'alert alert-info');
|
|
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line
|
|
|
|
it('Should be able to click the `Save` button if username is avalable', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('oliver', { force: true });
|
|
|
|
|
|
|
|
cy.get('@usernameForm').within(() => {
|
|
|
|
cy.contains('Save').should('not.be.disabled');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should show username is unavailable if it is', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('twaha', { force: true });
|
|
|
|
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username not available')
|
2020-11-22 00:09:38 +06:00
|
|
|
.should('be.visible')
|
|
|
|
.should('have.attr', 'role', 'alert')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should('have.class', 'alert alert-warning');
|
|
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line
|
|
|
|
it('Should not be possible to click the `Save` button if username is unavailable', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('twaha', { force: true });
|
|
|
|
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available').should('not.exist');
|
|
|
|
cy.contains('Username not available').should('not.exist');
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.contains(
|
|
|
|
'Please note, changing your username will also change ' +
|
|
|
|
'the URL to your profile and your certifications.'
|
2020-12-07 16:02:52 +06:00
|
|
|
).should('not.exist');
|
2020-11-22 00:09:38 +06:00
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
cy.get('@usernameForm').contains('Save').should('be.disabled');
|
2020-11-22 00:09:38 +06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should not show anything if user types their current name', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('developmentuser', { force: true });
|
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
cy.get('@usernameForm').contains('Save').should('be.disabled');
|
2020-11-22 00:09:38 +06:00
|
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
it('Should not be possible to click the `Save` button if user types their current name', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('developmentuser', { force: true });
|
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
cy.get('@usernameForm').contains('Save').should('be.disabled');
|
2020-11-22 00:09:38 +06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should show warning if username includes invalid character', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('Quincy Larson', { force: true });
|
|
|
|
|
2021-05-20 02:04:00 -05:00
|
|
|
cy.contains('Username "Quincy Larson" contains invalid characters')
|
2020-11-22 00:09:38 +06:00
|
|
|
.should('be.visible')
|
|
|
|
.should('have.attr', 'role', 'alert')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should('have.class', 'alert alert-danger');
|
|
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
it('Should not be able to click the `Save` button if username includes invalid character', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('Quincy Larson', { force: true });
|
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
cy.get('@usernameForm').contains('Save').should('be.disabled');
|
2020-11-22 00:09:38 +06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should change username if `Save` button is clicked', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('quincy', { force: true });
|
|
|
|
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available');
|
2020-11-22 00:09:38 +06:00
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
cy.get('@usernameForm').contains('Save').click({ force: true });
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.contains('Account Settings for quincy').should('be.visible');
|
|
|
|
|
|
|
|
cy.resetUsername();
|
|
|
|
});
|
|
|
|
|
2021-11-04 11:18:40 +01:00
|
|
|
it('Should change username with uppercase characters if `Save` button is clicked', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2021-11-04 11:18:40 +01:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('Quincy', { force: true });
|
|
|
|
|
|
|
|
cy.contains('Username is available');
|
|
|
|
|
|
|
|
cy.get('@usernameForm').contains('Save').click({ force: true });
|
|
|
|
cy.contains('Account Settings for Quincy').should('be.visible');
|
|
|
|
|
|
|
|
cy.resetUsername();
|
|
|
|
});
|
|
|
|
|
2020-11-22 00:09:38 +06:00
|
|
|
it('Should show flash message showing username has been updated', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('nhcarrigan', { force: true });
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available');
|
2022-04-01 00:07:01 -05:00
|
|
|
|
|
|
|
// temporary fix until https://github.com/cypress-io/cypress/issues/20562 is fixed
|
|
|
|
cy.contains(`Save`).click();
|
|
|
|
|
|
|
|
// revert to this when it is
|
|
|
|
// cy.get('@usernameInput').type('{enter}', { force: true, release: false });
|
2020-11-22 00:09:38 +06:00
|
|
|
|
|
|
|
cy.contains('We have updated your username to nhcarrigan')
|
|
|
|
.should('be.visible')
|
|
|
|
// We are checking for classes here to check for proper styling
|
|
|
|
// This will be replaced with Percy in the future
|
|
|
|
.should(
|
|
|
|
'have.class',
|
|
|
|
'flash-message alert alert-success alert-dismissable'
|
|
|
|
);
|
|
|
|
|
|
|
|
cy.resetUsername();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should be able to close the shown flash message', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('bjorno', { force: true });
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available');
|
2022-04-01 00:07:01 -05:00
|
|
|
|
|
|
|
// temporary fix until https://github.com/cypress-io/cypress/issues/20562 is fixed
|
|
|
|
cy.contains(`Save`).click();
|
|
|
|
|
|
|
|
// revert to this when it is
|
|
|
|
// cy.get('@usernameInput').type('{enter}', { force: true, release: false });
|
2020-11-22 00:09:38 +06:00
|
|
|
|
|
|
|
cy.contains('We have updated your username to bjorno').within(() => {
|
|
|
|
cy.get('button').click();
|
|
|
|
});
|
|
|
|
|
2020-12-07 16:02:52 +06:00
|
|
|
cy.contains('We have updated your username to bjorno').should('not.exist');
|
2020-11-22 00:09:38 +06:00
|
|
|
|
|
|
|
cy.resetUsername();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should change username if enter is pressed', () => {
|
2021-12-11 10:04:16 +01:00
|
|
|
goToSettings();
|
2020-11-22 00:09:38 +06:00
|
|
|
cy.get('@usernameInput')
|
|
|
|
.clear({ force: true })
|
|
|
|
.type('symbol', { force: true });
|
2020-12-16 02:02:52 -06:00
|
|
|
cy.contains('Username is available');
|
2020-11-22 00:09:38 +06:00
|
|
|
|
2022-04-01 00:07:01 -05:00
|
|
|
// temporary fix until https://github.com/cypress-io/cypress/issues/20562 is fixed
|
|
|
|
cy.contains(`Save`).click();
|
|
|
|
|
|
|
|
// revert to this when it is
|
|
|
|
// cy.get('@usernameInput').type('{enter}', { force: true, release: false });
|
2020-11-22 00:09:38 +06:00
|
|
|
|
|
|
|
cy.contains('Account Settings for symbol').should('be.visible');
|
|
|
|
|
|
|
|
cy.resetUsername();
|
|
|
|
});
|
|
|
|
});
|