hubl/cypress/integration/edit-channel.spec.js
2021-01-22 14:21:25 +01:00

66 lines
2.5 KiB
JavaScript

/// <reference types="Cypress" />
/* globals cy, expect */
context('Edit Channel Browser Testing', () => {
let channelName = 'Edited Test Channel ',
description = 'Edited Test Description ',
menuQuery = [
'solid-display.circle-tab',
'solid-display:last-child',
'solid-display[order-by="name"]'
];
before(() => {
cy.randomNum().then(num => {
channelName += num;
description += num;
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('Channel Edition process', () => {
it('should visit the channel list screen', () => {
cy.visit('/admin-circles');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/admin-circles');
});
});
it('should visit the last channel edit screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.visit('/circle/@' + id + '/circle-information/circle-edit');
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information/circle-edit');
});
}));
});
it('should enter new channel data', () => {
cy.get('#circle-edit input[name="name"]').clear().type(channelName);
cy.get('#circle-edit input[name="name"]').should('have.value', channelName);
cy.get('#circle-edit input[name="description"]').clear().type(description);
cy.get('#circle-edit input[name="description"]').should('have.value', description);
});
it('should click button to save the channel', () => {
cy.get('#circle-edit input[value="Enregistrer"]').click();
});
it('should land on channel information screen', () => {
cy.get(menuQuery.join(' '))
.invoke('attr', 'data-src')
.then(url => cy.encodeUrl(url).then(id => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/circle/@' + id + '/circle-information');
});
}));
});
it('should show edited channel data on channel information screen', () => {
cy.contains('solid-display-value[name="name"]', channelName).should("exist");
cy.contains('solid-display-value[name="description"]', description).should("exist");
});
});
});