Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a e2e test for "withoutSync()" bug fix #1744

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 216 additions & 17 deletions test/e2e-test-application/e2e/tests/1-angular/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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')
legteodav marked this conversation as resolved.
Show resolved Hide resolved
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');

legteodav marked this conversation as resolved.
Show resolved Hide resolved

// checking if we have NOT highlighted menu item
cy.get('a[href="/projects/pr2/virtual-tree"]').should('exist').not('.is-selected');

legteodav marked this conversation as resolved.
Show resolved Hide resolved

// CLICK ON navigate-withoutSync-virtual-tree
// linkManager().withoutSync().navigate('/projects/pr2/virtual-tree')
legteodav marked this conversation as resolved.
Show resolved Hide resolved
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');
});

});
});






});
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ <h3 class="fd-layout-panel__title">Check if path exists</h3>
</div>
</div>

<div class="fd-layout-panel">
<div class="fd-layout-panel luigi__margin-bottom--small">
<div class="fd-layout-panel__header">
<div class="fd-layout-panel__head">
<h3 class="fd-layout-panel__title">
Expand Down Expand Up @@ -679,6 +679,57 @@ <h3 class="fd-layout-panel__title">
</ul>
</div>
</div>

<div class="fd-layout-panel luigi__margin-bottom--small">
<div class="fd-layout-panel__header">
<div class="fd-layout-panel__head">
<h3 class="fd-layout-panel__title">
LuigiClient - withoutSync()
</h3>
</div>
</div>
<div class="fd-layout-panel__body">
<ul class="fd-list">
<li class="fd-list__item">
<a href="javascript:void(0)" class="fd-link" (click)="
linkManager().withoutSync().navigate('/projects/pr2/virtual-tree')"
data-testid='navigate-withoutSync-virtual-tree'
>Go to /projects/pr2/virtual-tree using withoutSync()
</a>
<app-code-snippet data="linkManager().withoutSync().navigate('/projects/pr2/virtual-tree')">
</app-code-snippet>
</li>

<li class="fd-list__item">
<a href="javascript:void(0)" class="fd-link navigate-withoutSync-settings" (click)="
linkManager().withoutSync().navigate('/projects/pr2/settings')"
data-testid='navigate-withoutSync-settings'
>Go to /projects/pr2/settings using withoutSync()
</a>
<app-code-snippet data="linkManager().withoutSync().navigate('/projects/pr2/settings')">
</app-code-snippet>
</li>


<li class="fd-list__item">
<a href="javascript:void(0)" class="fd-link navigate-withSync-virtual-tree"
(click)="navigateWithSync('/projects/pr2/virtual-tree')"
data-testid='navigate-withSync-virtual-tree'
>Go to /projects/pr2/virtual-tree NOT using withoutSync()
</a>
<app-code-snippet data="linkManager().navigate('/projects/pr2/virtual-tree')">
</app-code-snippet>
</li>



</ul>
</div>
</div>




</div>
<div *ngIf="projectId && projectId === 'tabNav'">
<div class="fd-section__header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down