Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/deposit-admin.spec.js
Show All 12 Lines | describe('Test admin deposit page', function() { | ||||
beforeEach(() => { | beforeEach(() => { | ||||
responseDeposits = [ | responseDeposits = [ | ||||
{ | { | ||||
'id': 614, | 'id': 614, | ||||
'external_id': 'ch-de-1', | 'external_id': 'ch-de-1', | ||||
'reception_date': '2020-05-18T13:48:27Z', | 'reception_date': '2020-05-18T13:48:27Z', | ||||
'status': 'done', | 'status': 'done', | ||||
'status_detail': null, | 'status_detail': null, | ||||
'swh_id': 'swh:1:dir:ef04a768', | 'swhid': 'swh:1:dir:ef04a768', | ||||
'swh_id_context': 'swh:1:dir:ef04a768;origin=https://w.s.o/c-d-1;visit=swh:1:snp:b234be1e;anchor=swh:1:rev:d24a75c9;path=/' | 'swhid_context': 'swh:1:dir:ef04a768;origin=https://w.s.o/c-d-1;visit=swh:1:snp:b234be1e;anchor=swh:1:rev:d24a75c9;path=/' | ||||
}, | }, | ||||
{ | { | ||||
'id': 613, | 'id': 613, | ||||
'external_id': 'ch-de-2', | 'external_id': 'ch-de-2', | ||||
'reception_date': '2020-05-18T11:20:16Z', | 'reception_date': '2020-05-18T11:20:16Z', | ||||
'status': 'done', | 'status': 'done', | ||||
'status_detail': null, | 'status_detail': null, | ||||
'swh_id': 'swh:1:dir:181417fb', | 'swhid': 'swh:1:dir:181417fb', | ||||
'swh_id_context': 'swh:1:dir:181417fb;origin=https://w.s.o/c-d-2;visit=swh:1:snp:8c32a2ef;anchor=swh:1:rev:3d1eba04;path=/' | 'swhid_context': 'swh:1:dir:181417fb;origin=https://w.s.o/c-d-2;visit=swh:1:snp:8c32a2ef;anchor=swh:1:rev:3d1eba04;path=/' | ||||
}, | }, | ||||
{ | { | ||||
'id': 612, | 'id': 612, | ||||
'external_id': 'ch-de-3', | 'external_id': 'ch-de-3', | ||||
'reception_date': '2020-05-18T11:20:16Z', | 'reception_date': '2020-05-18T11:20:16Z', | ||||
'status': 'rejected', | 'status': 'rejected', | ||||
'status_detail': 'incomplete deposit!', | 'status_detail': 'incomplete deposit!', | ||||
'swh_id': null, | 'swhid': null, | ||||
'swh_id_context': null | 'swhid_context': null | ||||
} | } | ||||
]; | ]; | ||||
// those are computed from the | // those are computed from the | ||||
expectedOrigins = { | expectedOrigins = { | ||||
614: 'https://w.s.o/c-d-1', | 614: 'https://w.s.o/c-d-1', | ||||
613: 'https://w.s.o/c-d-2', | 613: 'https://w.s.o/c-d-2', | ||||
612: '' | 612: '' | ||||
}; | }; | ||||
Show All 39 Lines | cy.wait('@listDeposits').then((xhr) => { | ||||
let deposit = deposits[idx]; | let deposit = deposits[idx]; | ||||
let responseDeposit = testDeposits[idx]; | let responseDeposit = testDeposits[idx]; | ||||
assert.isNotNull(deposit); | assert.isNotNull(deposit); | ||||
assert.isNotNull(responseDeposit); | assert.isNotNull(responseDeposit); | ||||
expect(deposit.id).to.be.equal(responseDeposit['id']); | expect(deposit.id).to.be.equal(responseDeposit['id']); | ||||
expect(deposit.external_id).to.be.equal(responseDeposit['external_id']); | expect(deposit.external_id).to.be.equal(responseDeposit['external_id']); | ||||
expect(deposit.status).to.be.equal(responseDeposit['status']); | expect(deposit.status).to.be.equal(responseDeposit['status']); | ||||
expect(deposit.status_detail).to.be.equal(responseDeposit['status_detail']); | expect(deposit.status_detail).to.be.equal(responseDeposit['status_detail']); | ||||
expect(deposit.swh_id).to.be.equal(responseDeposit['swh_id']); | expect(deposit.swhid).to.be.equal(responseDeposit['swhid']); | ||||
expect(deposit.swh_id_context).to.be.equal(responseDeposit['swh_id_context']); | expect(deposit.swhid_context).to.be.equal(responseDeposit['swhid_context']); | ||||
let expectedOrigin = expectedOrigins[deposit.id]; | let expectedOrigin = expectedOrigins[deposit.id]; | ||||
// ensure it's in the dom | // ensure it's in the dom | ||||
cy.contains(deposit.id).should('be.visible'); | cy.contains(deposit.id).should('be.visible'); | ||||
if (deposit.status !== 'rejected') { | if (deposit.status !== 'rejected') { | ||||
expect(row).to.not.contain(deposit.external_id); | expect(row).to.not.contain(deposit.external_id); | ||||
cy.contains(expectedOrigin).should('be.visible'); | cy.contains(expectedOrigin).should('be.visible'); | ||||
} | } | ||||
cy.contains(deposit.status).should('be.visible'); | cy.contains(deposit.status).should('be.visible'); | ||||
// those are hidden by default, so now visible | // those are hidden by default, so now visible | ||||
if (deposit.status_detail !== null) { | if (deposit.status_detail !== null) { | ||||
cy.contains(deposit.status_detail).should('not.be.visible'); | cy.contains(deposit.status_detail).should('not.be.visible'); | ||||
} | } | ||||
// those are hidden by default | // those are hidden by default | ||||
if (deposit.swh_id !== null) { | if (deposit.swhid !== null) { | ||||
cy.contains(deposit.swh_id).should('not.be.visible'); | cy.contains(deposit.swhid).should('not.be.visible'); | ||||
cy.contains(deposit.swh_id_context).should('not.be.visible'); | cy.contains(deposit.swhid_context).should('not.be.visible'); | ||||
} | } | ||||
}); | }); | ||||
// toggling all links and ensure, the previous checks are inverted | // toggling all links and ensure, the previous checks are inverted | ||||
cy.get('a.toggle-col').click({'multiple': true}).then(() => { | cy.get('a.toggle-col').click({'multiple': true}).then(() => { | ||||
cy.get('#swh-admin-deposit-list').find('tbody > tr').as('rows'); | cy.get('#swh-admin-deposit-list').find('tbody > tr').as('rows'); | ||||
cy.get('@rows').each((row, idx, collection) => { | cy.get('@rows').each((row, idx, collection) => { | ||||
Show All 9 Lines | cy.wait('@listDeposits').then((xhr) => { | ||||
expect(row).to.not.contain(deposit.status); | expect(row).to.not.contain(deposit.status); | ||||
// those are hidden by default, so now visible | // those are hidden by default, so now visible | ||||
if (deposit.status_detail !== null) { | if (deposit.status_detail !== null) { | ||||
cy.contains(deposit.status_detail).should('be.visible'); | cy.contains(deposit.status_detail).should('be.visible'); | ||||
} | } | ||||
// those are hidden by default, so now they should be visible | // those are hidden by default, so now they should be visible | ||||
if (deposit.swh_id !== null) { | if (deposit.swhid !== null) { | ||||
cy.contains(deposit.swh_id).should('be.visible'); | cy.contains(deposit.swhid).should('be.visible'); | ||||
cy.contains(deposit.swh_id_context).should('be.visible'); | cy.contains(deposit.swhid_context).should('be.visible'); | ||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
cy.get('#swh-admin-deposit-list-error') | cy.get('#swh-admin-deposit-list-error') | ||||
.should('not.contain', | .should('not.contain', | ||||
'An error occurred while retrieving the list of deposits'); | 'An error occurred while retrieving the list of deposits'); | ||||
}); | }); | ||||
}); | }); | ||||
}); | }); |