@internetarchive/ia-book-actions 0.0.22-3 → 0.0.23

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.22-3",
3
+ "version": "0.0.23",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -20,9 +20,9 @@
20
20
  "dependencies": {
21
21
  "@internetarchive/icon-info": "^1.2.6",
22
22
  "@internetarchive/local-cache": "^0.2.0",
23
- "@internetarchive/modal-manager": "^0.2.2",
23
+ "@internetarchive/modal-manager": "^0.2.1",
24
24
  "@internetarchive/shared-resize-observer": "^0.2.0",
25
- "lit": "^2.2.2"
25
+ "lit": "^2.2.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@open-wc/eslint-config": "^4.2.0",
@@ -86,6 +86,7 @@ export class GetLendingActions {
86
86
  primaryTitle: '',
87
87
  primaryActions: [],
88
88
  secondaryActions: [this.actionsConfig.adminOrPrintDisabledExitConfig()],
89
+ borrowType: 'adminBorrowed',
89
90
  };
90
91
  }
91
92
 
@@ -46,9 +46,14 @@ export class LoanTokenPoller {
46
46
  // Do an initial token, then set an interval
47
47
  this.handleLoanTokenPoller(true);
48
48
 
49
- this.loanTokenInterval = setInterval(() => {
50
- this.handleLoanTokenPoller();
51
- }, this.pollerDelay);
49
+ // if this.borrowType = adminBorrowed,
50
+ // - we don't want to fetch token on interval
51
+ // - the initial token is enough to set cookies for reading book and readaloud features
52
+ if (this.borrowType !== 'adminBorrowed') {
53
+ this.loanTokenInterval = setInterval(() => {
54
+ this.handleLoanTokenPoller();
55
+ }, this.pollerDelay);
56
+ }
52
57
 
53
58
  // event category and action for browsing book access
54
59
  const category = `${this.borrowType}BookAccess`;
@@ -6,9 +6,6 @@ import { LoanTokenPoller } from '../../../src/core/services/loan-token-poller.js
6
6
 
7
7
  describe('Get Loan Token', () => {
8
8
  it('get loan token for browsed books', async () => {
9
- // const localCacheStub = new LocalCache();
10
- // const localCacheGetSpy = Sinon.spy(localCacheStub, 'get');
11
-
12
9
  const tokenPoller = new LoanTokenPoller(
13
10
  'identifier1',
14
11
  'browsed',
@@ -24,17 +21,26 @@ describe('Get Loan Token', () => {
24
21
  successCallbackSpy();
25
22
  expect(successCallbackSpy.callCount).to.equal(1);
26
23
 
27
- // localCacheGetSpy();
28
- // expect(localCacheGetSpy.callCount).to.equal(1);
29
-
30
- // expect(tokenPoller.localCache.namespace).to.equal('LocalCache');
31
- // expect(tokenPoller.localCache.get).to.be.a('function');
32
-
33
- // tokenPoller.disconnectedInterval(); // clear token poller interval
34
- // expect(tokenPoller.loanTokenInterval).to.equal(undefined);
35
-
36
24
  tokenPoller.handleLoanTokenPoller(true);
37
25
  expect(tokenPoller.errorCallback).to.be.a('function');
38
26
  expect(tokenPoller.successCallback).have;
39
27
  });
28
+
29
+ it('get loan token for admin borrowed books', async () => {
30
+ const tokenPoller = new LoanTokenPoller(
31
+ 'identifier1',
32
+ 'adminBorrowed',
33
+ () => {},
34
+ () => {},
35
+ 2000 // 2 minutes'
36
+ );
37
+
38
+ const successCallbackSpy = Sinon.stub(tokenPoller, 'successCallback');
39
+ successCallbackSpy();
40
+ expect(successCallbackSpy.callCount).to.equal(1);
41
+
42
+ // for adminBorrowed,
43
+ // - not initialize loanTokenInterval as don't need to fetch loan after specific interval
44
+ expect(tokenPoller.loanTokenInterval).to.equal(undefined);
45
+ });
40
46
  });