@internetarchive/ia-book-actions 0.0.12-1 → 0.0.13-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/ia-book-actions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-1",
|
|
4
4
|
"description": "Bookreader actions for borrowable book",
|
|
5
5
|
"author": "Internet Archive",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore",
|
|
16
16
|
"test": "yarn run lint && web-test-runner --coverage",
|
|
17
17
|
"test:fast": "web-test-runner --coverage",
|
|
18
|
-
"test:watch": "web-test-runner --watch"
|
|
18
|
+
"test:watch": "web-test-runner --watch --puppeteer"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@internetarchive/ia-icons": "^1.2.2",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@internetarchive/local-cache": "^0.2.0",
|
|
26
26
|
"@internetarchive/modal-manager": "^0.1.0",
|
|
27
27
|
"@internetarchive/shared-resize-observer": "^0.0.1",
|
|
28
|
+
"@web/test-runner-puppeteer": "^0.10.5",
|
|
28
29
|
"lit-element": "^2.4.0",
|
|
29
30
|
"lit-html": "^1.3.0"
|
|
30
31
|
},
|
|
@@ -40,6 +40,7 @@ export class LoanTokenPoller {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Do an initial token, then set an interval
|
|
43
|
+
console.log('enableBookAccess => handleLoanTokenPoller');
|
|
43
44
|
this.handleLoanTokenPoller(true);
|
|
44
45
|
|
|
45
46
|
this.loanTokenInterval = setInterval(() => {
|
|
@@ -70,6 +71,7 @@ export class LoanTokenPoller {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
async handleLoanTokenPoller(isInitial = false) {
|
|
74
|
+
console.log('handleLoanTokenPoller', {isInitial})
|
|
73
75
|
const action = 'create_token';
|
|
74
76
|
ActionsHandlerService({
|
|
75
77
|
identifier: this.identifier,
|
package/src/ia-book-actions.js
CHANGED
|
@@ -156,6 +156,16 @@ export default class IABookActions extends LitElement {
|
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
this.borrowType = actions.borrowType;
|
|
159
|
+
|
|
160
|
+
const hasExpired =
|
|
161
|
+
'browsingExpired' in this.lendingStatus &&
|
|
162
|
+
this.lendingStatus?.browsingExpired;
|
|
163
|
+
console.log('***hasExpired', hasExpired);
|
|
164
|
+
if (hasExpired) {
|
|
165
|
+
this.tokenPoller?.disconnectedInterval();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
if (this.borrowType === 'browsed') {
|
|
160
170
|
// start timer for browsed.
|
|
161
171
|
// when browse is completed, we shows browse-again button
|
|
@@ -308,6 +318,7 @@ export default class IABookActions extends LitElement {
|
|
|
308
318
|
title: 'Lending error',
|
|
309
319
|
message: errorMsg,
|
|
310
320
|
headerColor: '#d9534f',
|
|
321
|
+
showCloseButton: true,
|
|
311
322
|
});
|
|
312
323
|
|
|
313
324
|
if (action === 'create_token') {
|
|
@@ -318,8 +329,6 @@ export default class IABookActions extends LitElement {
|
|
|
318
329
|
refresh
|
|
319
330
|
</button>`;
|
|
320
331
|
|
|
321
|
-
modalConfig.closeOnBackdropClick = false;
|
|
322
|
-
modalConfig.showCloseButton = false;
|
|
323
332
|
modalConfig.message = html` Uh oh, something went wrong trying to access
|
|
324
333
|
this book.<br />
|
|
325
334
|
Please ${refreshButton} to try again or send us an email to
|
|
@@ -251,10 +251,41 @@ describe('Browsing expired status', () => {
|
|
|
251
251
|
);
|
|
252
252
|
|
|
253
253
|
await aTimeout(1500); // wait for 1.5 second
|
|
254
|
-
el.updateComplete;
|
|
254
|
+
await el.updateComplete;
|
|
255
|
+
|
|
256
|
+
expect(el.primaryTitle).contains('Your loan has expired.');
|
|
257
|
+
expect(el.primaryActions[0].text).to.equal('Borrow again');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('Expiring book cancels interval', async () => {
|
|
261
|
+
const baseStatus = {
|
|
262
|
+
is_lendable: true,
|
|
263
|
+
user_has_browsed: false,
|
|
264
|
+
browseHasExpired: false,
|
|
265
|
+
secondsLeftOnLoan: 1,
|
|
266
|
+
};
|
|
267
|
+
const el = await fixture(
|
|
268
|
+
container({
|
|
269
|
+
userid: '@userid',
|
|
270
|
+
lendingStatus: baseStatus,
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
const browsingStatus = { ...baseStatus, user_has_browsed: true };
|
|
274
|
+
el.lendingStatus = browsingStatus;
|
|
275
|
+
await el.updateComplete;
|
|
276
|
+
|
|
277
|
+
expect(el.primaryTitle).contains('Borrow ends at ');
|
|
278
|
+
expect(el.primaryActions[0].text).to.equal('Return now');
|
|
279
|
+
expect(el.tokenPoller.loanTokenInterval).to.not.equal(undefined);
|
|
280
|
+
|
|
281
|
+
const expiredStatus = { ...browsingStatus, browsingExpired: true };
|
|
282
|
+
el.lendingStatus = expiredStatus;
|
|
283
|
+
await el.updateComplete;
|
|
284
|
+
await aTimeout(1500); // wait for 1.5 sec
|
|
255
285
|
|
|
256
286
|
expect(el.primaryTitle).contains('Your loan has expired.');
|
|
257
287
|
expect(el.primaryActions[0].text).to.equal('Borrow again');
|
|
288
|
+
expect(el.tokenPoller.loanTokenInterval).to.equal(undefined);
|
|
258
289
|
});
|
|
259
290
|
});
|
|
260
291
|
|