Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cypress tests for portal/brand Providers section #2820

Open
wants to merge 3 commits into
base: bleeding
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
57 changes: 57 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,57 @@
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, mediaRelaySet } =
newCarrier.request;
cy.fillTheForm({ description, name, transformationRuleSet, mediaRelaySet });
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, mediaRelaySet } = editCarriers.request;
cy.fillTheForm({ description, name, proxyTrunk, mediaRelaySet });
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,26 @@
import BillableCallItem from '../../../../fixtures/Provider/BillableCalls/getItem.json';
import DdiCollection from '../../../../fixtures/Provider/Ddis/getCollection.json';

describe('in BillableCalls', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('ddis-billable_calls');
cy.before('');
cy.get('svg[data-testid="PrecisionManufacturingIcon"]').first().click();
cy.contains('DDIs').click();
cy.get('header').should('contain', 'DDIs');
cy.get('table').should('contain', DdiCollection.body[0].ddie164);
});

it('View details', () => {
cy.intercept('GET', '**/api/brand/billable_calls/1*', {
...BillableCallItem,
}).as('getBillableCall-1');

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

cy.usePactWait(['getBillableCall-1'])
.its('response.statusCode')
.should('eq', 200);
});
});
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