"Fossies" - the Fresh Open Source Software Archive

Member "Rocket.Chat-4.7.1/apps/meteor/tests/e2e/09-channel.spec.ts" (13 May 2022, 10735 Bytes) of package /linux/www/Rocket.Chat-4.7.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import { test, expect } from '@playwright/test';
    2 
    3 import FlexTab from './utils/pageobjects/FlexTab';
    4 import MainContent from './utils/pageobjects/MainContent';
    5 import SideNav from './utils/pageobjects/SideNav';
    6 import LoginPage from './utils/pageobjects/LoginPage';
    7 import Global from './utils/pageobjects/Global';
    8 import { adminLogin } from './utils/mocks/userAndPasswordMock';
    9 import { LOCALHOST } from './utils/mocks/urlMock';
   10 import { publicChannelCreated, setPublicChannelCreated } from './utils/mocks/checks';
   11 import { publicChannelName } from './utils/mocks/channel';
   12 import { targetUser } from './utils/mocks/interations';
   13 
   14 let hasUserAddedInChannel = false;
   15 
   16 test.describe.serial('[Channel]', () => {
   17     let flexTab: FlexTab;
   18     let loginPage: LoginPage;
   19     let mainContent: MainContent;
   20     let sideNav: SideNav;
   21     let global: Global;
   22 
   23     test.beforeAll(async ({ browser, baseURL }) => {
   24         const context = await browser.newContext();
   25         const page = await context.newPage();
   26         const URL = baseURL || LOCALHOST;
   27         loginPage = new LoginPage(page);
   28         await loginPage.goto(URL);
   29 
   30         await loginPage.login(adminLogin);
   31         sideNav = new SideNav(page);
   32         mainContent = new MainContent(page);
   33         flexTab = new FlexTab(page);
   34         global = new Global(page);
   35 
   36         if (!publicChannelCreated) {
   37             await sideNav.createChannel(publicChannelName, false);
   38             await setPublicChannelCreated(true);
   39             console.log('public channel not found, creating one...');
   40         }
   41         await sideNav.openChannel('general');
   42     });
   43     test.describe('[Search]', () => {
   44         test.describe('[SpotlightSearch]', async () => {
   45             test.describe('general:', () => {
   46                 test('expect search general', async () => {
   47                     await sideNav.spotlightSearchIcon().click();
   48                     await sideNav.searchChannel('general');
   49                 });
   50 
   51                 test('expect go to general', async () => {
   52                     await sideNav.openChannel('general');
   53                     await expect(mainContent.channelTitle('general')).toContainText('general');
   54                 });
   55             });
   56 
   57             test.describe('user created channel:', () => {
   58                 test('expect search the user created channel', async () => {
   59                     await sideNav.spotlightSearchIcon().click();
   60                     await sideNav.searchChannel(publicChannelName);
   61                 });
   62 
   63                 test('expect go to the user created channel', async () => {
   64                     await sideNav.openChannel(publicChannelName);
   65                     await expect(mainContent.channelTitle(publicChannelName)).toContainText(publicChannelName);
   66                 });
   67             });
   68         });
   69 
   70         test.describe('[SideNav Channel List]', () => {
   71             test.beforeAll(async () => {
   72                 await mainContent.messageInput().click();
   73             });
   74 
   75             test.describe('general:', async () => {
   76                 test('expect show the general in the channel list', async () => {
   77                     await sideNav.getChannelFromList('general').scrollIntoViewIfNeeded();
   78                     await expect(sideNav.getChannelFromList('general')).toBeVisible();
   79                 });
   80 
   81                 test('expect go to the general channel', async () => {
   82                     await sideNav.openChannel('general');
   83                 });
   84             });
   85 
   86             test.describe('user created channel:', async () => {
   87                 test('expect show the user created channel in the channel list', async () => {
   88                     await sideNav.getChannelFromList(publicChannelName).scrollIntoViewIfNeeded();
   89                     await expect(sideNav.getChannelFromList(publicChannelName)).toBeVisible();
   90                 });
   91 
   92                 test('expect go to the user created channel', async () => {
   93                     await sideNav.openChannel(publicChannelName);
   94                 });
   95             });
   96         });
   97     });
   98 
   99     /*
  100      * Skipped tests below
  101      * */
  102     test.describe('[Usage]', () => {
  103         test.beforeAll(async () => {
  104             await sideNav.openChannel(publicChannelName);
  105         });
  106 
  107         test.describe('Adding a user to the room:', async () => {
  108             test.beforeAll(async () => {
  109                 if (await global.toastAlert().isVisible()) {
  110                     await global.dismissToast();
  111                 }
  112                 await flexTab.operateFlexTab('members', true);
  113             });
  114 
  115             test.afterAll(async () => {
  116                 if (await global.toastAlert().isVisible()) {
  117                     await global.dismissToast();
  118                 }
  119                 await flexTab.operateFlexTab('members', false);
  120             });
  121 
  122             test('expect add people to the room', async () => {
  123                 await flexTab.addPeopleToChannel(targetUser);
  124                 hasUserAddedInChannel = true;
  125                 await expect(global.toastAlert()).toBeVisible();
  126             });
  127         });
  128 
  129         test.describe('[Channel settings]:', async () => {
  130             test.describe('[Channel topic edit]', async () => {
  131                 test.beforeAll(async () => {
  132                     await flexTab.operateFlexTab('info', true);
  133                     await flexTab.editNameBtn().click();
  134                 });
  135 
  136                 test.afterAll(async () => {
  137                     if (await global.toastAlert().isVisible()) {
  138                         await global.dismissToast();
  139                     }
  140                     if (await flexTab.mainSideBar().isVisible()) {
  141                         await flexTab.mainSideBarClose().click();
  142                     }
  143                 });
  144 
  145                 test('expect edit the topic input', async () => {
  146                     await flexTab.editTopicTextInput().fill('TOPIC EDITED');
  147                 });
  148 
  149                 test('expect save the topic', async () => {
  150                     await flexTab.editNameSave().click();
  151                 });
  152 
  153                 test('expect show the new topic', async () => {
  154                     await expect(flexTab.secondSetting('TOPIC EDITED')).toBeVisible();
  155                 });
  156             });
  157 
  158             test.describe('[Channel announcement edit]', async () => {
  159                 test.beforeAll(async () => {
  160                     await flexTab.operateFlexTab('info', true);
  161                     await flexTab.editNameBtn().click();
  162                 });
  163 
  164                 test.afterAll(async () => {
  165                     if (await global.toastAlert().isVisible()) {
  166                         await global.dismissToast();
  167                     }
  168                     if (await flexTab.mainSideBar().isVisible()) {
  169                         await flexTab.mainSideBarClose().click();
  170                     }
  171                 });
  172 
  173                 test.skip('expect edit the announcement input', async () => {
  174                     await flexTab.editAnnouncementTextInput().type('ANNOUNCEMENT EDITED');
  175                 });
  176 
  177                 test.skip('expect save the announcement', async () => {
  178                     await flexTab.editNameSave().click();
  179                 });
  180 
  181                 // FIXME: breaking in CI
  182                 test.skip('expect show the new announcement', async () => {
  183                     await expect(flexTab.thirdSetting('ANNOUNCEMENT EDITED')).toHaveText('ANNOUNCEMENT EDITED');
  184                 });
  185             });
  186 
  187             test.describe('[Channel description edit]', async () => {
  188                 test.beforeAll(async () => {
  189                     await flexTab.operateFlexTab('info', true);
  190                     await flexTab.editNameBtn().click();
  191                 });
  192 
  193                 test.afterAll(async () => {
  194                     if (await global.toastAlert().isVisible()) {
  195                         await global.dismissToast();
  196                     }
  197                     if (await flexTab.mainSideBar().isVisible()) {
  198                         await flexTab.mainSideBarClose().click();
  199                     }
  200                 });
  201 
  202                 test('expect edit the description input', async () => {
  203                     await flexTab.editDescriptionTextInput().type('DESCRIPTION EDITED');
  204                 });
  205 
  206                 test('expect save the description', async () => {
  207                     await flexTab.editNameSave().click();
  208                 });
  209 
  210                 test('expect show the new description', async () => {
  211                     await flexTab.mainSideBarBack().click();
  212                     await expect(flexTab.fourthSetting()).toHaveText('DESCRIPTION EDITED');
  213                 });
  214             });
  215         });
  216 
  217         test.describe('[Members tab usage]:', async () => {
  218             test.describe('User muted', async () => {
  219                 test.beforeAll(async () => {
  220                     if (!hasUserAddedInChannel) {
  221                         await flexTab.operateFlexTab('members', true);
  222                         await flexTab.addPeopleToChannel(targetUser);
  223                         await flexTab.operateFlexTab('members', false);
  224                     }
  225                     await flexTab.operateFlexTab('members', true);
  226                 });
  227 
  228                 test.afterAll(async () => {
  229                     if (await global.toastAlert().isVisible()) {
  230                         await global.dismissToast();
  231                     }
  232                     await flexTab.operateFlexTab('members', false);
  233                 });
  234 
  235                 test('expect mute rocket cat', async () => {
  236                     await flexTab.muteUser(targetUser);
  237                 });
  238             });
  239 
  240             test.describe('[Owner added]', async () => {
  241                 test.beforeAll(async () => {
  242                     if (!hasUserAddedInChannel) {
  243                         await flexTab.operateFlexTab('members', true);
  244                         await flexTab.addPeopleToChannel(targetUser);
  245                         await flexTab.operateFlexTab('members', false);
  246                     }
  247                     await flexTab.operateFlexTab('members', true);
  248                 });
  249 
  250                 test.afterAll(async () => {
  251                     if (await global.toastAlert().isVisible()) {
  252                         await global.dismissToast();
  253                     }
  254                     await flexTab.operateFlexTab('members', false);
  255                 });
  256 
  257                 test('expect set rocket cat as owner', async () => {
  258                     await flexTab.setUserOwner(targetUser);
  259                 });
  260 
  261                 test('expect dismiss the toast', async () => {
  262                     if (await global.toastAlert().isVisible()) {
  263                         await global.dismissToast();
  264                     }
  265                 });
  266 
  267                 test.skip('expect the last message should be a subscription role added', async () => {
  268                     await expect(mainContent.lastMessageRoleAdded()).toBeVisible();
  269                 });
  270 
  271                 test.skip('expect show the target username in owner add message', async () => {
  272                     await expect(mainContent.lastMessageRoleAdded()).toContainText(targetUser);
  273                 });
  274             });
  275 
  276             test.describe('[Moderator added]', async () => {
  277                 test.beforeAll(async () => {
  278                     if (!hasUserAddedInChannel) {
  279                         await flexTab.operateFlexTab('members', true);
  280                         await flexTab.addPeopleToChannel(targetUser);
  281                         await flexTab.operateFlexTab('members', false);
  282                     }
  283                     await flexTab.operateFlexTab('members', true);
  284                 });
  285 
  286                 test.afterAll(async () => {
  287                     if (await global.toastAlert().isVisible()) {
  288                         await global.dismissToast();
  289                     }
  290                     await flexTab.operateFlexTab('members', false);
  291                 });
  292                 // FIXME: breaking in CI
  293                 test.skip('expect set rocket cat as moderator', async () => {
  294                     await flexTab.setUserModerator(targetUser);
  295                 });
  296 
  297                 // FIXME: not finding element in CI
  298                 test.skip('expect be that the last message is a subscription role added', async () => {
  299                     await expect(mainContent.lastMessageRoleAdded()).toBeVisible();
  300                 });
  301             });
  302 
  303             test.describe('Channel name edit', async () => {
  304                 test.beforeAll(async () => {
  305                     if (await global.toastAlert().isVisible()) {
  306                         await global.dismissToast();
  307                     }
  308                     await flexTab.operateFlexTab('info', true);
  309                 });
  310 
  311                 test.afterAll(async () => {
  312                     if (await global.toastAlert().isVisible()) {
  313                         await global.dismissToast();
  314                     }
  315 
  316                     if (await flexTab.mainSideBar().isVisible()) {
  317                         await flexTab.operateFlexTab('info', false);
  318                     }
  319                 });
  320 
  321                 test('expect show the old name', async () => {
  322                     await expect(flexTab.firstSetting()).toHaveText(publicChannelName);
  323                 });
  324 
  325                 test('expect click the edit name', async () => {
  326                     await flexTab.editNameBtn().click();
  327                 });
  328 
  329                 test('expect edit the name input', async () => {
  330                     await flexTab.editNameTextInput().fill(`NAME-EDITED-${publicChannelName}`);
  331                 });
  332 
  333                 test('expect save the name', async () => {
  334                     await flexTab.editNameSave().click();
  335                 });
  336 
  337                 test('expect show the new name', async () => {
  338                     const channelName = sideNav.getChannelFromList(`NAME-EDITED-${publicChannelName}`);
  339                     await expect(channelName).toHaveText(`NAME-EDITED-${publicChannelName}`);
  340                 });
  341             });
  342         });
  343     });
  344 });