Commit a7276aa7 authored by Laurent's avatar Laurent

Decalog-OPAC V2: fetch holds

parent 1030fdcf
import {PortalAdapter} from './adapter';
import * as cheerio from 'cheerio';
import {Account, Loan} from '../../models';
import {Account, Loan, Hold} from '../../models';
import {WrongLoginPassword} from './wrong-login-password';
export class DecalogOpacV2 extends PortalAdapter {
......@@ -80,16 +80,16 @@ export class DecalogOpacV2 extends PortalAdapter {
._requestProfilePage(account)
.then( ($) => {
let datas = $('div.loan-wrapper');
let datas = $('.loans-content .loan-wrapper');
let loans: Array<Loan> = new Array<Loan>();
datas.each((i, elem) => {
let loanNode = $(elem);
let document = loanNode.find('div[data-title]');
let loan_node = $(elem);
let document = loan_node.find('div[data-title]');
let title = document.attr('data-title');
let author = document.attr('data-author');
let date_due = loanNode.find('div.loan-info p + p').text().replace(/[^0-9\-]+/, '').trim();
let date_due = loan_node.find('div.loan-info p + p').text().replace(/[^0-9\-]+/, '').trim();
loans.push(new Loan()
.setTitle(title)
......@@ -100,4 +100,28 @@ export class DecalogOpacV2 extends PortalAdapter {
return loans;
});
}
protected _fetchHolds(account:Account): Promise<Array<Hold>> {
return this
._requestProfilePage(account)
.then( ($) => {
let datas = $('#booking .loan-wrapper');
let holds: Array<Hold> = new Array<Hold>();
datas.each((i, elem) => {
let hold_node = $(elem);
let document = hold_node.find('div[data-title]');
let title = document.attr('data-title');
let author = document.attr('data-author');
holds.push(new Hold()
.setTitle(title)
.setAuthor(author));
});
return holds;
});
}
}
......@@ -58,8 +58,8 @@ describe('AccountsController with one account in database', () => {
})
it('form selectedPortalIndex should be seven', () => {
expect(account_form.get('selectedPortalIndex')).to.equal(7);
it('form selectedPortalIndex should be height', () => {
expect(account_form.get('selectedPortalIndex')).to.equal(8);
})
......
......@@ -14,6 +14,9 @@ export class DecalogOpacV2WithSuccessfulLogin extends HTTPScenario {
{ content: this.frontPageConnected() })
.then({ url: base_url + '/opac/user/profile' },
{ content: this.accountPage() })
.then({ url: base_url + '/opac/user/profile' },
{ content: this.accountPage() });
}
......@@ -114,7 +117,31 @@ export class DecalogOpacV2WithSuccessfulLogin extends HTTPScenario {
</div>\
</div>\
</div>\
</div>');
</div>\
<div role="tabpanel" class="tab-pane fade active in" id="booking">\
<a href="#bookings-available-link" id="bookings-available-link" class="pull-right">Voir les réservations disponibles</a>\
<a href="#bookings-link" id="bookings-link" class="font-bold">Réservations</a>\
<p></p>\
<div class="loan-wrapper booking-not-available">\
<input data-bookingid="4134328203189283792" id="cancelCheckbox4134328203189283792" name="cancelCheckbox" class="loan-extendable hidden" type="checkbox">\
<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">\
</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>\
<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>\
</div>\
<div class="loan-actions">\
<button name="bookingCancel" class="btn btn-primary" id="cancel4134328203189283792" data-bookingid="4134328203189283792">Supprimer la réservation</button>\
</div>\
</div>\
</div>\
</div> \
</div>');
}
}
......
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