File size: 1,481 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
47
48
49
50
51
52
53
import data from '../../../../shared/testing/data';

const channel = data.channels[0];
const privateChannel = data.channels[1];

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

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

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

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

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

  it('should not allow general channel to be deleted', () => {
    cy.get('[data-cy="channel-overview"]').should('be.visible');

    cy.get('[data-cy="delete-channel-button"]').should('not.be.visible');
  });
});

describe('deleting a channel', () => {
  beforeEach(() => {
    cy.auth(ownerInPrivateChannelId).then(() =>
      cy.visit(`/${privateCommunity.slug}/${privateChannel.slug}/settings`)
    );
  });

  it('should delete a channel', () => {
    cy.get('[data-cy="channel-overview"]').should('be.visible');

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

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