Skip to content

Commit

Permalink
Merge pull request #2772 from irontec/PROVIDER-1983-test-retail-Accou…
Browse files Browse the repository at this point in the history
…nts-and-DDI

Retail Accounts and DDI
  • Loading branch information
R0MANDEV authored Sep 24, 2024
2 parents d616569 + 7183321 commit 02767eb
Show file tree
Hide file tree
Showing 11 changed files with 654 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import CallForwardSettingCollection from '../../../fixtures/CallForwardSetting/getCollection.json';
import CallForwardSettingItem from '../../../fixtures/CallForwardSetting/getItem.json';
import newCallForwardSetting from '../../../fixtures/CallForwardSetting/post.json';
import editCallForwardSetting from '../../../fixtures/CallForwardSetting/put.json';

describe('Retail Accounts CallForwardSetting', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Retail-Accounts-CallForwardSetting');
cy.before();

cy.contains('Retail Accounts').click();

cy.get('header').should('contain', 'Retail Accounts');

cy.get('svg[data-testid="PhoneForwardedIcon"]').first().click();

cy.get('table').should(
'contain',
CallForwardSettingCollection.body[0].numberValue
);
});

///////////////////////
// POST
///////////////////////
it('add CallForwardSetting', () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/client/call_forward_settings*',
response: newCallForwardSetting.response,
matchingRules: newCallForwardSetting.matchingRules,
},
'createCallForwardSetting'
);

cy.get('[aria-label=Add]').click();

const {
targetType,
numberValue,
friend,
extension,
voicemail,
enabled,
ddi,
} = newCallForwardSetting.request;
cy.fillTheForm({
targetType,
numberValue,
friend,
extension,
voicemail,
enabled,
ddi,
});

cy.get('header').should('contain', 'Call forward settings');

cy.usePactWait('createCallForwardSetting')
.its('response.statusCode')
.should('eq', 201);
});

///////////////////////////////
// PUT
///////////////////////////////
it('edit CallForwardSetting', () => {
cy.intercept('GET', '**/api/client/call_forward_settings/1', {
...CallForwardSettingItem,
}).as('getCallForwardSetting-1');

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/client/call_forward_settings/${editCallForwardSetting.response.body.id}`,
response: editCallForwardSetting.response,
},
'editCallForwardSetting'
);

cy.get('svg[data-testid="EditIcon"]').first().click();

const { enabled, ddi, callForwardType } = editCallForwardSetting.request;
cy.fillTheForm({
enabled,
ddi,
callForwardType,
});

cy.get('header').contains('Call forward settings');

cy.usePactWait(['editCallForwardSetting'])
.its('response.statusCode')
.should('eq', 200);
});

///////////////////////
// DELETE
///////////////////////
it('delete CallForwardSetting', () => {
cy.intercept('DELETE', '**/api/client/call_forward_settings/*', {
statusCode: 204,
}).as('deleteCallForwardSetting');

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').should('contain', 'Call forward settings');

cy.usePactWait(['deleteCallForwardSetting'])
.its('response.statusCode')
.should('eq', 204);
});
});
75 changes: 75 additions & 0 deletions web/portal/client/cypress/e2e/RetailAccount/Ddi/Ddi.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import DdiCollection from '../../../fixtures/Ddi/getCollection.json';
import DdiItem from '../../../fixtures/Ddi/getItem.json';
import editDdi from '../../../fixtures/Ddi/put.json';

describe('Retail Accounts Ddi', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Retail-Accounts-Ddi');
cy.before();

cy.contains('Retail Accounts').click();

cy.get('header').should('contain', 'Retail Accounts');

cy.get('td button svg[data-testid="MoreHorizIcon"]').first().click();
cy.get('li.MuiMenuItem-root').contains('DDIs').click();

cy.get('table').should('contain', DdiCollection.body[0].ddie164);
});

///////////////////////////////
// PUT
///////////////////////////////
it('edit Ddi', () => {
cy.intercept('GET', '**/api/client/ddis/1', {
...DdiItem,
}).as('getDdi-1');

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/client/ddis/${editDdi.response.body.id}`,
response: editDdi.response,
},
'editDdi'
);

cy.get('svg[data-testid="EditIcon"]').first().click();

const {
conditionalRoute,
conferenceRoom,
description,
displayName,
externalCallFilter,
fax,
huntGroup,
ivr,
language,
queue,
residentialDevice,
routeType,
user,
} = editDdi.request;

cy.fillTheForm({
conditionalRoute,
conferenceRoom,
description,
displayName,
externalCallFilter,
fax,
huntGroup,
ivr,
language,
queue,
residentialDevice,
routeType,
user,
});

cy.contains('DDIs');

cy.usePactWait(['editDdi']).its('response.statusCode').should('eq', 200);
});
});
50 changes: 50 additions & 0 deletions web/portal/client/cypress/e2e/RetailAccount/RetailAccount.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import RetailAccountCollection from '../../fixtures/RetailAccount/getCollection.json';
import RetailAccountItem from '../../fixtures/RetailAccount/getItem.json';
import editRetailAccount from '../../fixtures/RetailAccount/put.json';

describe('Retail Account', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Retail-Accounts');
cy.before();

cy.contains('Retail Accounts').click();

cy.get('header').should('contain', 'Retail Accounts');

cy.get('table').should('contain', RetailAccountCollection.body[0].name);
});

///////////////////////////////
// PUT
///////////////////////////////
it('edit Retail Account', () => {
cy.intercept('GET', '**/api/client/retail_accounts/1', {
...RetailAccountItem,
}).as('getRetailAccount-1');

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/client/retail_accounts/${editRetailAccount.response.body.id}`,
response: editRetailAccount.response,
},
'editRetailAccount'
);

cy.get('svg[data-testid="EditIcon"]').first().click();

const { description, transformationRuleSet, outgoingDdi } =
editRetailAccount.request;
cy.fillTheForm({
description,
transformationRuleSet,
outgoingDdi,
});

cy.contains('Retail Accounts');

cy.usePactWait(['editRetailAccount'])
.its('response.statusCode')
.should('eq', 200);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"body": {
"restricted": false,
"vpbx": false,
"residential": false,
"retail": true,
"wholesale": false,
"billingInfo": false,
"defaultCountryId": 68,
"acls": [],
"features": [
"queues",
"recordings",
"faxes",
"friends",
"conferences"
]
},
"headers": {
"content-type": "application/json; charset=utf-8"
},
"statusCode": 200
}
35 changes: 35 additions & 0 deletions web/portal/client/cypress/fixtures/RetailAccount/getItem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"body": {
"name": "testRetailAccount",
"description": "",
"transport": "udp",
"ip": null,
"port": null,
"password": "9rv6G3TVc-",
"fromDomain": null,
"directConnectivity": "no",
"ddiIn": "yes",
"t38Passthrough": "no",
"rtpEncryption": false,
"multiContact": true,
"ruriDomain": null,
"trustSDP": false,
"id": 1,
"transformationRuleSet": null,
"outgoingDdi": null,
"status": [
{
"contact": "sip:[email protected]:5060",
"publicContact": false,
"received": "sip:212.64.172.26:5060",
"publicReceived": true,
"expires": "2031-01-01 00:59:59",
"userAgent": "Yealink SIP-T23G 44.80.0.130"
}
]
},
"headers": {
"content-type": "application/json; charset=utf-8"
},
"statusCode": 200
}
33 changes: 33 additions & 0 deletions web/portal/client/cypress/fixtures/RetailAccount/post.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"request": {
"name": "alice2",
"password": "ZGthe7E2+5",
"mac": null,
"terminalModel": 1
},
"response": {
"body": {
"name": "alice2",
"disallow": "all",
"allowAudio": "alaw",
"allowVideo": null,
"directMediaMethod": "invite",
"password": "ZGthe7E2+5",
"mac": null,
"lastProvisionDate": null,
"t38Passthrough": "no",
"rtpEncryption": false,
"id": 5,
"terminalModel": 1
},
"headers": {
"content-type": "application/json; charset=utf-8"
},
"statusCode": 201
},
"matchingRules": {
"$.body.id": {
"match": "type"
}
}
}
23 changes: 23 additions & 0 deletions web/portal/client/cypress/fixtures/RetailAccount/put.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"request": {
"name": "readOnlyRetailAccount",
"description": "updated desc",
"transformationRuleSet": 1,
"outgoingDdi": 1
},
"response": {
"body": {
"name": "testRetailAccount",
"description": "updated desc",
"transport": "udp",
"password": "9rv6G1TVc-",
"id": 1,
"transformationRuleSet": 1,
"outgoingDdi": 1
},
"headers": {
"content-type": "application/json; charset=utf-8"
},
"statusCode": 200
}
}
Loading

0 comments on commit 02767eb

Please sign in to comment.