Skip to content

Commit

Permalink
portal/brand: test
Browse files Browse the repository at this point in the history
  • Loading branch information
R0MANDEV committed Dec 3, 2024
1 parent 9987cb3 commit 750a1d8
Show file tree
Hide file tree
Showing 57 changed files with 4,195 additions and 2,249 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import CarrierServerCollection from '../../../../fixtures/Provider/CarrierServer/getCollection.json';
import {
deleteCarrierServer,
postCarrierServer,
putCarrierServer,
} from './CarrierServer.tests';

describe('in Carrier Servers', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Carriers-Carrier-Server');
cy.before();

cy.get('svg[data-testid="PrecisionManufacturingIcon"]').first().click();
cy.contains('Carriers').click();
cy.get('svg[data-testid="StorageIcon"]').first().click();

cy.get('header').should('contain', 'Carrier servers');

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

///////////////////////
// POST
///////////////////////
it('add Carrier Server', postCarrierServer);

///////////////////////////////
// PUT
///////////////////////////////
it('edit Carrier Server', putCarrierServer);

///////////////////////////////
// DELETE
///////////////////////////////
it('delete Carrier Server', deleteCarrierServer);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import CarrierItem from '../../../../fixtures/Provider/Carriers/getItem.json';
import CarrierServerItem from '../../../../fixtures/Provider/CarrierServer/getItem.json';
import newCarrierServer from '../../../../fixtures/Provider/CarrierServer/post.json';
import editCarriersServer from '../../../../fixtures/Provider/CarrierServer/put.json';

export const postCarrierServer = () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/brand/carrier_servers*',
response: newCarrierServer.response,
matchingRules: newCarrierServer.matchingRules,
},
'createCarrierServer'
);

cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/carriers/1*',
response: { ...CarrierItem },
},
'getCompanies-1'
);
cy.get('[aria-label=Add]').click();
const { authUser, outboundProxy, sipProxy } = newCarrierServer.request;
cy.fillTheForm({
authUser,
outboundProxy,
sipProxy,
});
cy.get('header li.MuiBreadcrumbs-li:last').should(
'contain',
'Carrier servers'
);

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

export const putCarrierServer = () => {
cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/carrier_servers/1',
response: { ...CarrierServerItem },
},
'getCarrier-1'
);

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/brand/carrier_servers/${editCarriersServer.response.body.id}`,
response: editCarriersServer.response,
},
'editCarriers'
);
cy.get('svg[data-testid="EditIcon"]').eq(0).click();
const { authUser, outboundProxy } = editCarriersServer.request;
cy.fillTheForm({
authUser,
outboundProxy,
});
cy.get('header').should('contain', 'Carriers');
cy.usePactWait(['editCarriers']).its('response.statusCode').should('eq', 200);
};

export const deleteCarrierServer = () => {
cy.intercept('DELETE', '**/api/brand/carrier_servers/*', {
statusCode: 204,
}).as('deleteCarrierServer');
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', 'Carrier servers');

cy.usePactWait(['deleteCarrierServer'])
.its('response.statusCode')
.should('eq', 204);
};
26 changes: 26 additions & 0 deletions web/portal/brand/cypress/e2e/Providers/Carriers/Carriers.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import CarriersCollection from '../../../fixtures/Provider/Carriers/getCollection.json';
import { postCarrier, putCarrier } from './Carriers.tests';

describe('in Carriers', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Carriers');
cy.before();

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

cy.get('header').should('contain', 'Carriers');

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

///////////////////////
// POST
///////////////////////
it('add Carrier', postCarrier);

///////////////////////////////
// PUT
///////////////////////////////
it('edit Carrier', putCarrier);
});
56 changes: 56 additions & 0 deletions web/portal/brand/cypress/e2e/Providers/Carriers/Carriers.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import CarrierItem from '../../../fixtures/Provider/Carriers/getItem.json';
import newCarrier from '../../../fixtures/Provider/Carriers/post.json';
import editCarriers from '../../../fixtures/Provider/Carriers/put.json';
import CompaniesItem from '../../../fixtures/Provider/Companies/VirtualPbxs/getItem.json';

export const postCarrier = () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/brand/carriers*',
response: newCarrier.response,
matchingRules: newCarrier.matchingRules,
},
'createDdi'
);

cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/companies/1*',
response: { ...CompaniesItem },
},
'getCompanies-1'
);
cy.get('[aria-label=Add]').click();
const { description, name, transformationRuleSet } = newCarrier.request;
cy.fillTheForm({ description, name, transformationRuleSet });
cy.get('header li.MuiBreadcrumbs-li:last').should('contain', 'Carriers');

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

export const putCarrier = () => {
cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/carriers/1',
response: { ...CarrierItem },
},
'getDdis-1'
);

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/brand/carriers/${editCarriers.response.body.id}`,
response: editCarriers.response,
},
'editCarriers'
);
cy.get('svg[data-testid="EditIcon"]').eq(1).click();
const { description, name, proxyTrunk } = newCarrier.request;
cy.fillTheForm({ description, name, proxyTrunk });
cy.get('header').should('contain', 'Carriers');
cy.usePactWait(['editCarriers']).its('response.statusCode').should('eq', 200);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import BillableCallsCollection from '../../../../fixtures/Provider/BillableCalls/getCollection.json';
import DdisCollection from '../../../../fixtures/Provider/Ddis/getCollection.json';

describe('in BillableCalls', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('ddisProviders-billable_calls');

cy.intercept('GET', '**/api/brand/ddis/1', {
...DdisCollection,
body: DdisCollection.body.find((row) => row.id === 3),
}).as('getDdis1');

cy.before('ddis');

cy.get('svg[data-testid="PrecisionManufacturingIcon"]').first().click();
cy.contains('DDI Providers').click();
cy.get('td button svg[data-testid="MoreHorizIcon"]').first().click();
cy.get('li.MuiMenuItem-root')
.contains('External calls')
.click({ force: true });

cy.get('header li.MuiBreadcrumbs-li:last').should(
'contain',
'External calls'
);
});

it('contains Billable Calls', () => {
cy.get('table').should('contain', BillableCallsCollection.body[0].caller);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import DdisProvidersAddressesCollection from '../../../../fixtures/Provider/DdiProviders/getProviderAddressesCollection.json';
import {
deleteDdiProviders,
postDdiProvidersAddresses,
putDdiProvidersAddresses,
} from './DDIProviderAddresses.tests';

describe('in Ddis Provider Addresses', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('DDIs-Providers-Addresses');
cy.before();

cy.get('svg[data-testid="PrecisionManufacturingIcon"]').first().click();
cy.contains('DDI Providers').click();

cy.get('svg[data-testid="DnsIcon"]').first().click();
cy.get('header').should('contain', 'DDI Providers');

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

///////////////////////
// POST
///////////////////////
it('add Ddi Providers Addresses', postDdiProvidersAddresses);

///////////////////////////////
// PUT
///////////////////////////////
it('edit Ddi Providers', putDdiProvidersAddresses);

///////////////////////
// DELETE
///////////////////////
it('delete Ddi Providers', deleteDdiProviders);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import DdiProvidersAddressesItem from '../../../../fixtures/Provider/DdiProviders/getProviderAddressesItem.json';
import newDdiProvidersAddresses from '../../../../fixtures/Provider/DdiProviders/postProviderAddresses.json';
import editDdisProvidersAddresses from '../../../../fixtures/Provider/DdiProviders/putProviderAddresses.json';

export const postDdiProvidersAddresses = () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/brand/ddi_provider_addresses*',
response: newDdiProvidersAddresses.response,
matchingRules: newDdiProvidersAddresses.matchingRules,
},
'createDdiProvidersAddresses'
);

cy.get('[aria-label=Add]').click();
cy.get('header').should('contain', 'DDI Provider Addresses');

const { ip, description } = newDdiProvidersAddresses.request;
cy.fillTheForm({ ip, description });

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

export const putDdiProvidersAddresses = () => {
cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/ddi_provider_addresses/1',
response: { ...DdiProvidersAddressesItem },
},
'getDdisProvidersAddresses-1'
);

cy.usePactIntercept(
{
method: 'PUT',
url: `**/api/brand/ddi_provider_addresses/${editDdisProvidersAddresses.response.body.id}`,
response: editDdisProvidersAddresses.response,
},
'editDdisProvidersAddresses'
);

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

const { description, ip } = editDdisProvidersAddresses.request;
cy.fillTheForm({ description, ip });

cy.get('header').should('contain', 'DDI Provider Addresses');

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

export const deleteDdiProviders = () => {
cy.intercept('DELETE', '**/api/brand/ddi_provider_addresses/*', {
statusCode: 204,
}).as('deleteDdiProvidersAddresses');
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', 'DDI Provider Addresses');

cy.usePactWait(['deleteDdiProvidersAddresses'])
.its('response.statusCode')
.should('eq', 204);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import DdisProvidersRegistrationsCollection from '../../../../fixtures/Provider/DdiProviders/getProviderRegistrationsCollection.json';
import {
deleteDdiProvidersRegistrations,
postDdiProvidersRegistrations,
putDdiProvidersRegistrations,
} from './DDIProviderRegistrations.tests';

describe('in Ddis Provider Registrations', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('DDIs-Providers-Registrations');
cy.before();

cy.get('svg[data-testid="PrecisionManufacturingIcon"]').first().click();
cy.contains('DDI Providers').click();

cy.get('td button svg[data-testid="MoreHorizIcon"]').first().click();
cy.get('li.MuiMenuItem-root')
.contains('DDI Provider Registrations')
.click();
cy.get('header').should('contain', 'DDI Provider Registrations');

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

///////////////////////
// POST
///////////////////////
it('add Ddi Providers Registrations', postDdiProvidersRegistrations);

///////////////////////////////
// PUT
///////////////////////////////
it('edit Ddi Providers Registrations', putDdiProvidersRegistrations);

///////////////////////
// DELETE
///////////////////////
it('delete Ddi Providers Registrations', deleteDdiProvidersRegistrations);
});
Loading

0 comments on commit 750a1d8

Please sign in to comment.