From 830716e5fa437e0111f71e05de90a12f2f97d34a Mon Sep 17 00:00:00 2001 From: "Leggieri, Davide Teodoro" Date: Wed, 27 Jan 2021 15:39:26 +0100 Subject: [PATCH] merging with master --- .../e2e/tests/1-angular/navigation.spec.js | 233 ++++++++++++++++-- .../src/app/project/project.component.html | 53 +++- .../src/app/project/project.component.ts | 5 + 3 files changed, 273 insertions(+), 18 deletions(-) diff --git a/test/e2e-test-application/e2e/tests/1-angular/navigation.spec.js b/test/e2e-test-application/e2e/tests/1-angular/navigation.spec.js index 134621f7bf..e01fa7dfac 100644 --- a/test/e2e-test-application/e2e/tests/1-angular/navigation.spec.js +++ b/test/e2e-test-application/e2e/tests/1-angular/navigation.spec.js @@ -310,7 +310,7 @@ describe('Navigation', () => { cy.get('.fd-shellbar') .contains('Visible for all users') .should('exist'); - + cy.get('.fd-shellbar') .contains('Visible for anonymous users only') .should('not.exist'); @@ -849,28 +849,227 @@ describe('Navigation', () => { }); }); }); - describe('User settings', () => { - it('It should display user settings info when userSettingsGroup provided', () => { - const userSettings = - '{"userAccount":{"name":"Luigi","email":"luigi@luigi.de","server":"luigi.server"},"language":{"language":"Italian","date":"XXX?","time":"12 h"}}'; - localStorage.setItem('luigi.preferences.userSettings', userSettings); - cy.visit('/projects/pr1/user_settings'); - cy.getIframeBody().then($iframeBody => { - cy.wrap($iframeBody).should('contain', 'LuigiClient User Settings'); + describe('Collapsible Categories / Accordion', () => { + it('It should have multiple categories collapsed', () => { + cy.visit('/projects/pr2/collapsibles'); + + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + + cy.get( + 'li[data-testid="superusefulgithublinks"] a[title="Super useful Github links"]' + ).click(); + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'be.visible' + ); + + cy.get( + 'li[data-testid="superusefulgithublinks"] a[title="Super useful Github links"]' + ).click(); + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + }); + + it('It should have a local side nav accordion mode', () => { + cy.visit('/projects/pr2/sidenavaccordionmode'); + + // All is closed + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + + cy.get( + 'li[data-testid="superusefulgithublinks"] a[title="Super useful Github links"]' + ).click(); + + // First one is open only + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + // Second one is open only + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'be.visible' + ); + + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + // All is closed + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + }); + + it('It should have a global side nav accordion mode', () => { + cy.visit('/projects/pr2/collapsibles'); + cy.window().then(win => { + const config = win.Luigi.getConfig(); + config.navigation.defaults = { + sideNavAccordionMode: true + }; + win.Luigi.configChanged('settings.navigation'); + // All is closed + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + + cy.get( + 'li[data-testid="superusefulgithublinks"] a[title="Super useful Github links"]' + ).click(); + + // First one is open only + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); + + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + // Second one is open only + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'be.visible' + ); + + cy.get( + 'li[data-testid="usermanagement"] a[title="User Management"]' + ).click(); + + // All is closed + cy.get( + 'li[data-testid="superusefulgithublinks"]>ul.fd-nested-list' + ).should('not.be.visible'); + cy.get('li[data-testid="usermanagement"]>ul.fd-nested-list').should( + 'not.be.visible' + ); }); - cy.clearLocalStorage('luigi.preferences.userSettings'); + }); + }); + + + describe('Link withoutSync/withSync', () => { + beforeEach(() => { + cy.visitLoggedIn('/projects/pr2'); }); - it('It should not display user settings info when userSettingsGroup not found', () => { - const userSettings = '{"mockGroup":{ name: "test"}}'; - localStorage.setItem('luigi.preferences.userSettings', userSettings); + it('withoutSync -> it should remain on the current page, highlight tree menu and remain in same page', () => { + cy.expectPathToBe('/projects/pr2'); + cy.getIframeBody().then(result => { + // Link on Main page PR2 exist + cy.wrap(result).contains(' with params: project to global settings and back'); + + // checking if we have NOT highlighted menu item + cy.get('a[href="/projects/pr2/virtual-tree"]').should('exist').not('.is-selected'); + + // CLICK ON navigate-withoutSync-virtual-tree + // linkManager().withoutSync().navigate('/projects/pr2/virtual-tree') + cy.wrap(result).find('a[data-testid="navigate-withoutSync-virtual-tree"]').click(); + + // Url should changed in the main window + cy.expectPathToBe('/projects/pr2/virtual-tree'); + // Click link is still here (we haven't changed page) + cy.wrap(result).find('a[data-testid="navigate-withoutSync-virtual-tree"]') + // checking if we have highlighted menu item + cy.get('a[href="/projects/pr2/virtual-tree"]').should('exist').should('have.class','is-selected'); + + + // checking if we have NOT highlighted menu item + cy.get('a[href="/projects/pr2/settings"]').should('exist').not('.is-selected'); + + // CLICK ON navigate-withoutSync-virtual-tree + // linkManager().withoutSync().navigate('/projects/pr2/virtual-tree') + cy.wrap(result).find('a[data-testid="navigate-withoutSync-settings"]').click(); + + // Url should changed in the main window + cy.expectPathToBe('/projects/pr2/settings'); + // Click link is still here (we haven't changed page) + cy.wrap(result).find('a[data-testid="navigate-withoutSync-virtual-tree"]') + // checking if we have highlighted menu item + cy.get('a[href="/projects/pr2/settings"]').should('exist').should('have.class','is-selected'); - cy.visit('/projects/pr1/settings'); - cy.getIframeBody().then($iframeBody => { - cy.wrap($iframeBody).should('not.contain', 'LuigiClient User Settings'); }); - cy.clearLocalStorage('luigi.preferences.userSettings'); + + }); + + it('withSync -> it should change page', () => { + cy.expectPathToBe('/projects/pr2'); + cy.getIframeBody().then(result => { + // Link on Main page PR2 exist + cy.wrap(result).contains(' with params: project to global settings and back'); + + + // checking if we have NOT highlighted menu item + cy.get('a[href="/projects/pr2/virtual-tree"]').should('exist').not('.is-selected'); + + + // CLICK ON navigate-withoutSync-virtual-tree + // linkManager().withoutSync().navigate('/projects/pr2/virtual-tree') + cy.wrap(result).find('a[data-testid="navigate-withSync-virtual-tree"]').click(); + + // Url should changed in the main window + cy.expectPathToBe('/projects/pr2/virtual-tree'); + + // Check we have changed page + cy.wrap(result).contains(' with params: project to global settings and back').should('not.exist'); + // checking if we have highlighted menu item + cy.get('a[href="/projects/pr2/virtual-tree"]').should('exist').should('have.class','is-selected'); + + cy.wrap(result).contains('Add Segments To The Url content'); + }); + }); }); + + + + + + }); diff --git a/test/e2e-test-application/src/app/project/project.component.html b/test/e2e-test-application/src/app/project/project.component.html index 9f6d21fac3..b4bcf8f0bf 100644 --- a/test/e2e-test-application/src/app/project/project.component.html +++ b/test/e2e-test-application/src/app/project/project.component.html @@ -639,7 +639,7 @@

Check if path exists

-
+

@@ -679,6 +679,57 @@

+ + + + + +
diff --git a/test/e2e-test-application/src/app/project/project.component.ts b/test/e2e-test-application/src/app/project/project.component.ts index 16d1918218..d992a17cfa 100644 --- a/test/e2e-test-application/src/app/project/project.component.ts +++ b/test/e2e-test-application/src/app/project/project.component.ts @@ -83,6 +83,11 @@ export class ProjectComponent implements OnInit, OnDestroy { }, 2000); } + navigateWithSync(path) { + linkManager()['options'].withoutSync = false; + linkManager().navigate(path); + } + public ngOnInit() { // We suggest to use a centralized approach of LuigiClient.addContextUpdateListener // Take a look at ngOnInit in this component and app.component.ts where we set the listeners.