File size: 2,477 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import data from '../../shared/testing/data';

const community = data.communities[0];
const { userId: ownerId } = data.usersCommunities.find(
  ({ communityId, isOwner }) => communityId === community.id && isOwner
);
const channels = data.channels
  .filter(({ communityId }) => community.id === communityId)
  .filter(c => !c.deletedAt);

describe('Community settings overview tab', () => {
  beforeEach(() => {
    cy.auth(ownerId).then(() => cy.visit(`/${community.slug}/settings`));
  });

  it('should render the settings overview and allow editing the community metadata', () => {
    cy.get('[data-cy="community-settings"]').should('be.visible');
    cy.contains('Channels');
    // Make sure all channels are listed and link to their settings
    channels.forEach(channel => {
      cy.contains(channel.name);
      cy.get(`[href*="${community.slug}/${channel.slug}/settings"]`);
    });
    // Make sure the subnav is rendered correctly
    cy.get(`[href*="settings/members"]`).should('be.visible');

    // Editing
    const name = 'text';
    const description = 'text';
    // Change name
    cy.get('[data-cy="community-settings-name-input"]')
      .clear()
      .type(`${name}`);
    // Change description
    cy.get('[data-cy="community-settings-description-input"]')
      .clear()
      .type(description);
    const website = 'https://mxstbr.com/bla';
    // Change website
    cy.get('[data-cy="community-settings-website-input"]')
      .clear()
      .type(website);
    // Submit changes
    cy.get('[data-cy="community-settings-edit-save-button"]').click();
    cy.visit(`/${community.slug}`);
    cy.location('pathname').should('eq', `/${community.slug}`);
    // Make sure changes were applied
    cy.contains(description);
    cy.contains(name);
    cy.contains(website);
    // Revert changes
    cy.visit(`/${community.slug}/settings`);
    cy.get('[data-cy="community-settings-name-input"]')
      .clear()
      .type(community.name);
    cy.get('[data-cy="community-settings-description-input"]')
      .clear()
      .type(community.description);
    cy.get('[data-cy="community-settings-website-input"]')
      .clear()
      .type(community.website);
    cy.get('[data-cy="community-settings-edit-save-button"]').click();
    cy.visit(`/${community.slug}`);
    cy.location('pathname').should('eq', `/${community.slug}`);
    cy.contains(community.name);
    cy.contains(community.description);
    cy.contains(community.website);
  });
});