Skip to content

Commit

Permalink
fix: close dialogs when switching to page mode (#175)
Browse files Browse the repository at this point in the history
This feature was commented out by a mistake

Fixes #172
  • Loading branch information
ronnymikalsen authored and raymondkarstensen committed Nov 1, 2017
1 parent 7ec2831 commit 967dc89
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 4 deletions.
16 changes: 16 additions & 0 deletions integration/e2e/features/view-switch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ Feature: Page view
And zoom level is home
When the user pinch in
Then the viewer should change to dashboard view

@desktop
Scenario: Close "Contents" dialog
Given the viewer is in dashboard view
And the viewer is in metadata view
When the user click in the viewer
Then the viewer should change to page view
And the Contents dialog should be closed

@desktop
Scenario: Close "Search" dialog
Given the viewer is in dashboard view
And the search dialog is open
When the user click in the viewer
Then the viewer should change to page view
And the Search dialog should be closed
7 changes: 7 additions & 0 deletions integration/e2e/pages/content-search.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { Utils } from '../helpers/utils';
const utils = new Utils();
export class ContentSearchPage {

async isOpen() {
// Wait for dialog animation
await browser.sleep(1000);
const el: ElementFinder = element(by.css('mime-search'));
return el.isPresent();
}

async setSearchTerm(term: string) {
const el: ElementFinder = await utils.waitForElement(element(by.css('.content-search-input')));
await el.clear();
Expand Down
15 changes: 15 additions & 0 deletions integration/e2e/pages/contents.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { protractor } from 'protractor/built';
import { browser, element, ElementFinder, by } from 'protractor';
import { Utils } from '../helpers/utils';

const utils = new Utils();
export class ContentsPage {

async isOpen() {
// Wait for dialog animation
await browser.sleep(1000);
const el: ElementFinder = element(by.css('mime-contents'));
return el.isPresent();
}

}
8 changes: 8 additions & 0 deletions integration/e2e/step-definitions/content-dialog.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { expect } from '../helpers/chai-imports';
import { browser } from 'protractor';

import { ViewerPage } from '../pages/viewer.po';
import { ContentsPage } from '../pages/contents.po';
import { MetadataPage } from '../pages/metadata.po';
import { TableOfContentsPage } from '../pages/table-of-contents.po';

defineSupportCode(function ({ Given, Then, When }) {
const page = new ViewerPage();
const contents = new ContentsPage();
const metadata = new MetadataPage();
const toc = new TableOfContentsPage();

Expand Down Expand Up @@ -39,4 +41,10 @@ defineSupportCode(function ({ Given, Then, When }) {
const currentPageString = await page.getCurrentPageString();
expect(currentPageString.includes(pageNumber)).to.eql(true);
});

Then(/^the Contents dialog should be closed$/, async () => {
const isOpen = await contents.isOpen();
expect(isOpen).to.equal(false);
});

});
9 changes: 9 additions & 0 deletions integration/e2e/step-definitions/content-search.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ defineSupportCode(function ({ Given, When, Then }) {
const page = new ViewerPage();
const contentSearchPage = new ContentSearchPage();

Given(/^the search dialog is open$/, async () => {
await page.openContentSearchDialog();
});

Given(/^the user has selected the second hit$/, async () => {
await selectHit(1);
});
Expand Down Expand Up @@ -66,6 +70,11 @@ defineSupportCode(function ({ Given, When, Then }) {
expect(el.isPresent()).to.eql({});
});

Then(/^the Search dialog should be closed$/, async () => {
const isOpen = await contentSearchPage.isOpen();
expect(isOpen).to.equal(false);
});

Then(/^hit number (.*) should be marked$/, async (hitIndex: number) => {
const isSelected: boolean = await contentSearchPage.isSelected(hitIndex);
expect(isSelected).to.equal(true);
Expand Down
6 changes: 2 additions & 4 deletions src/lib/src/viewer/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,10 @@ export class ViewerComponent implements OnInit, OnDestroy, OnChanges {

// ChangeDetection fix
onModeChange() {
/*
if (this.modeService.mode === ViewerMode.DASHBOARD) {
this.contentsDialogService.destroy();
this.contentSearchDialogService.destroy();
this.contentsDialogService.close();
this.contentSearchDialogService.close();
}
*/
}

toggleToolbarsState(mode: ViewerMode): void {
Expand Down

0 comments on commit 967dc89

Please sign in to comment.