Skip to content

Commit

Permalink
fix closure, draft test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Valiulin committed Dec 18, 2024
1 parent 577bb06 commit f45e810
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,31 @@ context('When saving after deleting a frame, job metadata is inconsistent.', ()
cy.get('button').contains('Save').click({ force: true });
cy.get('button').contains('Save').trigger('mouseout');
}
function middleware(request, response) {
function middleware() {
let calls = 0;
const responseStub = { statusCode: 502, body: 'Network error' };
const badResponseStub = { statusCode: 502, body: 'Network error' };
function handle(req, res) {
if (calls === 0) {
console.log(calls);
calls++;
res.send(responseStub);
res.send(badResponseStub);
} else {
req.continue();
console.log(calls);
req.continue({ statusCode: 200, body: 'OK' });
}
}
handle(request, response);
return handle;
}
cy.intercept('PATCH', '/api/jobs/**/data/meta**', middleware);
cy.intercept('PATCH', '/api/jobs/**/data/meta**', middleware()).as('patchMeta');
clickDelete();
clickSave();
cy.contains('button', 'Restore').should('be.visible');
cy.wait('@patchMeta').its('response.body').should('eq', 502);
cy.wait('@patchMeta').its('response.body').should('eq', 200);

cy.wait('@patchMeta');
// TODO: refactor saveJob with necessary status

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

/**
* FIXME: this just asserts 502
Expand Down

0 comments on commit f45e810

Please sign in to comment.