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

feat(P2P-ENERGY): added cypress test case for open spark confirmation… #2778

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
43 changes: 43 additions & 0 deletions cypress/e2e/p2p-energy/p2p-energy-confirmationPage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { testIds } from '../../../shared/dataTestIds'
describe('P2P Energy Order Confirmation Page', () => {
context('should render Homepage when user click on go back to home button', () => {
before(() => {
cy.clearAllLocalStorage()
cy.visit(testIds.url_base)
cy.getByData(testIds.clickable_card_open_spark).click()
cy.wait(2000)
cy.intercept('POST', '**/search', {
fixture: 'P2P/searchResponse.json'
}).as('searchResponse')
cy.getByData(testIds.P2P_hompage_button).click()
cy.wait(2000)
cy.url().should('include', `${testIds.url_search}?searchTerm`)

cy.getByData(testIds.searchpage_products).first().click()
cy.url().should('include', testIds.url_product)
cy.intercept('POST', '/select', { fixture: 'P2P/selectResult.json' }).as('selectCall')
cy.getByData(testIds.productpage_addTocartButton).click()
cy.wait('@selectCall')
cy.getByData(testIds.cartpage_cartOrderButton).click()
cy.getByData(testIds.checkoutpage_shippingDetails).getByData(testIds.checkoutpage_openForm).click()
cy.getByData('submit').click()
cy.intercept('POST', '**/init', { fixture: 'P2P/initResponse.json' }).as('initCall')
cy.wait('@initCall')
cy.getByData(testIds.checkoutpage_proceedToCheckout).click()
cy.url().should('include', testIds.url_payment)
cy.url().should('include', '/paymentMode')
cy.intercept('POST', '/confirm', { fixture: 'P2P/confirmResponse.json' }).as('confirmResponse')
cy.getByData(testIds.paymentpage_radioButton).eq(3).check().should('be.checked')
cy.getByData(testIds.paymentpage_confirmButton).click()

cy.url().should('include', '/orderConfirmation')
cy.intercept('POST', '/confirm', { fixture: 'P2P/confirmResponse.json' }).as('confirmResponse')
cy.wait('@confirmResponse')
})

it('should render homepage when click on go back to home', () => {
cy.getByData(testIds.orderConfirmation_goBackToHome).click()
cy.url().should('include', testIds.url_home)
})
})
})
226 changes: 226 additions & 0 deletions cypress/fixtures/P2P/confirmResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
{
"data": [
{
"context": {
"domain": "uei:p2p_trading",
"action": "on_confirm",
"version": "1.1.0",
"bpp_id": "bpp-ps-network-strapi-dev.example.io",
"bpp_uri": "http://bpp-ps-network-strapi-dev.example.io",
"country": "IND",
"city": "std:080",
"location": {
"country": {
"name": "India",
"code": "IND"
},
"city": {
"name": "Bangalore",
"code": "std:080"
}
},
"bap_id": "bap-ps-network-dev.example.io",
"bap_uri": "https://bap-ps-network-dev.example.io",
"transaction_id": "f45a4b75-64b1-4170-be37-b53dbfd87357",
"message_id": "82177cd1-2d05-46b5-9ef2-40a92ef838a8",
"ttl": "PT10M",
"timestamp": "2024-12-16T13:42:53.320Z"
},
"message": {
"orderId": "2635",
"provider": {
"id": "798",
"name": "Leela Energy Corp",
"short_desc": "Leela Energy Company",
"long_desc": "Big Leela Energy Company",
"images": [
{
"url": "https://file.aiquickdraw.com/imgcompressed/img/compressed_56a2f2ed06b49ceb7f8580c4bed33b52.webp",
"size_type": "sm"
}
],
"fulfillments": [
{
"id": "27",
"type": "END",
"rateable": true,
"state": {
"description": "ORDER RECEIVED",
"descriptor": {
"code": "ORDER_RECEIVED",
"name": "ORDER RECEIVED"
}
}
},
{
"id": "27",
"type": "END",
"rateable": true
},
{
"id": "26",
"type": "START",
"rateable": true
}
]
},
"items": [
{
"id": "322",
"name": "Energy",
"code": "energy",
"short_desc": "Excess power from my rooftop system to sell",
"images": [
{
"url": "https://file.aiquickdraw.com/imgcompressed/img/compressed_56a2f2ed06b49ceb7f8580c4bed33b52.webp",
"size_type": "sm"
}
],
"price": {
"value": "13"
},
"rating": "null",
"rateable": true,
"quantity": {
"available": {
"count": 120,
"measure": {
"value": "120",
"unit": "kWh"
}
}
},
"categories": [
{
"id": "100",
"name": "SOLAR ENERGY"
}
],
"fulfillments": [
{
"id": "27",
"type": "END"
},
{
"id": "27",
"type": "END"
},
{
"id": "26",
"type": "START"
}
]
}
],
"fulfillments": [
{
"id": "27",
"type": "END",
"stops": [
{
"location": {
"gps": "28.6436082,77.08698369999999",
"address": "Flat 208, A Block, Janakpuri West, New Delhi",
"city": {
"name": "New Delhi"
},
"state": {
"name": "Delhi"
},
"country": {
"code": "IND"
},
"area_code": "110018"
},
"contact": {
"phone": "9886098860",
"email": "[email protected]"
}
}
],
"state": {
"descriptor": {
"code": "ORDER_RECEIVED",
"short_desc": "ORDER RECEIVED"
},
"updated_at": "2024-12-16T13:42:53.241Z"
}
},
{
"id": "27",
"type": "END",
"rateable": true,
"state": {
"descriptor": {
"code": "ORDER_RECEIVED",
"short_desc": "ORDER RECEIVED"
},
"updated_at": "2024-12-16T13:42:53.241Z"
}
},
{
"id": "26",
"type": "START",
"rateable": true,
"state": {
"descriptor": {
"code": "ORDER_RECEIVED",
"short_desc": "ORDER RECEIVED"
},
"updated_at": "2024-12-16T13:42:53.241Z"
}
}
],
"quote": {
"price": {
"value": "13"
},
"breakup": [
{
"title": "CGST",
"price": {
"currency": "INR",
"value": "5"
}
},
{
"title": "SGST",
"price": {
"currency": "INR",
"value": "5"
}
},
{
"title": "Convenience charges",
"price": {
"currency": "INR",
"value": "1"
}
},
{
"title": "Wheeling charges @ 0.5/unit",
"price": {
"currency": "INR",
"value": "1"
}
},
{
"title": "P2P Energy Cost",
"price": {
"currency": "INR"
}
}
]
},
"billing": {
"city": {
"name": "New Delhi"
},
"state": {
"name": "Delhi"
}
}
}
}
]
}