fix(client): add validation to profile image URL (#41927)

* fix: fix broken image url after validation

* feat: add tests for a broken image url submission

* fix: reduce event related calls

* Update cypress/integration/settings/image-picture-check.js

Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>

* Update cypress/integration/settings/image-picture-check.js

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
Co-authored-by: Sem Bauke <46919888+Sembauke@users.noreply.github.com>
This commit is contained in:
Ismail Tlemcani
2021-05-23 15:08:12 +01:00
committed by GitHub
parent 3b2be48dea
commit 914ff44f74
2 changed files with 86 additions and 9 deletions

View File

@ -0,0 +1,39 @@
/* global cy */
describe('Picture input field', () => {
beforeEach(() => {
cy.login();
cy.visit('/settings');
// Setting aliases here
cy.get('input#about-picture').as('pictureInput');
});
it('Should be possible to type', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type('twaha', { force: true })
.should('have.attr', 'value', 'twaha');
});
it('Show an error message if an incorrect url was submitted', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type('https://s3.amazonaws.com/freecodecamp/camper-image', {
force: true
})
.then(() => {
cy.contains('URL must link directly to an image file');
});
});
it('Can submit a correct URL', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type(
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png',
{
force: true
}
);
cy.wait(500);
cy.get('#camper-identity > .btn').should('not.be.disabled');
});
});