Commit 61f238ea authored by Robert Knight's avatar Robert Knight

Always capture EPUBContentSelector, PageSelector in VitalSource books

In preparation for enabling the `book_as_single_document` feature for everyone,
enable capturing the EPUBContentSelector selector whether the feature flag is
enabled or not.

Once this is released, all new VS annotations will have all the data they will
need after they are migrated to the new format [1] and only the annotation URL
will need to be changed. This will leave us with only a fixed set of older
annotations for which we will need to obtain the missing CFI and chapter title
data.

[1] See https://github.com/hypothesis/h/issues/7709
parent 2448bc52
......@@ -360,63 +360,53 @@ describe('annotator/integrations/vitalsource', () => {
assert.calledWith(fakeHTMLIntegration.scrollToAnchor, anchor);
});
context('when "book_as_single_document" flag is on', () => {
beforeEach(() => {
featureFlags.update({ book_as_single_document: true });
});
it('adds selector for current EPUB book Content Document', async () => {
const integration = createIntegration();
integration.contentContainer();
assert.calledWith(fakeHTMLIntegration.contentContainer);
const range = new Range();
const selectors = await integration.describe(range);
it('adds selector for current EPUB book Content Document', async () => {
const integration = createIntegration();
integration.contentContainer();
assert.calledWith(fakeHTMLIntegration.contentContainer);
const cfiSelector = selectors.find(
s => s.type === 'EPUBContentSelector'
);
const range = new Range();
const selectors = await integration.describe(range);
assert.ok(cfiSelector);
assert.deepEqual(cfiSelector, {
type: 'EPUBContentSelector',
url: resolveURL('/pages/chapter_02.xhtml'),
cfi: '/2',
title: 'Chapter two (from TOC)',
});
const cfiSelector = selectors.find(s => s.type === 'EPUBContentSelector');
const pageSelector = selectors.find(s => s.type === 'PageSelector');
assert.notOk(pageSelector);
assert.ok(cfiSelector);
assert.deepEqual(cfiSelector, {
type: 'EPUBContentSelector',
url: resolveURL('/pages/chapter_02.xhtml'),
cfi: '/2',
title: 'Chapter two (from TOC)',
});
it('adds selector for current PDF book page', async () => {
fakeBookElement.selectPDFBook();
const pageSelector = selectors.find(s => s.type === 'PageSelector');
assert.notOk(pageSelector);
});
const integration = createIntegration();
integration.contentContainer();
assert.calledWith(fakeHTMLIntegration.contentContainer);
it('adds selector for current PDF book page', async () => {
fakeBookElement.selectPDFBook();
const range = new Range();
const selectors = await integration.describe(range);
const cfiSelector = selectors.find(
s => s.type === 'EPUBContentSelector'
);
const integration = createIntegration();
integration.contentContainer();
assert.calledWith(fakeHTMLIntegration.contentContainer);
assert.ok(cfiSelector);
assert.deepEqual(cfiSelector, {
type: 'EPUBContentSelector',
url: resolveURL('/pages/2'),
cfi: '/1',
title: 'First chapter',
});
const range = new Range();
const selectors = await integration.describe(range);
const cfiSelector = selectors.find(s => s.type === 'EPUBContentSelector');
assert.ok(cfiSelector);
assert.deepEqual(cfiSelector, {
type: 'EPUBContentSelector',
url: resolveURL('/pages/2'),
cfi: '/1',
title: 'First chapter',
});
const pageSelector = selectors.find(s => s.type === 'PageSelector');
assert.ok(pageSelector);
assert.deepEqual(pageSelector, {
type: 'PageSelector',
index: 1,
label: '2',
});
const pageSelector = selectors.find(s => s.type === 'PageSelector');
assert.ok(pageSelector);
assert.deepEqual(pageSelector, {
type: 'PageSelector',
index: 1,
label: '2',
});
});
......
......@@ -320,9 +320,6 @@ export class VitalSourceContentIntegration
async describe(root: HTMLElement, range: Range) {
const selectors: Selector[] = this._htmlIntegration.describe(root, range);
if (!this._bookIsSingleDocument()) {
return selectors;
}
const {
cfi,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment