File size: 1,176 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import data from '../../../../shared/testing/data';

const channel = data.channels[0];

const community = data.communities.find(
  community => community.id === channel.communityId
);

const { userId: ownerInChannelId } = data.usersChannels.find(
  ({ channelId, isOwner }) => channelId === channel.id && isOwner
);

const NEW_NAME = 'General Update';
const NEW_DESCRIPTION = 'New description';

describe('edit a channel', () => {
  beforeEach(() => {
    cy.auth(ownerInChannelId).then(() =>
      cy.visit(`/${community.slug}/${channel.slug}/settings`)
    );
  });

  it('should edit a channel', () => {
    cy.get('[data-cy="channel-overview"]').should('be.visible');
    cy.get('[data-cy="channel-members"]').should('be.visible');
    cy.get('[data-cy="channel-name-input"]')
      .should('be.visible')
      .click()
      .clear()
      .type(NEW_NAME);

    cy.get('[data-cy="channel-description-input"]')
      .should('be.visible')
      .click()
      .clear()
      .type(NEW_DESCRIPTION);

    cy.get('[data-cy="save-button"]')
      .should('be.visible')
      .click();

    cy.visit(`/${community.slug}/${channel.slug}`);
    cy.contains(NEW_NAME);
  });
});