Skip to content

Commit

Permalink
Merge pull request #2810 from irontec/PROVIDER-1958-cypress-brand-cli…
Browse files Browse the repository at this point in the history
…ent-block

Add clients block cypress tests
  • Loading branch information
danigargar authored Nov 12, 2024
2 parents cd4996e + 0cb148e commit cdfafdd
Show file tree
Hide file tree
Showing 40 changed files with 2,284 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import RatingProfiles from '../../../../fixtures/Provider/RatingProfile/getCollection.json';
import {
deleteProfile,
postProfile,
putProfile,
} from '../../common/RatingProfile.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('residential-client-rating-profiles');

cy.before('');
cy.contains('Clients').click();
cy.contains('Virtual PBXs').click();

cy.get('header').should('contain', 'Virtual PBXs');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Rating Profiles').click();
cy.get('header').should('contain', 'Rating Profiles');

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

it('add RatingProfile', postProfile);

it('edit RatingProfile', putProfile);

it('delete RatingProfile', deleteProfile);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import UsersAddresses from '../../../../fixtures/Kam/UsersAddresses/getCollection.json';
import {
addUserAddress,
deleteUserAddress,
} from '../../common/UserAddress.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('residential-client-users-addresses');

cy.before('');
cy.contains('Clients').click();
cy.contains('Residentials').click();

cy.get('header').should('contain', 'Residentials');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root')
.contains(/^Authorized sources$/)
.click();
cy.get('header').should('contain', 'Authorized sources');

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

it('add UserAddress', addUserAddress);

it('delete UserAddress', deleteUserAddress);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import RatingProfiles from '../../../../fixtures/Provider/RatingProfile/getCollection.json';
import {
deleteProfile,
postProfile,
putProfile,
} from '../../common/RatingProfile.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('retails-client-rating-profiles');

cy.before('');
cy.contains('Clients').click();
cy.contains('Retails').click();

cy.get('header').should('contain', 'Retails');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Rating Profiles').click();
cy.get('header').should('contain', 'Rating Profiles');

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

it('add RatingProfile', postProfile);

it('edit RatingProfile', putProfile);

it('delete RatingProfile', deleteProfile);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import UsersAddresses from '../../../../fixtures/Kam/UsersAddresses/getCollection.json';
import {
addUserAddress,
deleteUserAddress,
editUserAddress,
} from '../../common/UserAddress.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('retail-client-users-addresses');

cy.before('');
cy.contains('Clients').click();
cy.contains('Retails').click();

cy.get('header').should('contain', 'Retails');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root')
.contains(/^Authorized sources$/)
.click();
cy.get('header').should('contain', 'Authorized sources');

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

it('add UsersAddress', addUserAddress);

it('update UsersAddress', editUserAddress);

it('delete UsersAddress', deleteUserAddress);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import BannedAddresses from '../../../../fixtures/Provider/BannedAddress/getCollection.json';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('vpbx-client-banned-addresses');

cy.before('');
cy.contains('Clients').click();
cy.contains('Virtual PBXs').click();

cy.get('header').should('contain', 'Virtual PBXs');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Banned IP addresses').click();
cy.get('header').should('contain', 'Banned IP addresses');

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

it('edit disabled', () => {
cy.get('[data-testid="EditIcon"]').should('not.be.enabled');
});

it('delete disabled', () => {
cy.get('[data-testid="DeleteIcon"]').should('not.be.enabled');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import RatingProfiles from '../../../../fixtures/Provider/RatingProfile/getCollection.json';
import {
deleteProfile,
postProfile,
putProfile,
} from '../../common/RatingProfile.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('vpbx-client-rating-profiles');

cy.before('');
cy.contains('Clients').click();
cy.contains('Virtual PBXs').click();

cy.get('header').should('contain', 'Virtual PBXs');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Rating Profiles').click();
cy.get('header').should('contain', 'Rating Profiles');

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

it('add RatingProfile', postProfile);

it('edit RatingProfile', putProfile);

it('delete RatingProfile', deleteProfile);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import UsersAddresses from '../../../../fixtures/Kam/UsersAddresses/getCollection.json';
import {
addUserAddress,
deleteUserAddress,
editUserAddress,
} from '../../common/UserAddress.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('vpbx-client-users-addresses');

cy.before('');
cy.contains('Clients').click();
cy.contains('Virtual PBXs').click();

cy.get('header').should('contain', 'Virtual PBXs');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root')
.contains(/^Authorized sources$/)
.click();
cy.get('header').should('contain', 'Authorized sources');

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

it('add UsersAddress', addUserAddress);

it('edit UsersAddress', editUserAddress);

it('delete UsersAddress', deleteUserAddress);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import AdministratorCollection from '../../../../fixtures/Provider/Administrator/getCollection.json';
import {
deleteAdministrator,
postAdministrator,
putActiveAdministratorEmptyPassword,
putAdministrator,
} from '../../../Administrator/Administrator.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('retail-client-administrator');
cy.before('');
cy.contains('Clients').click();
cy.contains('Retails').click();

cy.get('header').should('contain', 'Retails');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root')
.contains(/^Client's Administrators$/)
.click();
cy.get('header').should('contain', "Client's Administrators");

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

///////////////////////
// POST
///////////////////////
it('add Administrator', postAdministrator);

///////////////////////////////
// PUT
///////////////////////////////
it('edit Administrator', putAdministrator);

///////////////////////////////
// PUT
///////////////////////////////
it(
'edit active Administrator with empty password',
putActiveAdministratorEmptyPassword
);
///////////////////////
// DELETE
///////////////////////
it('delete Administrator', deleteAdministrator);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import RatingProfiles from '../../../../fixtures/Provider/RatingProfile/getCollection.json';
import {
deleteProfile,
postProfile,
putProfile,
} from '../../common/RatingProfile.tests';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('vpbx-client-rating-profiles');

cy.before('');
cy.contains('Clients').click();
cy.contains('Virtual PBXs').click();

cy.get('header').should('contain', 'Virtual PBXs');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Rating Profiles').click();
cy.get('header').should('contain', 'Rating Profiles');

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

it('add RatingProfile', postProfile);

it('edit RatingProfile', putProfile);

it('delete RatingProfile', deleteProfile);
});
103 changes: 103 additions & 0 deletions web/portal/brand/cypress/e2e/Clients/Wholesales/Trusted/Trusted.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import Trusteds from '../../../../fixtures/Kam/Trusted/getCollection.json';
import TrustedItem from '../../../../fixtures/Kam/Trusted/getItem.json';
import NewTrusted from '../../../../fixtures/Kam/Trusted/post.json';
import EditTrusted from '../../../../fixtures/Kam/Trusted/put.json';

describe('in Administrator', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('wholesale-client-trusted');

cy.before('');
cy.contains('Clients').click();
cy.contains('Wholesales').click();

cy.get('header').should('contain', 'Wholesales');
cy.get('td button svg[data-testid="MoreHorizIcon"]').eq(3).click();
cy.get('li.MuiMenuItem-root').contains('Authorized Ip Addresses').click();
cy.get('header').should('contain', 'Authorized Ip Addresses');

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

it('add Trusted', () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/brand/trusteds*',
response: NewTrusted.response,
},
'postTrusteds'
);

cy.get('button').contains('Add').click();

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

const { srcIp, description } = NewTrusted.body;

cy.fillTheForm({
srcIp,
description,
});

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

it('edit Trusted', () => {
cy.usePactIntercept(
{
method: 'GET',
url: '**/api/brand/trusteds/1',
response: TrustedItem.response,
},
'getTrusteds-1'
);

cy.usePactIntercept(
{
method: 'PUT',
url: '**/api/brand/trusteds/1',
response: EditTrusted.response,
},
'putTrusteds-1'
);

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

cy.usePactWait('getTrusteds-1')
.its('response.statusCode')
.should('eq', 200);

const { srcIp, description } = EditTrusted.request;
cy.fillTheForm({
srcIp: srcIp,
description: description,
});

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

it('delete Trusted', () => {
cy.usePactIntercept(
{
method: 'DELETE',
url: '**/api/brand/trusteds/1',
response: '200',
},
'deleteTrusted-1'
);

cy.get('table [data-testid="DeleteIcon"]').first().click();
cy.contains('Remove element');
cy.get('div.MuiDialog-container button')
.filter(':visible')
.contains('Yes, delete it')
.click({ force: true });

cy.usePactWait('deleteTrusted-1')
.its('response.statusCode')
.should('eq', 200);
});
});
Loading

0 comments on commit cdfafdd

Please sign in to comment.