Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> Co-authored-by: dukegreene <duke@forem.com>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
describe('Mascot Section', () => {
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
|
|
cy.get('@user').then((user) => {
|
|
cy.loginUser(user);
|
|
});
|
|
});
|
|
|
|
describe('mascot image setting', () => {
|
|
it('rejects an invalid image URL', () => {
|
|
cy.get('@user').then(() => {
|
|
cy.visit('/admin/customization/config');
|
|
cy.findByTestId('mascotSectionForm').as('mascotSectionForm');
|
|
|
|
cy.get('@mascotSectionForm').findByText('Mascot').click();
|
|
cy.get('@mascotSectionForm')
|
|
.findByLabelText('Mascot Image URL')
|
|
.as('image');
|
|
cy.get('@image').clear();
|
|
cy.get('@image').type('notanimage');
|
|
|
|
cy.get('@mascotSectionForm').findByText('Update Settings').click();
|
|
|
|
cy.url().should('contains', '/admin/customization/config');
|
|
|
|
cy.findByTestId('snackbar').within(() => {
|
|
cy.findByRole('alert').should(
|
|
'have.text',
|
|
'Validation failed: Mascot image url is not a valid URL',
|
|
);
|
|
});
|
|
});
|
|
});
|
|
|
|
it('accepts a valid image URL', () => {
|
|
cy.get('@user').then(() => {
|
|
cy.visit('/admin/customization/config');
|
|
cy.findByTestId('mascotSectionForm').as('mascotSectionForm');
|
|
|
|
cy.get('@mascotSectionForm').findByText('Mascot').click();
|
|
cy.get('@mascotSectionForm')
|
|
.findByLabelText('Mascot Image URL')
|
|
.as('image');
|
|
cy.get('@image').clear();
|
|
cy.get('@image').type('https://example.com/image.png');
|
|
|
|
cy.get('@mascotSectionForm').findByText('Update Settings').click();
|
|
|
|
cy.url().should('contains', '/admin/customization/config');
|
|
|
|
cy.findByTestId('snackbar').within(() => {
|
|
cy.findByRole('alert').should(
|
|
'have.text',
|
|
'Successfully updated settings.',
|
|
);
|
|
});
|
|
|
|
// Page reloaded so need to get a new reference to the form.
|
|
cy.findByTestId('mascotSectionForm').as('mascotSectionForm');
|
|
cy.findByLabelText('Mascot Image URL').should(
|
|
'have.value',
|
|
'https://example.com/image.png',
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|