From 95506eb94825be5f9e6e2d5ca1fce91e2a5d307f Mon Sep 17 00:00:00 2001 From: Uday Vunnam <20707504+udayvunnam@users.noreply.github.com> Date: Mon, 15 Nov 2021 09:19:07 +0530 Subject: [PATCH] fix: change autogenerated to false on dynamically setting a label (#101) --- .../src/integration/app.spec.ts | 24 ++++++++++++++++--- apps/simple-demo/src/app/app.component.html | 12 ++++++++-- apps/simple-demo/src/app/app.component.ts | 7 +++++- .../simple-demo/src/app/app.routing.module.ts | 7 ++++-- .../src/lib/breadcrumb.service.ts | 5 ++++ 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/apps/simple-demo-e2e/src/integration/app.spec.ts b/apps/simple-demo-e2e/src/integration/app.spec.ts index 489faf3..75c4fb9 100644 --- a/apps/simple-demo-e2e/src/integration/app.spec.ts +++ b/apps/simple-demo-e2e/src/integration/app.spec.ts @@ -1,17 +1,35 @@ describe('simple-demo', () => { - it('should contain breadcrumbs for books', () => { + it('should show breadcrumbs within ngIf', () => { cy.visit('/'); // initially within ngIf and not shown cy.get('xng-breadcrumb').should('not.exist'); cy.get('button').contains('Toggle Breadcrumb Visibility').click(); cy.get('xng-breadcrumb').contains('Dashboard'); + }); + it("shouldn't have default seperator if Home breadcrumb is not defined", () => { // shouldn't have default seperator if Home breadcrumb is not defined cy.get('.xng-breadcrumb-list').contains('/').should('not.exist'); - cy.get('a').contains('Order Details').click(); + }); - // Should show breadcrumbs when routeReuseStrategy is false + it('should show breadcrumbs when routeReuseStrategy is false', () => { + // Dashboard and Order Details use same component and routeReuseStrategy false still should get data + cy.get('a').contains('Order Details').click(); cy.get('.xng-breadcrumb-list').contains('Order Details').should('exist'); cy.get('.xng-breadcrumb-list').contains('Company Name').should('exist'); }); + + it('should show breadcrumbs if dynamically set with autoGenerate false', () => { + cy.get('a').contains('Order Items').click(); + cy.get('.auto-generated-true .xng-breadcrumb-list') + .contains('items') + .should('exist'); + cy.get('.auto-generated-false .xng-breadcrumb-list') + .contains('items') + .should('not.exist'); + cy.get('button').contains('Set Order Items Label').click(); + cy.get('.auto-generated-false .xng-breadcrumb-list') + .contains('My Order Items') + .should('exist'); + }); }); diff --git a/apps/simple-demo/src/app/app.component.html b/apps/simple-demo/src/app/app.component.html index cd08879..5183b89 100644 --- a/apps/simple-demo/src/app/app.component.html +++ b/apps/simple-demo/src/app/app.component.html @@ -1,8 +1,14 @@ -