Commit b80201c6 authored by Laurent's avatar Laurent

Decalog OPAC V2 fetch holds, add links to records

parent a7276aa7
......@@ -88,13 +88,20 @@ export class DecalogOpacV2 extends PortalAdapter {
let document = loan_node.find('div[data-title]');
let title = document.attr('data-title');
let author = document.attr('data-author');
let loan_id = loan_node.find('input[name=prolongCheckbox]').attr('data-loanid');
let thumbnail = loan_node.find('.loan-img img').attr('src');
let date_due = loan_node.find('div.loan-info p + p').text().replace(/[^0-9\-]+/, '').trim();
let record_url = loan_node.find('.loan-book a').attr('href');
let record_id = record_url.split('?id=')[1];
loans.push(new Loan()
.setTitle(title)
.setAuthor(author)
.setDateDue(date_due.split('-').reverse().join('-')));
.setTitle(title)
.setAuthor(author)
.setDateDue(date_due.split('-').reverse().join('-'))
.setLoanId(loan_id)
.setRecordThumbnail(thumbnail)
.setRecordId(record_id)
.setRecordUrl(record_url));
});
return loans;
......@@ -115,10 +122,21 @@ export class DecalogOpacV2 extends PortalAdapter {
let document = hold_node.find('div[data-title]');
let title = document.attr('data-title');
let author = document.attr('data-author');
let status = hold_node.find('.loan-info p').text().trim();
let hold_id = hold_node.find('input[name=cancelCheckbox]').attr('data-bookingid');
let thumbnail = hold_node.find('.loan-img img').attr('src');
let record_url = hold_node.find('.loan-book a').attr('href');
let record_id = record_url.split('?id=')[1];
holds.push(new Hold()
.setTitle(title)
.setAuthor(author));
.setHoldId(hold_id)
.setTitle(title)
.setAuthor(author)
.setStatus(status)
.setRecordThumbnail(thumbnail)
.setRecordId(record_id)
.setRecordUrl(record_url)
);
});
return holds;
......
......@@ -63,10 +63,10 @@ export class DecalogOpacV2WithSuccessfulLogin extends HTTPScenario {
"Mariachi Plaza [enregistrement sonore]" data-publisheddate="2016" data-author=\
"Michael Connelly" data-type="Musique et son"><img class=\
"pull-left hidden-xs hidden-sm" src=\
"http://reseaudmonts.bibenligne.fr/vendors/decalog/opac/icon/default.svg"></div>\
"http://decopac.fr/vendors/decalog/opac/icon/default.svg"></div>\
<div class="loan-book">\
<p><a href=\
"http://reseaudmonts.bibenligne.fr/opac/catalog/bibrecord?id=7446959634132077903">\
"http://decopac.fr/opac/catalog/bibrecord?id=7446959634132077903">\
Mariachi Plaza [enregistrement sonore]</a> par Michael\
Connelly</p><small>Publié par Audiolib, 2016</small>\
</div>\
......@@ -95,10 +95,10 @@ export class DecalogOpacV2WithSuccessfulLogin extends HTTPScenario {
"Conquérants de Troy (Les) T. 2. Eckmül le bucheron"\
data-publisheddate="2008" data-author="Ciro Tota" data-type="Texte"><img class=\
"pull-left hidden-xs hidden-sm" src=\
"http://reseaudmonts.bibenligne.fr/vendors/decalog/opac/icon/default.svg"></div>\
"http://decopac.fr/vendors/decalog/opac/icon/default.svg"></div>\
<div class="loan-book">\
<p><a href=\
"http://reseaudmonts.bibenligne.fr/opac/catalog/bibrecord?id=7240711406263836785">\
"http://decopac.fr/opac/catalog/bibrecord?id=7240711406263836785">\
Conquérants de Troy (Les) T. 2. Eckmül le bucheron</a> par Ciro\
Tota</p><small>Publié par Soleil, 2008</small>\
</div>\
......@@ -127,10 +127,10 @@ export class DecalogOpacV2WithSuccessfulLogin extends HTTPScenario {
<div id="booking-node-4134328203189283792" class="panel panel-default panel-card"> \
<div class="panel-body loan">\
<div class="loan-img hidden-xs hidden-sm" id="dkConnectImg9782302012516" name="dkConnectImg" data-ean="9782302012516" data-title="Lanfeust Odyssey (2) : Lanfeust odyssey. 2, L\'énigme Or-Azur, seconde partie" data-publisheddate="2010" data-author="Christophe Arleston, Didier Tarquin" data-type="Texte">\
<img class="pull-left hidden-xs hidden-sm" src="http://reseaudmonts.bibenligne.fr/vendors/decalog/opac/icon/default.svg">\
<img class="pull-left hidden-xs hidden-sm" src="http://decopac.fr/vendors/decalog/opac/icon/default.svg">\
</div>\
<div class="loan-book">\
<p><a href="http://reseaudmonts.bibenligne.fr/opac/catalog/bibrecord?id=681156372250376446">Lanfeust Odyssey (2) : Lanfeust odyssey. 2, L\'énigme Or-Azur, seconde partie</a> par Christophe Arleston, Didier Tarquin</p>\
<p><a href="http://decopac.fr/opac/catalog/bibrecord?id=681156372250376446">Lanfeust Odyssey (2) : Lanfeust odyssey. 2, L\'énigme Or-Azur, seconde partie</a> par Christophe Arleston, Didier Tarquin</p>\
<small>Publié par Soleil, 2010</small> </div>\
<div class="loan-info">\
<p>Réservé le 05-06-2018 chez <b>St Clément les Places - Bibliothèque</b></p>\
......
declare var describe, expect, it, before, beforeEach, chai: any;
import {Loan, Account, Database, WrongLoginPassword} from '../../models/';
import {Loan, Hold, Account, Database, WrongLoginPassword} from '../../models/';
import {DecalogOpacV2} from '../../models/portal/decalog-opac-v2';
import {DecalogOpacV2WithSuccessfulLogin, DecalogOpacV2WithLoginError} from './decalog-opac-v2-fixtures';
......@@ -33,7 +33,7 @@ describe('Account on DecalogOpacV2', () => {
describe('With successful Login scenario', () => {
it('db should have three loans', () => {
it('db should have three loans and one hold', () => {
let http = new DecalogOpacV2WithSuccessfulLogin('http://decopac.fr');
return adapter.setHTTP(http).refresh(account).then(() => {
let loans = db.findAll(Loan).sort((a, b) => {
......@@ -43,8 +43,21 @@ describe('Account on DecalogOpacV2', () => {
expect(loans).to.have.lengthOf(2);
expect(loans[0].getTitle()).to.contains('Mariachi Plaza [enregistrement sonore]');
expect(loans[0].getDateDue()).to.equals('2018-05-27');
expect(loans[1].getAuthor()).to.equals('Ciro Tota');
expect(loans[0].getLoanId()).to.equals('4715235069142336121');
expect(loans[0].getRecordThumbnail()).to.equals('http://decopac.fr/vendors/decalog/opac/icon/default.svg');
expect(loans[0].getRecordId()).to.equals('7446959634132077903');
expect(loans[0].getRecordUrl()).to.equals('http://decopac.fr/opac/catalog/bibrecord?id=7446959634132077903');
expect(loans[1].getAuthor()).to.equals('Ciro Tota');
let holds = db.findAll(Hold);
expect(holds).to.have.lengthOf(1);
expect(holds[0].getTitle()).to.equals('Lanfeust Odyssey (2) : Lanfeust odyssey. 2, L\'énigme Or-Azur, seconde partie');
expect(holds[0].getAuthor()).to.equals('Christophe Arleston, Didier Tarquin');
expect(holds[0].getStatus()).to.equals('Réservé le 05-06-2018 chez St Clément les Places - Bibliothèque');
expect(holds[0].getHoldId()).to.equals('4134328203189283792');
expect(holds[0].getRecordThumbnail()).to.equals('http://decopac.fr/vendors/decalog/opac/icon/default.svg');
expect(holds[0].getRecordUrl()).to.equals('http://decopac.fr/opac/catalog/bibrecord?id=681156372250376446');
expect(holds[0].getRecordId()).to.equals('681156372250376446');
});
});
});
......
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