-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3066 from beckn/cypress-open-spark-admin-flow
feat(OPEN-SPARK): added cypress test cases for admin flow
- Loading branch information
Showing
7 changed files
with
182 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { testIds } from '../../../shared/dataTestIds' | ||
describe('Admin Flow', () => { | ||
context('Should Render Empty admin page when there is no response in get pending trades', () => { | ||
before(() => { | ||
cy.clearAllLocalStorage() | ||
cy.clearAllCookies() | ||
cy.visit(testIds.url_base) | ||
cy.getByData('consumer_button').click() | ||
cy.getByData(testIds.auth_inputEmail).type(testIds.user_validEmail_admin_flow) | ||
cy.getByData(testIds.auth_inputEmail).should('have.value', testIds.user_validEmail_admin_flow) | ||
cy.getByData(testIds.auth_inputPassword).type(testIds.user_validPassword_admin_flow) | ||
cy.getByData(testIds.auth_inputPassword).should('have.value', testIds.user_validPassword_admin_flow) | ||
cy.getByData(testIds.auth_loginButton).click() | ||
}) | ||
it('should render empty admin page ', () => { | ||
cy.url().should('include', testIds.url_home) | ||
cy.intercept('GET', '/beckn-trade-bap/get-pending-trades', { | ||
fixture: 'OpenSpark/myTrade/get-pending-empty-trades.json' | ||
}).as('emptyPendingTrade') | ||
cy.wait('@emptyPendingTrade') | ||
}) | ||
it('should render lock demand button diabled ', () => { | ||
cy.getByData(testIds.total_aggregated_lock_demand).should('be.disabled') | ||
cy.getByData(testIds.total_aggregated_demand).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_head).should('be.visible') | ||
cy.getByData('noRows').should('be.visible') | ||
cy.getByData('noRows').should('contain.text', 'No rows') | ||
}) | ||
}) | ||
context('Should Render admin page when there is response in get pending trades', () => { | ||
before(() => { | ||
cy.clearAllLocalStorage() | ||
cy.clearAllCookies() | ||
cy.visit(testIds.url_base) | ||
cy.getByData('consumer_button').click() | ||
cy.getByData(testIds.auth_inputEmail).type(testIds.user_validEmail_admin_flow) | ||
cy.getByData(testIds.auth_inputEmail).should('have.value', testIds.user_validEmail_admin_flow) | ||
cy.getByData(testIds.auth_inputPassword).type(testIds.user_validPassword_admin_flow) | ||
cy.getByData(testIds.auth_inputPassword).should('have.value', testIds.user_validPassword_admin_flow) | ||
cy.getByData(testIds.auth_loginButton).click() | ||
}) | ||
it('should render admin page ', () => { | ||
cy.url().should('include', testIds.url_home) | ||
cy.intercept('GET', '/beckn-trade-bap/get-pending-trades', { | ||
fixture: 'OpenSpark/myTrade/get-pending-trades.json' | ||
}).as('getPendingTrade') | ||
cy.wait('@getPendingTrade') | ||
}) | ||
it('should display all the fields and button', () => { | ||
cy.getByData(testIds.total_aggregated_demand).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_head).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_row).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_unit).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_consumer).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_table_date).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_item_quantity).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_item_name).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_item_date).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_nav_img).should('be.visible') | ||
cy.getByData(testIds.total_aggregated_lock_demand).should('be.visible') | ||
}) | ||
it('should render lock demand button enable and user click it for lock demand ', () => { | ||
cy.intercept('POST', '/beckn-trade-bap/start-trade', { | ||
fixture: 'OpenSpark/myTrade/start-trade.json' | ||
}).as('start-trade') | ||
cy.getByData(testIds.total_aggregated_lock_demand).click() | ||
cy.wait('@start-trade') | ||
cy.intercept('GET', '/beckn-trade-bap/get-pending-trades', { | ||
fixture: 'OpenSpark/myTrade/get-pending-empty-trades.json' | ||
}).as('emptyPendingTrade') | ||
cy.visit(testIds.url_base) | ||
}) | ||
}) | ||
}) |
1 change: 1 addition & 0 deletions
1
cypress/fixtures/OpenSpark/myTrade/get-pending-empty-trades.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
58 changes: 58 additions & 0 deletions
58
cypress/fixtures/OpenSpark/myTrade/get-pending-trades.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"id": 206, | ||
"unit": "kwh", | ||
"item_name": "energy", | ||
"trusted_source": false, | ||
"cred_required": false, | ||
"recurring": false, | ||
"domain": "uei:p2p_trading", | ||
"status": "RECEIVED", | ||
"type": "BUY", | ||
"quantity": 100, | ||
"price": 0, | ||
"createdAt": "2025-01-23T10:29:20.570Z", | ||
"updatedAt": "2025-01-23T10:29:20.570Z", | ||
"publishedAt": "2025-01-23T10:29:20.566Z", | ||
"profile": { | ||
"id": 128, | ||
"name": "Leelatai Kalbhor", | ||
"address": "pune", | ||
"createdAt": "2024-12-04T08:29:52.567Z", | ||
"updatedAt": "2025-01-15T04:00:25.459Z", | ||
"publishedAt": "2025-01-13T06:24:00.090Z", | ||
"phone": "9718329616", | ||
"zip_code": null, | ||
"utility_name": "MSEB", | ||
"customer_id": "12345" | ||
} | ||
}, | ||
{ | ||
"id": 207, | ||
"unit": "kwh", | ||
"item_name": "energy", | ||
"trusted_source": false, | ||
"cred_required": false, | ||
"recurring": false, | ||
"domain": "uei:p2p_trading", | ||
"status": "RECEIVED", | ||
"type": "BUY", | ||
"quantity": 50, | ||
"price": 0, | ||
"createdAt": "2025-01-23T10:29:27.344Z", | ||
"updatedAt": "2025-01-23T10:29:27.344Z", | ||
"publishedAt": "2025-01-23T10:29:27.339Z", | ||
"profile": { | ||
"id": 128, | ||
"name": "Leelatai Kalbhor", | ||
"address": "pune", | ||
"createdAt": "2024-12-04T08:29:52.567Z", | ||
"updatedAt": "2025-01-15T04:00:25.459Z", | ||
"publishedAt": "2025-01-13T06:24:00.090Z", | ||
"phone": "9718329616", | ||
"zip_code": null, | ||
"utility_name": "MSEB", | ||
"customer_id": "12345" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"message": "Trade processing completed!", | ||
"data": [ | ||
{ | ||
"tradeId": 206, | ||
"status": "SUCCESS", | ||
"message": "Trade executed successfully for Trade ID: 206" | ||
}, | ||
{ | ||
"tradeId": 207, | ||
"status": "SUCCESS", | ||
"message": "Trade executed successfully for Trade ID: 207" | ||
} | ||
] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -674,6 +674,8 @@ const testIds = { | |
user_validPassword_consumer_flow: 'Test@123', | ||
user_validEmail_producer_flow: '[email protected]', | ||
user_validPassword_producer_flow: 'Test@123', | ||
user_validEmail_admin_flow: '[email protected]', | ||
user_validPassword_admin_flow: 'Test@123', | ||
total_energy_text: 'total_energy_text', | ||
total_energy_input: 'total_energy_input', | ||
total_energy_unit: 'total_energy_unit', | ||
|
@@ -723,6 +725,18 @@ const testIds = { | |
document_uplaod_date: 'document-uplaod-date', | ||
delete_Icon: 'delete-Icon', | ||
trade_details_date: 'trade-details-date', | ||
trade_details_Id: 'trade-details-Id' | ||
trade_details_Id: 'trade-details-Id', | ||
total_aggregated_demand: 'total_aggregated_demand', | ||
total_aggregated_table: 'total_aggregated_table', | ||
total_aggregated_table_head: 'total_aggregated_table_head', | ||
total_aggregated_table_row: 'total_aggregated_table_row', | ||
total_aggregated_table_unit: 'total_aggregated_table_unit', | ||
total_aggregated_table_consumer: 'total_aggregated_table_consumer', | ||
total_aggregated_table_date: 'total_aggregated_table_date', | ||
total_aggregated_item_quantity: 'total_aggregated_item_quantity', | ||
total_aggregated_item_name: 'total_aggregated_item_name', | ||
total_aggregated_item_date: 'total_aggregated_item_date', | ||
total_aggregated_nav_img: 'total_aggregated_nav_img', | ||
total_aggregated_lock_demand: 'total_aggregated_lock_demand' | ||
} | ||
export { testIds } |