-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into fix/missing-translations
- Loading branch information
Showing
16 changed files
with
482 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
site/gatsby-site/cypress/e2e/integration/entityEdit.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { conditionalIt } from '../../support/utils'; | ||
import entity from '../../fixtures/entities/entity.json'; | ||
import updateOneEntity from '../../fixtures/entities/updateOneEntity.json'; | ||
|
||
describe('Edit Entity', () => { | ||
const entity_id = 'google'; | ||
|
||
const url = `/entities/edit?entity_id=${entity_id}`; | ||
|
||
conditionalIt( | ||
!Cypress.env('isEmptyEnvironment') && Cypress.env('e2eUsername') && Cypress.env('e2ePassword'), | ||
'Should successfully edit Entity fields', | ||
() => { | ||
cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword')); | ||
|
||
cy.visit(url); | ||
|
||
cy.conditionalIntercept( | ||
'**/graphql', | ||
(req) => req.body.operationName == 'FindEntity', | ||
'FindEntity', | ||
entity | ||
); | ||
|
||
cy.wait(['@FindEntity']); | ||
|
||
const values = { | ||
name: 'Google new', | ||
}; | ||
|
||
Object.keys(values).forEach((key) => { | ||
cy.get(`[name=${key}]`).clear().type(values[key]); | ||
}); | ||
|
||
cy.conditionalIntercept( | ||
'**/graphql', | ||
(req) => req.body.operationName == 'UpdateEntity', | ||
'UpdateEntity', | ||
updateOneEntity | ||
); | ||
|
||
const now = new Date(); | ||
|
||
cy.clock(now); | ||
|
||
cy.contains('button', 'Save').click(); | ||
|
||
const updatedEntity = { | ||
name: values.name, | ||
date_modified: now.toISOString(), | ||
}; | ||
|
||
cy.wait('@UpdateEntity').then((xhr) => { | ||
expect(xhr.request.body.operationName).to.eq('UpdateEntity'); | ||
expect(xhr.request.body.variables.query.entity_id).to.eq(entity_id); | ||
expect(xhr.request.body.variables.set).to.deep.eq(updatedEntity); | ||
}); | ||
|
||
cy.get('.tw-toast').contains('Entity updated successfully.').should('exist'); | ||
} | ||
); | ||
|
||
conditionalIt( | ||
!Cypress.env('isEmptyEnvironment') && Cypress.env('e2eUsername') && Cypress.env('e2ePassword'), | ||
'Should display an error message when editing Entity fails', | ||
() => { | ||
cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword')); | ||
|
||
cy.visit(url); | ||
|
||
cy.conditionalIntercept( | ||
'**/graphql', | ||
(req) => req.body.operationName == 'FindEntity', | ||
'FindEntity', | ||
entity | ||
); | ||
|
||
cy.wait(['@FindEntity']); | ||
|
||
const values = { | ||
name: 'Google new', | ||
}; | ||
|
||
Object.keys(values).forEach((key) => { | ||
cy.get(`[name=${key}]`).clear().type(values[key]); | ||
}); | ||
|
||
cy.conditionalIntercept( | ||
'**/graphql', | ||
(req) => req.body.operationName == 'UpdateEntity', | ||
'UpdateEntity', | ||
{ | ||
data: null, | ||
errors: [ | ||
{ | ||
message: 'Dummy error message', | ||
}, | ||
], | ||
} | ||
); | ||
|
||
const now = new Date(); | ||
|
||
cy.clock(now); | ||
|
||
cy.contains('button', 'Save').click(); | ||
|
||
const updatedEntity = { | ||
name: values.name, | ||
date_modified: now.toISOString(), | ||
}; | ||
|
||
cy.wait('@UpdateEntity').then((xhr) => { | ||
expect(xhr.request.body.operationName).to.eq('UpdateEntity'); | ||
expect(xhr.request.body.variables.query.entity_id).to.eq(entity_id); | ||
expect(xhr.request.body.variables.set).to.deep.eq(updatedEntity); | ||
}); | ||
|
||
cy.get('.tw-toast').contains('Error updating Entity.').should('exist'); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"data": { | ||
"entity": { | ||
"entity_id": "google", | ||
"name": "Google", | ||
"created_at": "2024-03-01T21:52:39.877Z", | ||
"date_modified": "2024-03-21T21:52:39.877Z" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
site/gatsby-site/cypress/fixtures/entities/updateOneEntity.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"data": { | ||
"updateOneEntity": { | ||
"entity_id": "google" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.