@internetarchive/bookreader 5.0.0-66 → 5.0.0-68
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.css +68 -918
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +118 -128
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +24 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReaderDemo/BookReaderDemo.css +0 -18
- package/BookReaderDemo/BookReaderJSAdvanced.js +0 -3
- package/BookReaderDemo/demo-autoplay.html +0 -2
- package/BookReaderDemo/demo-fullscreen-mobile.html +1 -4
- package/BookReaderDemo/demo-fullscreen.html +0 -3
- package/BookReaderDemo/demo-iiif.js +0 -1
- package/BookReaderDemo/demo-internetarchive.html +41 -3
- package/BookReaderDemo/demo-vendor-fullscreen.html +0 -3
- package/BookReaderDemo/immersion-1up.html +0 -1
- package/BookReaderDemo/immersion-mode.html +0 -3
- package/BookReaderDemo/toggle_controls.html +1 -1
- package/CHANGELOG.md +10 -0
- package/index.html +1 -1
- package/package.json +9 -9
- package/src/BookNavigator/book-navigator.js +4 -3
- package/src/BookReader/Mode1Up.js +1 -1
- package/src/BookReader/Mode1UpLit.js +1 -1
- package/src/BookReader/Navbar/Navbar.js +2 -2
- package/src/BookReader/events.js +0 -1
- package/src/BookReader.js +1 -2
- package/src/css/BookReader.scss +1 -5
- package/src/css/_BRnav.scss +5 -10
- package/src/css/_BRsearch.scss +6 -2
- package/src/css/_controls.scss +3 -2
- package/src/plugins/plugin.autoplay.js +1 -2
- package/src/plugins/plugin.chapters.js +201 -169
- package/src/plugins/search/plugin.search.js +0 -3
- package/src/plugins/tts/plugin.tts.js +1 -1
- package/tests/e2e/base.test.js +3 -11
- package/tests/e2e/helpers/base.js +26 -26
- package/tests/e2e/helpers/rightToLeft.js +4 -4
- package/tests/e2e/helpers/{desktopSearch.js → search.js} +19 -19
- package/tests/e2e/models/Navigation.js +16 -42
- package/tests/e2e/viewmode.test.js +3 -3
- package/tests/jest/plugins/plugin.chapters.test.js +92 -76
- package/tests/jest/plugins/search/plugin.search.view.test.js +0 -1
- package/webpack.config.js +0 -1
- package/BookReader/plugins/plugin.mobile_nav.js +0 -2
- package/BookReader/plugins/plugin.mobile_nav.js.map +0 -1
- package/src/css/_MobileNav.scss +0 -194
- package/src/plugins/plugin.mobile_nav.js +0 -288
- package/tests/e2e/helpers/mobileSearch.js +0 -85
- package/tests/jest/plugins/plugin.mobile_nav.test.js +0 -66
@@ -1,85 +0,0 @@
|
|
1
|
-
import { ClientFunction, RequestMock } from 'testcafe';
|
2
|
-
import { SEARCH_INSIDE_URL_RE , mockResponseFound, mockResponseNotFound,
|
3
|
-
TEST_TEXT_FOUND, TEST_TEXT_NOT_FOUND, PAGE_FIRST_RESULT } from './mockSearch';
|
4
|
-
|
5
|
-
|
6
|
-
export function runMobileSearchTests(br) {
|
7
|
-
//building mock response for successful and unsuccessful search
|
8
|
-
const mockFound = RequestMock()
|
9
|
-
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
10
|
-
.respond(mockResponseFound, 202);
|
11
|
-
|
12
|
-
const mockNotFound = RequestMock()
|
13
|
-
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
14
|
-
.respond(mockResponseNotFound, 202);
|
15
|
-
|
16
|
-
test
|
17
|
-
.requestHooks(mockFound)('Mobile search - successful search', async t => {
|
18
|
-
await t.resizeWindowToFitDevice('Sony Xperia Z', {portraitOrientation: true});
|
19
|
-
const nav = br.nav.mobile;
|
20
|
-
|
21
|
-
//opening side menu and search
|
22
|
-
await t.expect(nav.hamburgerButton.visible).ok();
|
23
|
-
await t.click(nav.hamburgerButton);
|
24
|
-
await t.expect(nav.menuSearchButton.visible).ok();
|
25
|
-
await t.click(nav.menuSearchButton);
|
26
|
-
|
27
|
-
//assuring that the search bar is enabled
|
28
|
-
await t.expect(nav.searchBox.visible).ok();
|
29
|
-
|
30
|
-
//testing successful search
|
31
|
-
await t
|
32
|
-
.selectText(nav.searchBox.find('[name="query"]'))
|
33
|
-
.pressKey('delete');
|
34
|
-
await t
|
35
|
-
.typeText(nav.searchBox.find('[name="query"]'), TEST_TEXT_FOUND)
|
36
|
-
.pressKey('enter');
|
37
|
-
await t.expect(nav.searchResults.visible).ok();
|
38
|
-
await t.expect(nav.searchResultText.exists).ok();
|
39
|
-
await t.expect(nav.searchResultText.innerText).contains(TEST_TEXT_FOUND);
|
40
|
-
|
41
|
-
//checking url
|
42
|
-
const getPageUrl = ClientFunction(() => window.location.href);
|
43
|
-
await t.expect(getPageUrl()).contains(TEST_TEXT_FOUND);
|
44
|
-
|
45
|
-
//checks clicking on first search result opens correct page
|
46
|
-
await t.click(nav.searchResults.child(0));
|
47
|
-
await t.expect(getPageUrl()).contains(PAGE_FIRST_RESULT);
|
48
|
-
|
49
|
-
//checks highlight on result page is visible
|
50
|
-
const highlight = br.shell.find(".searchHiliteLayer rect");
|
51
|
-
await t.expect(highlight.visible).ok();
|
52
|
-
|
53
|
-
await t.maximizeWindow();
|
54
|
-
});
|
55
|
-
|
56
|
-
test
|
57
|
-
.requestHooks(mockNotFound)('Mobile search - unsuccessful search', async t => {
|
58
|
-
await t.resizeWindowToFitDevice('Sony Xperia Z', {portraitOrientation: true});
|
59
|
-
const nav = br.nav.mobile;
|
60
|
-
|
61
|
-
//opening side menu and search
|
62
|
-
await t.expect(nav.hamburgerButton.visible).ok();
|
63
|
-
await t.click(nav.hamburgerButton);
|
64
|
-
await t.expect(nav.menuSearchButton.visible).ok();
|
65
|
-
await t.click(nav.menuSearchButton);
|
66
|
-
|
67
|
-
//assuring that the search bar is enabled
|
68
|
-
await t.expect(nav.searchBox.visible).ok();
|
69
|
-
|
70
|
-
//testing unsuccessful search
|
71
|
-
await t
|
72
|
-
.selectText(nav.searchBox.find('[name="query"]'))
|
73
|
-
.pressKey('delete');
|
74
|
-
await t
|
75
|
-
.typeText(nav.searchBox.find('[name="query"]'), TEST_TEXT_NOT_FOUND)
|
76
|
-
.pressKey('enter');
|
77
|
-
await t.expect(nav.searchResultText.withText(TEST_TEXT_NOT_FOUND).exists).notOk();
|
78
|
-
|
79
|
-
//checking url
|
80
|
-
const getPageUrl = ClientFunction(() => window.location.href.toString());
|
81
|
-
await t.expect(getPageUrl()).contains(TEST_TEXT_NOT_FOUND);
|
82
|
-
await t.maximizeWindow();
|
83
|
-
});
|
84
|
-
|
85
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
|
2
|
-
import BookReader from '@/src/BookReader.js';
|
3
|
-
import '@/src/plugins/plugin.mobile_nav.js';
|
4
|
-
|
5
|
-
/** @type {BookReader} */
|
6
|
-
let br;
|
7
|
-
beforeEach(() => {
|
8
|
-
document.body.innerHTML = '<div id="BookReader">';
|
9
|
-
br = new BookReader();
|
10
|
-
br.init();
|
11
|
-
});
|
12
|
-
|
13
|
-
afterEach(() => {
|
14
|
-
jest.clearAllMocks();
|
15
|
-
});
|
16
|
-
|
17
|
-
describe('Plugin: Mobile Nav', () => {
|
18
|
-
test('has option flag', () => {
|
19
|
-
expect(BookReader.defaultOptions.enableMobileNav).toEqual(true);
|
20
|
-
});
|
21
|
-
test('has added BR property: mobileNavTitle', () => {
|
22
|
-
expect(br).toHaveProperty('mobileNavTitle');
|
23
|
-
expect(br.mobileNavTitle).toBeTruthy();
|
24
|
-
});
|
25
|
-
test('has added BR property: mobileNavFullscreenOnly', () => {
|
26
|
-
expect(br).toHaveProperty('mobileNavFullscreenOnly');
|
27
|
-
expect(br.mobileNavFullscreenOnly).toEqual(false);
|
28
|
-
});
|
29
|
-
test('has a referenced copy of nav in BookReader', () => {
|
30
|
-
expect(br.refs).toHaveProperty('$mmenu');
|
31
|
-
});
|
32
|
-
test('draws toolbar on init', () => {
|
33
|
-
let callCount = 0;
|
34
|
-
// Since we have a custom setter set in utils/classes.js, we can't
|
35
|
-
// use regular spying; need to "override" the function with a watcher.
|
36
|
-
BookReader.prototype.initToolbar = function(_super) {
|
37
|
-
return function() {
|
38
|
-
callCount++;
|
39
|
-
_super.apply(this, arguments);
|
40
|
-
};
|
41
|
-
}(BookReader.prototype.initToolbar);
|
42
|
-
const br = new BookReader();
|
43
|
-
br.init();
|
44
|
-
expect(callCount).toBe(1);
|
45
|
-
});
|
46
|
-
test('sets a class on body to signal it has attached', () => {
|
47
|
-
expect($(document.body).hasClass('BRbodyMobileNavEnabled')).toEqual(true);
|
48
|
-
});
|
49
|
-
test('loads the navbar on init', () => {
|
50
|
-
expect($('#BRmobileMenu')).toHaveLength(1);
|
51
|
-
});
|
52
|
-
test('There is a Settings Section', () => {
|
53
|
-
expect($('.BRmobileMenu__settings')).toHaveLength(1);
|
54
|
-
});
|
55
|
-
test('There is a More Info Section', () => {
|
56
|
-
expect($('.BRmobileMenu__moreInfoRow')).toHaveLength(1);
|
57
|
-
});
|
58
|
-
test('There is a Sharing Section', () => {
|
59
|
-
expect($('.BRmobileMenu__share')).toHaveLength(1);
|
60
|
-
});
|
61
|
-
test('clicking on hamburger opens menu', () => {
|
62
|
-
expect($('html').hasClass('mm-opened')).toEqual(false);
|
63
|
-
$('.BRmobileHamburger').trigger("click");
|
64
|
-
expect($('html').hasClass('mm-opened')).toEqual(true);
|
65
|
-
});
|
66
|
-
});
|