Skip to content

Commit

Permalink
feat: activate the most recent view when closing a view
Browse files Browse the repository at this point in the history
Closes #74
  • Loading branch information
mofogasy authored and danielwiehl committed Jul 24, 2019
1 parent 2578b20 commit 7896583
Show file tree
Hide file tree
Showing 23 changed files with 191 additions and 52 deletions.
64 changes: 64 additions & 0 deletions projects/e2e/workbench/src/view-tab-bar.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import { AppPO } from './page-object/app.po';
import { browser } from 'protractor';
import { WelcomePagePO } from './page-object/welcome-page.po';
import { ViewNavigationPO } from './page-object/view-navigation.po';

describe('ViewTabBar', () => {

const appPO = new AppPO();
const welcomePagePO = new WelcomePagePO();
const viewNavigationPO = new ViewNavigationPO();

beforeEach(async () => {
await browser.get('/');
Expand Down Expand Up @@ -48,4 +50,66 @@ describe('ViewTabBar', () => {
await expect(appPO.getViewTabCount()).toEqual(0);
await expect(appPO.isViewTabBarShowing()).toBeTruthy();
});

it('should activate the most recent view when closing a view', async () => {
await viewNavigationPO.navigateTo();
await expect(appPO.getViewTabCount()).toEqual(1);

// open view-1
await viewNavigationPO.enterPath('view');
await viewNavigationPO.enterMatrixParams({viewCssClass: 'e2e-view-1', viewTitle: 'view-1'});
await viewNavigationPO.checkActivateIfPresent(true);
await viewNavigationPO.selectTarget('blank');
await viewNavigationPO.navigate();

await expect(appPO.findViewTab('e2e-view-1').isActive()).toBeTruthy();
await expect(appPO.getViewTabCount()).toEqual(2);

// open view-2
await viewNavigationPO.activateViewTab();
await viewNavigationPO.enterPath('view');
await viewNavigationPO.enterMatrixParams({viewCssClass: 'e2e-view-2', viewTitle: 'view-2'});
await viewNavigationPO.checkActivateIfPresent(true);
await viewNavigationPO.selectTarget('blank');
await viewNavigationPO.navigate();

await expect(appPO.findViewTab('e2e-view-2').isActive()).toBeTruthy();
await expect(appPO.getViewTabCount()).toEqual(3);

// open view-3
await viewNavigationPO.activateViewTab();
await viewNavigationPO.enterPath('view');
await viewNavigationPO.enterMatrixParams({viewCssClass: 'e2e-view-3', viewTitle: 'view-3'});
await viewNavigationPO.checkActivateIfPresent(true);
await viewNavigationPO.selectTarget('blank');
await viewNavigationPO.navigate();

await expect(appPO.findViewTab('e2e-view-3').isActive()).toBeTruthy();
await expect(appPO.getViewTabCount()).toEqual(4);

// activate view-2
await appPO.findViewTab('e2e-view-2').click();

await expect(appPO.findViewTab('e2e-view-2').isActive()).toBeTruthy();

// activate view-1
await appPO.findViewTab('e2e-view-1').click();

await expect(appPO.findViewTab('e2e-view-1').isActive()).toBeTruthy();

// activate view-3
await appPO.findViewTab('e2e-view-3').click();

await expect(appPO.findViewTab('e2e-view-3').isActive()).toBeTruthy();

// close view-3
await appPO.findViewTab('e2e-view-3').close();

await expect(appPO.findViewTab('e2e-view-1').isActive()).toBeTruthy();

// close view-1
await appPO.findViewTab('e2e-view-1').close();

await expect(appPO.findViewTab('e2e-view-2').isActive()).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { NgModule } from '@angular/core';
import { WorkbenchApplicationPlatformModule } from '../workbench-application-platform.module';
import { NullErrorHandler } from '../core/null-error-handler.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { WorkbenchModule } from '@scion/workbench';
import { RouterTestingModule } from '@angular/router/testing';
import { ApplicationRegistry } from '../core/application-registry.service';
import { ApplicationManifest } from '../core/metadata';
import { WorkbenchTestingModule } from '@scion/workbench';

describe('ManifestCollector', () => {

Expand Down Expand Up @@ -85,7 +85,7 @@ function createApplicationManifest(app: { appName: string }): ApplicationManifes
imports: [
HttpClientTestingModule,
RouterTestingModule.withRoutes([]),
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
WorkbenchApplicationPlatformModule.forRoot({
errorHandler: NullErrorHandler,
applicationConfig: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import { fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { NgModule, NgModuleFactoryLoader } from '@angular/core';
import { WorkbenchApplicationPlatformModule } from '../workbench-application-platform.module';
import { NullErrorHandler } from '../core/null-error-handler.service';
import { WorkbenchModule } from '@scion/workbench';
import { RouterTestingModule, SpyNgModuleFactoryLoader } from '@angular/router/testing';
import { Router } from '@angular/router';
import { WorkbenchTestingModule } from '@scion/workbench';

describe('WorkbenchApplicationPlatform', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
WorkbenchApplicationPlatformModule.forRoot({errorHandler: NullErrorHandler, applicationConfig: []}),
RouterTestingModule.withRoutes([{path: 'lazy-module-forroot', loadChildren: './lazy-forroot.module'}]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, NgModule, NgModuleFactoryLoader } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.spec';
import { RouterTestingModule, SpyNgModuleFactoryLoader } from '@angular/router/testing';
import { Router, RouteReuseStrategy, RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { advance, clickElement } from './util/util.spec';
import { ActivityPartComponent } from '../activity-part/activity-part.component';
import { WorkbenchTestingModule } from './workbench-testing.module';

/**
*
Expand Down Expand Up @@ -117,7 +117,7 @@ class AppComponent {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
RouterTestingModule.withRoutes([
{path: 'feature-a', loadChildren: './feature-a/feature-a.module'},
Expand Down
4 changes: 2 additions & 2 deletions projects/scion/workbench/src/lib/spec/activity-action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, NgModule } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { RouterTestingModule } from '@angular/router/testing';
import { Router, RouteReuseStrategy } from '@angular/router';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -19,6 +18,7 @@ import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.sp
import { ActivityPartComponent } from '../activity-part/activity-part.component';
import { By } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { WorkbenchTestingModule } from './workbench-testing.module';

/**
*
Expand Down Expand Up @@ -129,7 +129,7 @@ class Activity3Component {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
CommonModule,
RouterTestingModule.withRoutes([
Expand Down
4 changes: 2 additions & 2 deletions projects/scion/workbench/src/lib/spec/activity-guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, Injectable, NgModule } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { RouterTestingModule } from '@angular/router/testing';
import { ActivatedRouteSnapshot, CanActivate, Router, RouteReuseStrategy, RouterStateSnapshot } from '@angular/router';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -20,6 +19,7 @@ import { ActivityPartComponent } from '../activity-part/activity-part.component'
import { By } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { Observable } from 'rxjs';
import { WorkbenchTestingModule } from './workbench-testing.module';

/**
*
Expand Down Expand Up @@ -126,7 +126,7 @@ class Activity2CanActivate implements CanActivate {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
CommonModule,
RouterTestingModule.withRoutes([
Expand Down
4 changes: 2 additions & 2 deletions projects/scion/workbench/src/lib/spec/activity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, NgModule, OnDestroy } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { RouterTestingModule } from '@angular/router/testing';
import { ActivatedRoute, ParamMap, Router, RouteReuseStrategy } from '@angular/router';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -20,6 +19,7 @@ import { Subject } from 'rxjs';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
import { ActivityPartComponent } from '../activity-part/activity-part.component';
import { WorkbenchTestingModule } from './workbench-testing.module';

describe('Activity part', () => {

Expand Down Expand Up @@ -146,7 +146,7 @@ class Activity2Component {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
RouterTestingModule.withRoutes([
{path: 'activity-debug', component: ActivityDebugComponent},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import { async, fakeAsync, inject, TestBed } from '@angular/core/testing';
import { Component, Inject, Injectable, InjectionToken, NgModule, NgModuleFactoryLoader, Optional } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.spec';
import { RouterTestingModule, SpyNgModuleFactoryLoader } from '@angular/router/testing';
import { Router, RouterModule } from '@angular/router';
Expand All @@ -20,6 +19,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { advance, clickElement } from './util/util.spec';
import { ActivityPartComponent } from '../activity-part/activity-part.component';
import { By } from '@angular/platform-browser';
import { WorkbenchTestingModule } from './workbench-testing.module';

/**
*
Expand Down Expand Up @@ -144,7 +144,7 @@ export class FeatureService {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
RouterTestingModule.withRoutes([
{path: 'feature', loadChildren: './feature/feature.module'},
Expand Down
4 changes: 2 additions & 2 deletions projects/scion/workbench/src/lib/spec/route-resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, NgModule } from '@angular/core';
import { ViewPartGridComponent } from '../view-part-grid/view-part-grid.component';
import { WorkbenchModule } from '../workbench.module';
import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.spec';
import { RouterTestingModule } from '@angular/router/testing';
import { Router } from '@angular/router';
import { InternalWorkbenchRouter, WorkbenchRouter } from '../routing/workbench-router.service';
import { advance } from './util/util.spec';
import { WorkbenchViewRegistry } from '../workbench-view-registry.service';
import { WorkbenchView } from '../workbench.model';
import { WorkbenchTestingModule } from './workbench-testing.module';

describe('WbRouter', () => {

Expand Down Expand Up @@ -111,7 +111,7 @@ class ViewComponent {
@NgModule({
declarations: [ViewComponent],
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
RouterTestingModule.withRoutes([
{path: 'path/to/view', component: ViewComponent},
{path: 'path/to/view-1', component: ViewComponent},
Expand Down
8 changes: 4 additions & 4 deletions projects/scion/workbench/src/lib/spec/router-navigate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { Component, NgModule, NgModuleFactoryLoader } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { RouterTestingModule, SpyNgModuleFactoryLoader } from '@angular/router/testing';
import { Router, RouterModule } from '@angular/router';
import { WorkbenchRouter } from '../routing/workbench-router.service';
import { CommonModule } from '@angular/common';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { advance, clickElement } from './util/util.spec';
import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.spec';
import { WorkbenchTestingModule } from './workbench-testing.module';

/**
* Testsetup:
Expand Down Expand Up @@ -306,7 +306,7 @@ class AppComponent {

@NgModule({
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
NoopAnimationsModule,
RouterTestingModule.withRoutes([
{path: 'feature-a', loadChildren: './feature-a/feature-a.module'},
Expand Down Expand Up @@ -376,7 +376,7 @@ class FeatureA_View2Component {
@NgModule({
imports: [
CommonModule,
WorkbenchModule.forChild(),
WorkbenchTestingModule.forChild(),
RouterModule.forChild([
{path: '', component: FeatureA_EntryComponent},
{path: 'view-1', component: FeatureA_View1Component},
Expand Down Expand Up @@ -442,7 +442,7 @@ class FeatureB_View2Component {
@NgModule({
imports: [
CommonModule,
WorkbenchModule.forChild(),
WorkbenchTestingModule.forChild(),
RouterModule.forChild([
{path: '', component: FeatureB_EntryComponent},
{path: 'view-1', component: FeatureB_View1Component},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import { async, fakeAsync, inject, TestBed } from '@angular/core/testing';
import { expect, jasmineCustomMatchers } from './util/jasmine-custom-matchers.spec';
import { Component, NgModule } from '@angular/core';
import { WorkbenchModule } from '../workbench.module';
import { ViewPartGridComponent } from '../view-part-grid/view-part-grid.component';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { WorkbenchViewPartRegistry } from '../view-part-grid/workbench-view-part-registry.service';
import { WorkbenchRouter } from '../routing/workbench-router.service';
import { advance } from './util/util.spec';
import { WorkbenchTestingModule } from './workbench-testing.module';

describe('ViewPartGridComponent', () => {

Expand Down Expand Up @@ -504,7 +504,7 @@ class View3Component {
@NgModule({
declarations: [View1Component, View2Component, View3Component],
imports: [
WorkbenchModule.forRoot(),
WorkbenchTestingModule.forRoot(),
RouterTestingModule.withRoutes([
{path: 'view-1', component: View1Component},
{path: 'view-2', component: View2Component},
Expand Down
Loading

0 comments on commit 7896583

Please sign in to comment.