Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/deposit-admin.spec.js
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | responseDeposits = [ | ||||
'id': 614, | 'id': 614, | ||||
'type': 'code', | 'type': 'code', | ||||
'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, | ||||
'swhid': 'swh:1:dir:ef04a768', | 'swhid': 'swh:1:dir:ef04a768', | ||||
'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=/', | '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=/', | ||||
'raw_metadata': '<foo>bar</foo>', | |||||
'uri': 'https://w.s.o/c-d-1' | 'uri': 'https://w.s.o/c-d-1' | ||||
}, | }, | ||||
{ | { | ||||
'id': 613, | 'id': 613, | ||||
'type': 'code', | 'type': 'code', | ||||
'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, | ||||
'swhid': 'swh:1:dir:181417fb', | 'swhid': 'swh:1:dir:181417fb', | ||||
'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=/', | '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=/', | ||||
'raw_metadata': null, | |||||
'uri': 'https://w.s.o/c-d-2' | 'uri': 'https://w.s.o/c-d-2' | ||||
}, | }, | ||||
{ | { | ||||
'id': 612, | 'id': 612, | ||||
'type': 'code', | 'type': 'code', | ||||
'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!', | ||||
'swhid': null, | 'swhid': null, | ||||
'swhid_context': null, | 'swhid_context': null, | ||||
'raw_metadata': null, | |||||
'uri': null | 'uri': 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: '' | ||||
}; | }; | ||||
}); | }); | ||||
it('Should display properly entries', function() { | it('Should properly display entries', function() { | ||||
cy.adminLogin(); | cy.adminLogin(); | ||||
const testDeposits = responseDeposits; | const testDeposits = responseDeposits; | ||||
cy.intercept(`${depositListUrl}**`, { | cy.intercept(`${depositListUrl}**`, { | ||||
body: { | body: { | ||||
'draw': 10, | 'draw': 10, | ||||
'recordsTotal': testDeposits.length, | 'recordsTotal': testDeposits.length, | ||||
'recordsFiltered': testDeposits.length, | 'recordsFiltered': testDeposits.length, | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | cy.wait('@listDeposits').then((xhr) => { | ||||
cy.contains(deposit.status_detail).should('not.exist'); | cy.contains(deposit.status_detail).should('not.exist'); | ||||
} | } | ||||
// those are hidden by default | // those are hidden by default | ||||
if (deposit.swhid !== null) { | if (deposit.swhid !== null) { | ||||
cy.contains(deposit.swhid).should('not.exist'); | cy.contains(deposit.swhid).should('not.exist'); | ||||
cy.contains(deposit.swhid_context).should('not.exist'); | cy.contains(deposit.swhid_context).should('not.exist'); | ||||
} | } | ||||
if (deposit.raw_metadata !== null) { | |||||
cy.get('button.metadata', {withinSubject: row}) | |||||
.should('exist') | |||||
.click({force: true}); | |||||
cy.get('#swh-web-modal-html code.xml').should('be.visible'); | |||||
anlambert: It looks like there is a race condition between the cypress test runner and the javascript code… | |||||
Done Inline Actionsah, good catch. Waiting for the close button to appear seems to be good enough. vlorentz: ah, good catch. Waiting for the close button to appear seems to be good enough. | |||||
// Dismiss the modal | |||||
cy.get('body').wait(500).type('{esc}'); | |||||
cy.get('#swh-web-modal-html code.xml').should('not.be.visible'); | |||||
} else { | |||||
cy.get('button.metadata', {withinSubject: row}).should('not.exist'); | |||||
cy.get('#swh-web-modal-html code.xml').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) => { | ||||
const deposit = deposits[idx]; | const deposit = deposits[idx]; | ||||
const expectedOrigin = expectedOrigins[deposit.id]; | const expectedOrigin = expectedOrigins[deposit.id]; | ||||
// ensure it's in the dom | // ensure it's in the dom | ||||
cy.contains(deposit.id).should('not.exist'); | expect(row).to.not.contain(deposit.id); | ||||
if (deposit.status !== 'rejected') { | if (deposit.status !== 'rejected') { | ||||
expect(row).to.not.contain(deposit.external_id); | expect(row).to.not.contain(deposit.external_id); | ||||
expect(row).to.contain(expectedOrigin); | expect(row).to.contain(expectedOrigin); | ||||
} | } | ||||
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) { | ||||
Show All 22 Lines |
It looks like there is a race condition between the cypress test runner and the javascript code of swh-web.
So when you hit the escape key, the key press event handlers have not been set yet for the modal and thus nothing happens.
A workaround is to wait a little bit before typing: cy.get('body').wait(500).type('{esc}').