"Fossies" - the Fresh Open Source Software Archive

Member "Rocket.Chat-4.7.1/apps/meteor/tests/e2e/08-resolutions.spec.ts" (13 May 2022, 3554 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, Browser } from '@playwright/test';
    2 
    3 import MainContent from './utils/pageobjects/MainContent';
    4 import SideNav from './utils/pageobjects/SideNav';
    5 import LoginPage from './utils/pageobjects/LoginPage';
    6 import { adminLogin } from './utils/mocks/userAndPasswordMock';
    7 
    8 let loginPage: LoginPage;
    9 let mainContent: MainContent;
   10 let sideNav: SideNav;
   11 
   12 async function initConfig(
   13     browser: Browser,
   14     baseURL: string | undefined,
   15     options = { viewport: { width: 650, height: 800 } },
   16 ): Promise<any> {
   17     const context = await browser.newContext(options);
   18     const page = await context.newPage();
   19     const URL = baseURL as string;
   20     loginPage = new LoginPage(page);
   21     await loginPage.goto(URL);
   22 
   23     await loginPage.login(adminLogin);
   24     sideNav = new SideNav(page);
   25     mainContent = new MainContent(page);
   26     return { loginPage, sideNav, mainContent };
   27 }
   28 
   29 test.describe('[Resolution]', function () {
   30     test.describe('[Mobile Render]', async () => {
   31         test.beforeAll(async ({ browser, baseURL }) => {
   32             await initConfig(browser, baseURL);
   33         });
   34 
   35         test.afterAll(async ({ browser, baseURL }) => {
   36             await initConfig(browser, baseURL, { viewport: { width: 1600, height: 1600 } });
   37 
   38             await expect(sideNav.spotlightSearchIcon()).toBeVisible();
   39         });
   40 
   41         test('expect close the sidenav', async () => {
   42             const position = await mainContent.mainContent().boundingBox();
   43             await expect(position?.x).toEqual(0);
   44             await expect(await sideNav.isSideBarOpen()).toBeFalsy;
   45         });
   46 
   47         test.describe('moving elements:', async () => {
   48             test.beforeEach(async () => {
   49                 if (!(await sideNav.isSideBarOpen())) {
   50                     await sideNav.burgerBtn().click({ force: true });
   51                 }
   52             });
   53 
   54             test('expect open the sidenav', async () => {
   55                 const position = await mainContent.mainContent().boundingBox();
   56                 await expect(position?.x).toEqual(0);
   57                 await expect(await sideNav.isSideBarOpen()).toBeTruthy;
   58             });
   59 
   60             test('expect not close sidebar on pressing the sidebar item menu', async () => {
   61                 await sideNav.firstSidebarItemMenu().click();
   62 
   63                 const position = await mainContent.mainContent().boundingBox();
   64                 await expect(position?.x).toEqual(0);
   65 
   66                 await expect(await sideNav.isSideBarOpen()).toBeTruthy;
   67 
   68                 await sideNav.firstSidebarItemMenu().click();
   69             });
   70 
   71             test('expect close the sidenav when open general channel', async () => {
   72                 await sideNav.openChannel('general');
   73                 await expect(await sideNav.isSideBarOpen()).toBeFalsy;
   74             });
   75 
   76             test.describe('Preferences', async () => {
   77                 test.beforeAll(async () => {
   78                     if (!(await sideNav.isSideBarOpen())) {
   79                         await sideNav.burgerBtn().click({ force: true });
   80                     }
   81 
   82                     await sideNav.sidebarUserMenu().click();
   83                     await sideNav.account().click();
   84                 });
   85 
   86                 test.afterEach(async () => {
   87                     await sideNav.returnToMenuInLowResolution().click();
   88                 });
   89 
   90                 test('expect close the sidenav when press the preferences link', async () => {
   91                     await sideNav.preferences().click();
   92                     await sideNav.getPage().mouse.click(640, 30);
   93                     await expect(await sideNav.isSideBarOpen()).toBeTruthy;
   94                 });
   95 
   96                 test('expect close the sidenav when press the profile link', async () => {
   97                     await sideNav.profile().click();
   98                     await sideNav.getPage().mouse.click(640, 30);
   99                     await expect(await sideNav.isSideBarOpen()).toBeTruthy;
  100                 });
  101 
  102                 test('expect close the preferences nav', async () => {
  103                     await sideNav.preferencesClose().click();
  104                     await sideNav.getPage().mouse.click(640, 30);
  105                     await expect(await sideNav.isSideBarOpen()).toBeFalsy;
  106                 });
  107             });
  108         });
  109     });
  110 });