<commit_before>/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

import { browser, by, element } from 'protractor';
import { Util } from '../util/index';
import { SidenavPage } from './sidenav.po';

describe('Sidenav component', () => {
    let sidenav: SidenavPage;

    beforeEach(() => {
        Util.init();
        sidenav = new SidenavPage();
    });

    it('should be visible by default', () => {
        sidenav.navigateTo();
        expect(element(by.css('deja-sidenav-menu')).isPresent()).toBe(true);
        expect(element(by.css('deja-sidenav-menu')).isDisplayed()).toBe(true);
    });

    it('should open on menu click', () => {
        sidenav.navigateTo();

        Util.waitForElement('deja-sidenav-menu mat-list-item.active');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active')).isPresent()).toBe(true);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(false, 'Should be close by default');

        element(by.css('mat-sidenav .header-menu-btn')).click();
        browser.sleep(500);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(true, 'Should be open');

        element(by.css('mat-sidenav .header-menu-btn')).click();
        browser.sleep(500);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(false, 'Should be close');
    });

    it('should be open by default on desktop', () => {
        sidenav.navigateTo();
        browser.driver.manage().window().setSize(1920, 1080);
        browser.sleep(500);

        Util.waitForElement('deja-sidenav-menu mat-list-item.active');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active')).isPresent()).toBe(true);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(true, 'Should be open');

        browser.driver.manage().window().setSize(1024, 768);
        browser.sleep(500);
    });

    it('should be hidden on mobile', () => {
        sidenav.navigateTo();
        browser.driver.manage().window().setSize(375, 667);
        browser.sleep(500);

        Util.waitForElement('deja-sidenav-menu');
        expect(element(by.css('deja-sidenav-menu')).isDisplayed()).toBe(false, 'Should be hidden');

        element(by.css('mat-toolbar .menu-btn')).click();
        browser.sleep(500);
        expect(element(by.css('deja-sidenav-menu')).isDisplayed()).toBe(true, 'Should be visible');

        browser.driver.manage().window().setSize(1024, 768);
        browser.sleep(500);
    });
});
<commit_msg>quiet(Test): Fix Test E2E<commit_after>/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

import { browser, by, element } from 'protractor';
import { Util } from '../util/index';
import { SidenavPage } from './sidenav.po';

describe('Sidenav component', () => {
    let sidenav: SidenavPage;

    beforeEach(() => {
        Util.init();
        sidenav = new SidenavPage();
    });

    it('should be hidden on mobile', () => {
        sidenav.navigateTo();
        browser.driver.manage().window().setSize(375, 667);
        browser.sleep(500);

        Util.waitForElement('deja-sidenav-menu');
        expect(element(by.css('deja-sidenav-menu')).isDisplayed()).toBe(false, 'Should be hidden');

        browser.driver.manage().window().setSize(1024, 768);
        browser.sleep(500);
    });

    it('should be minimize on tablet', () => {
        Util.waitForElement('deja-sidenav-menu');
        expect(element(by.css('deja-sidenav-menu')).isDisplayed()).toBe(true, 'Should be visible');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(false, 'Should be minimize');
    });

    it('should be open on desktop', () => {
        browser.driver.manage().window().setSize(1250, 500);
        browser.sleep(500);

        Util.waitForElement('deja-sidenav-menu mat-list-item.active');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active')).isPresent()).toBe(true, 'Should be visible');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(true, 'Should be open');

        browser.driver.manage().window().setSize(1024, 768);
        browser.sleep(500);
    });

    it('should open on menu click', () => {
        Util.waitForElement('deja-sidenav-menu mat-list-item.active');
        expect(element(by.css('deja-sidenav-menu mat-list-item.active')).isPresent()).toBe(true);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(false, 'Should be close by default');

        element(by.css('mat-sidenav .header-menu-btn')).click();
        browser.sleep(500);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(true, 'Should be open');

        element(by.css('mat-sidenav .header-menu-btn')).click();
        browser.sleep(500);
        expect(element(by.css('deja-sidenav-menu mat-list-item.active .mat-list-text')).isDisplayed()).toBe(false, 'Should be close');
    });
});

{'fraction_non_alphanumeric': 0.1828072052791154, 'fraction_numerical': 0.01765650080256822, 'mean_word_length': 3.264638783269962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3373929', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1811, 'n_words': 297}