Skip to content

Commit

Permalink
Merge pull request #2802 from clari182/fix/similar-dissimilar-test
Browse files Browse the repository at this point in the history
Add intercept for updating incident
  • Loading branch information
pdcp1 authored May 28, 2024
2 parents bc765c8 + d01c853 commit b1238bd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions site/gatsby-site/cypress/e2e/integration/cite.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,18 @@ describe('Cite pages', () => {
it('Should link similar incidents', () => {
cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword'));

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'UpdateIncident',
'updateIncident',
updateIncident50
);

cy.conditionalIntercept(
'**/graphql',
(req) =>
req.body.operationName == 'UpdateIncidents' &&
req.body.variables.set.editor_similar_incidents == 10,
req.body.variables.set.editor_similar_incidents == 50,
'updateSimilarIncidents',
{
data: {
Expand All @@ -869,7 +876,7 @@ describe('Cite pages', () => {
'**/graphql',
(req) =>
req.body.operationName == 'UpdateIncidents' &&
req.body.variables.set.editor_dissimilar_incidents == 10,
req.body.variables.set.editor_dissimilar_incidents == 50,
'updateDissimilarIncidents',
{
data: {
Expand All @@ -881,7 +888,7 @@ describe('Cite pages', () => {
}
);

cy.visit('/incidents/edit/?incident_id=10');
cy.visit('/incidents/edit/?incident_id=50');

cy.waitForStableDOM();

Expand All @@ -906,17 +913,19 @@ describe('Cite pages', () => {

cy.get('button[type="submit"]').click();

cy.wait('@updateIncident', { timeout: 8000 });

cy.wait('@updateSimilarIncidents', { timeout: 30000 }).then((xhr) => {
expect(xhr.request.body.variables.query).deep.eq({ incident_id_in: [123] });
expect(xhr.request.body.variables.set).to.deep.eq({
editor_similar_incidents: [10],
editor_similar_incidents: [50],
});
});

cy.wait('@updateDissimilarIncidents', { timeout: 30000 }).then((xhr) => {
expect(xhr.request.body.variables.query).deep.eq({ incident_id_in: [456] });
expect(xhr.request.body.variables.set).to.deep.eq({
editor_dissimilar_incidents: [10],
editor_dissimilar_incidents: [50],
});
});
});
Expand Down

0 comments on commit b1238bd

Please sign in to comment.