Skip to content

Commit

Permalink
add middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Valiulin committed Dec 18, 2024
1 parent ea7317b commit 577bb06
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,35 @@ context('When saving after deleting a frame, job metadata is inconsistent.', ()

describe(`Testing issue ${issueId}`, () => {
it('Crash on Save job. Save again.', () => {
cy.deleteFrame(); // FIXME: does normal saving with 200, better to just push a button
// cy.deleteFrame(); // FIXME: does normal saving with 200, better to just push a button
function clickDelete() {
cy.get('.cvat-player-delete-frame').click();
cy.get('.cvat-modal-delete-frame').within(() => {
cy.contains('button', 'Delete').click();
});
}
function clickSave() {
cy.get('button').contains('Save').click({ force: true });
cy.get('button').contains('Save').trigger('mouseout');
}
function middleware(request, response) {
let calls = 0;
const responseStub = { statusCode: 502, body: 'Network error' };
function handle(req, res) {
if (calls === 0) {
calls++;
res.send(responseStub);
} else {
req.continue();
}
}
handle(request, response);
}
cy.intercept('PATCH', '/api/jobs/**/data/meta**', middleware);
clickDelete();
clickSave();

cy.wait('@patchMeta');

// Check that frame is deleted
cy.contains('button', 'Restore').should('be.visible');
Expand Down

0 comments on commit 577bb06

Please sign in to comment.