-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
web/portal/brand/cypress/e2e/Providers/DdiProviders/Ddis/Ddis.tests.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,91 @@ | ||
import CompaniesItem from '../../../../fixtures/Provider/Companies/VirtualPbxs/getItem.json'; | ||
import DdiItem from '../../../../fixtures/Provider/Ddis/getItem.json'; | ||
import newDdi from '../../../../fixtures/Provider/Ddis/post.json'; | ||
import editDdis from '../../../../fixtures/Provider/Ddis/put.json'; | ||
|
||
export const postDdi = () => { | ||
cy.usePactIntercept( | ||
{ | ||
method: 'POST', | ||
url: '**/api/brand/ddis*', | ||
response: newDdi.response, | ||
matchingRules: newDdi.matchingRules, | ||
}, | ||
'createDdi' | ||
); | ||
|
||
cy.usePactIntercept( | ||
{ | ||
method: 'GET', | ||
url: '**/api/brand/companies/1*', | ||
response: { ...CompaniesItem }, | ||
}, | ||
'getCompanies-1' | ||
); | ||
|
||
cy.get('[aria-label=Add]').click(); | ||
|
||
const { ddi, description, type, company, country } = newDdi.request; | ||
cy.fillTheForm({ | ||
ddi, | ||
description, | ||
type, | ||
company, | ||
country, | ||
}); | ||
|
||
cy.get('header li.MuiBreadcrumbs-li:last').should('contain', 'DDIs'); | ||
|
||
cy.usePactWait(['createDdi']).its('response.statusCode').should('eq', 201); | ||
}; | ||
|
||
export const putDdi = () => { | ||
cy.usePactIntercept( | ||
{ | ||
method: 'GET', | ||
url: '**/api/brand/ddis/1', | ||
response: { ...DdiItem }, | ||
}, | ||
'getDdis-1' | ||
); | ||
|
||
cy.usePactIntercept( | ||
{ | ||
method: 'PUT', | ||
url: `**/api/brand/ddis/${editDdis.response.body.id}`, | ||
response: editDdis.response, | ||
}, | ||
'editDdis' | ||
); | ||
|
||
cy.get('svg[data-testid="EditIcon"]').eq(1).click(); | ||
|
||
const { ddi, description, type, country } = newDdi.request; | ||
cy.fillTheForm({ | ||
ddi, | ||
description, | ||
type, | ||
country, | ||
}); | ||
|
||
cy.get('header').should('contain', 'DDIs'); | ||
|
||
cy.usePactWait(['editDdis']).its('response.statusCode').should('eq', 200); | ||
}; | ||
|
||
export const deleteDdi = () => { | ||
cy.intercept('DELETE', '**/api/brand/ddis/*', { | ||
statusCode: 204, | ||
}).as('deleteDdi'); | ||
|
||
cy.get('td button svg[data-testid="DeleteIcon"]').first().click(); | ||
cy.contains('Remove element'); | ||
cy.get('div.MuiDialog-container button') | ||
.filter(':visible') | ||
.contains('Yes, delete it') | ||
.click(); | ||
|
||
cy.get('header li.MuiBreadcrumbs-li:last').should('contain', 'DDIs'); | ||
|
||
cy.usePactWait(['deleteDdi']).its('response.statusCode').should('eq', 204); | ||
}; |
28 changes: 28 additions & 0 deletions
28
web/portal/brand/cypress/fixtures/Provider/DdiProviders/getItem.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,28 @@ | ||
{ | ||
"body": { | ||
"description": "DDIProviderDescription", | ||
"name": "DDIProviderName", | ||
"id": 1, | ||
"transformationRuleSet": { | ||
"description": "Brand 1 transformation for Spain", | ||
"internationalCode": "00", | ||
"trunkPrefix": "", | ||
"areaCode": "", | ||
"nationalLen": 9, | ||
"generateRules": false, | ||
"id": 1, | ||
"name": { | ||
"en": "Brand 1 transformation for Spain", | ||
"es": "Marca 1 tansformacion para España", | ||
"ca": "Marca 1 tansformacion para España", | ||
"it": "Brand 1 transformation for Spain" | ||
}, | ||
"country": 68, | ||
"editable": true | ||
} | ||
}, | ||
"headers": { | ||
"content-type": "application/json; charset=utf-8" | ||
}, | ||
"statusCode": 200 | ||
} |