Skip to content

Commit

Permalink
Merge pull request #2814 from irontec/PROVIDER-2049-vpbx-client-billi…
Browse files Browse the repository at this point in the history
…ng-block

Add cypress tests for billing section
  • Loading branch information
danigargar authored Nov 12, 2024
2 parents 19179f3 + e6a2e09 commit cd4996e
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web/portal/client/cypress/e2e/Invoice/Invoice.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import InvoiceCollection from '../../fixtures/Invoices/getCollection.json';

describe('Invoice', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('Invoices');
cy.before();

cy.contains('Billing').click();
cy.contains('Invoices').click();

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

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

it('has disabled buttons', () => {
cy.get('[data-testid="EditIcon"]').first().should('not.be.enabled');
cy.get('[data-testid="DeleteIcon"]').first().should('not.be.enabled');
});
});
23 changes: 23 additions & 0 deletions web/portal/client/cypress/e2e/RatingProfile/RatingProfile.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import RatingProfileCollection from '../../fixtures/RatingProfiles/getCollection.json';

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

cy.contains('Billing').click();
cy.contains('Rating profiles').click();

cy.get('header').should('contain', 'Rating profiles');

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

it('has disabled buttons', () => {
cy.get('[data-testid="EditIcon"]').first().should('not.be.enabled');
cy.get('[data-testid="DeleteIcon"]').first().should('not.be.enabled');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
describe('RatingProfiles', () => {
beforeEach(() => {
cy.prepareGenericPactInterceptors('RatingProfiles');
cy.before();

cy.contains('Billing').click();
cy.contains('Rating profiles').click();

cy.get('header').should('contain', 'Rating profiles');
cy.get('[data-testid="CurrencyExchangeIcon"]').first().click();

cy.get('[role="dialog"]').contains('Simulate call');
});

it('has disabled buttons', () => {
cy.usePactIntercept(
{
method: 'POST',
url: '**/api/client/rating_profiles/1/simulate_call',
response: {
body: {
plan: 'Something',
callDate: '2023-01-24 10:51:44',
duration: 20,
patternName: 'Dest3 (+346)',
connectionCharge: 0,
intervalStart: '0',
rate: 0.0025,
ratePeriod: 1,
totalCost: 0.15,
currencySymbol: '€',
},
statusCode: 201,
},
},
'postSimulateCall'
);

cy.get(`[role="dialog"] input`)
.first()
.clear()
.type('+342654', { delay: 1 });
cy.get(`[role="dialog"] input`).eq(1).clear().type(20, { delay: 1 });

cy.get('[role="dialog"] button').contains('Accept').first().click();

cy.usePactWait('postSimulateCall');

cy.get('[role="dialog"] table').contains('Something');
});
});
26 changes: 26 additions & 0 deletions web/portal/client/cypress/fixtures/Invoices/getCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"body": [
{
"number": "TEST025",
"inDate": "2023-05-17 00:00:00",
"outDate": "2023-05-18 21:29:59",
"taxRate": 21,
"totalWithTax": null,
"id": 39,
"pdf": {
"fileSize": null,
"mimeType": null,
"baseName": null
},
"currency": ""
}
],
"headers": {
"x-first-page": "/api/client/invoices?_page=1",
"x-next-page": "/api/client/invoices?_page=1",
"x-last-page": "/api/client/invoices?_page=1",
"x-total-items": "1",
"x-total-pages": "1"
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"body": [
{
"id": 1,
"name": {
"en": "Something",
"es": "Algo",
"ca": "Algo mes",
"it": "Più"
}
},
{
"id": 2,
"name": {
"en": "Something more",
"es": "Algo más",
"ca": "Algo mes",
"it": "Più"
}
}
],
"headers": {
"x-first-page": "/api/client/rating_plan_groups?_page=1",
"x-last-page": "/api/client/rating_plan_groups?_page=1",
"x-next-page": "/api/client/rating_plan_groups?_page=1",
"x-total-items": "1",
"x-total-pages": "1"
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"body": [
{
"activationTime": "2018-02-02 21:20:20",
"id": 1,
"ratingPlanGroup": 1,
"routingTag": 1
}
],
"headers": {
"x-first-page": "/api/client/rating_profiles?_page=1",
"x-last-page": "/api/client/rating_profiles?_page=1",
"x-next-page": "/api/client/rating_profiles?_page=1",
"x-total-items": "1",
"x-total-pages": "1"
},
"statusCode": 200
}
17 changes: 17 additions & 0 deletions web/portal/client/cypress/fixtures/RoutingTag/getCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"body": [
{
"name": "TagName",
"tag": "123#",
"id": 1
}
],
"headers": {
"x-first-page": "/api/client/routing_tags?_page=1",
"x-last-page": "/api/client/routing_tags?_page=1",
"x-next-page": "/api/client/routing_tags?_page=1",
"x-total-items": "1",
"x-total-pages": "1"
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"consumer": {
"name": "client-consumer-RatingProfiles"
},
"provider": {
"name": "client-provider-RatingProfiles"
},
"interactions": [
{
"description": "has disabled buttons",
"providerState": "",
"request": {
"method": "POST",
"path": "/api/client/rating_profiles/1/simulate_call",
"headers": {
"accept": "application/json, text/plain, */*",
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2Nzc4MzY2OTMsImV4cCI6MTY3Nzg0MDI5Mywicm9sZXMiOlsiUk9MRV9DT01QQU5ZX0FETUlOIl0sInVzZXJuYW1lIjoiY2xpZW50In0.eUZuqUVipx3O6OE9pd-TfjCdCIq3t0w8vZxky_eclCDng3GNf2dJjjdVcTv16BDswy355tixdqHhTx_X3sK6bMJoqD52eDshPL821sNHm2b38zbZl3bnf9MRRqY82eT88MZ_cWiJQ5_fm6PxMickC4FtJzXqAP-SBV7XswA-zB57TMKhdNYFsz41GI0szfmqRpm_-CYv3AfORKozFxWHtKJNd71r-Re1-BmSR0neatx9fr2eJOjAKoNGJkQmmx8c6nMcaeZBDIiglQJkDXk-A7eq6q1iF6vrqLq2ov27mFn4YmuLQkNCloZEoQDJNFR1CNZJRNqod4jC0N-y1FXFSBmbMH7_-F0XyUrbUx7DRzP-4ZK9LDxNTGZRvylDHXcTmJgmMEmPZ64DuTW4SozUjVxeVFv4OgveeLtexbLbmJ9qLoh0d8dtQSMvDOyr-t4zGw2zOUOdudXUp-t0S1oqDcEfEM-3dx2EW6SL11QoXWgVkIaN6eARiKMVnAWmUDAn7uT6TbKAZ4F8rEo5MmZMjDT_YuOF57DcGeDbC6035Kyd8SFgTcS6i3UqGf1Fp6U9nT1Snux8ATrt6cLJ644ZF2nkFb39EXlHHF03kzvVsw05nHHerLSVvdLgoSRVJSQufIF8JMK0MNMFGlBcUs3q4drqVGKiFcWQ-qXVV97IFpk",
"content-length": "28",
"content-type": "application/x-www-form-urlencoded"
},
"body": "number=%2B342654&duration=20",
"query": ""
},
"response": {
"status": 201,
"headers": {
"content-type": "application/json"
},
"body": {
"plan": "Something",
"callDate": "2023-01-24 10:51:44",
"duration": 20,
"patternName": "Dest3 (+346)",
"connectionCharge": 0,
"intervalStart": "0",
"rate": 0.0025,
"ratePeriod": 1,
"totalCost": 0.15,
"currencySymbol": ""
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
},
"client": {
"name": "pact-cypress-adapter",
"version": "1.3.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import FriendPatternsCollection from '../../fixtures/FriendPattern/getCollection
import HolidayDateCollection from '../../fixtures/HolidayDate/getCollection.json';
import HuntGroupCollection from '../../fixtures/HuntGroup/getCollection.json';
import HuntGroupMemberByHuntGroupCollection from '../../fixtures/HuntGroupMember/getCollection.json';
import InvoiceCollection from '../../fixtures/Invoices/getCollection.json';
import IvrCollection from '../../fixtures/Ivr/getCollection.json';
import IvrEntryCollection from '../../fixtures/IvrEntry/getCollection.json';
import LanguageCollection from '../../fixtures/Language/getCollection.json';
Expand All @@ -47,10 +48,13 @@ import OutgoingDdiRulePatternCollection from '../../fixtures/OutgoingDdiRulePatt
import PickUpGroupCollection from '../../fixtures/PickUpGroup/getCollection.json';
import QueueCollection from '../../fixtures/Queue/getCollection.json';
import QueueMemberCollection from '../../fixtures/QueueMember/getCollection.json';
import RatingPlanGroup from '../../fixtures/RatingPlanGroup/getCollection.json';
import RatingProfileCollection from '../../fixtures/RatingProfiles/getCollection.json';
import RecordingCollection from '../../fixtures/Recording/getCollection.json';
import ResidentialDeviceCollection from '../../fixtures/ResidentialDevice/getCollection.json';
import RetailAccountCollection from '../../fixtures/RetailAccount/getCollection.json';
import RouteLockCollection from '../../fixtures/RouteLock/getCollection.json';
import RoutingTagCollection from '../../fixtures/RoutingTag/getCollection.json';
import ScheduleCollection from '../../fixtures/Schedule/getCollection.json';
import ServiceCollection from '../../fixtures/Service/getCollection.json';
import ServiceUnassignedCollection from '../../fixtures/Service/getUnassignedCollection.json';
Expand Down Expand Up @@ -355,5 +359,21 @@ Cypress.Commands.add(
cy.intercept('GET', '**/api/client/call_acl_rel_match_lists?*', {
...CallAclRelMatchListCollection,
}).as('getCallAclRelMatchList');

cy.intercept('GET', '**/api/client/rating_profiles?*', {
...RatingProfileCollection,
}).as('getRatingProfiles');

cy.intercept('GET', '**/api/client/routing_tags?*', {
...RoutingTagCollection,
}).as('getRoutingTags');

cy.intercept('GET', '**/api/client/rating_plan_groups?*', {
...RatingPlanGroup,
}).as('getRatinggPlanGroups');

cy.intercept('GET', '**/api/client/invoices?*', {
...InvoiceCollection,
}).as('getInvoices');
}
);

0 comments on commit cd4996e

Please sign in to comment.