Skip to content

Commit

Permalink
portal/brand: cypress ddis block
Browse files Browse the repository at this point in the history
  • Loading branch information
R0MANDEV committed Nov 26, 2024
1 parent 1375af2 commit 25bbdd2
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
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);
};
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
}

0 comments on commit 25bbdd2

Please sign in to comment.