diff --git a/apps/open-spark/pages/adminDashboard.tsx b/apps/open-spark/pages/adminDashboard.tsx index c633cbc3..43a5d0a0 100644 --- a/apps/open-spark/pages/adminDashboard.tsx +++ b/apps/open-spark/pages/adminDashboard.tsx @@ -14,6 +14,7 @@ import Cookies from 'js-cookie' import BecknButton from '@beckn-ui/molecules/src/components/button/Button' import { MdOutlineRefresh } from 'react-icons/md' import { setTradeExecutionProcessed, UserRootState } from '@store/user-slice' +import { testIds } from '@shared/dataTestIds' interface PendingTrades { id: number @@ -130,6 +131,7 @@ const LockDemand = () => { > { className="hideScroll" marginTop={'1rem'} > - +
- +
Unit @@ -166,6 +173,7 @@ const LockDemand = () => { alignItems="center" placeContent={'center'} width={'130px'} + data-test={testIds.total_aggregated_table_consumer} > Consumer @@ -176,6 +184,7 @@ const LockDemand = () => { alignItems="center" placeContent={'center'} width={'70px'} + data-test={testIds.total_aggregated_table_date} > Date @@ -205,6 +214,7 @@ const LockDemand = () => { padding="0" > { padding="0" > { padding="0" > { nav_icon {
{ { + 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) + }) + }) +}) diff --git a/cypress/fixtures/OpenSpark/myTrade/get-pending-empty-trades.json b/cypress/fixtures/OpenSpark/myTrade/get-pending-empty-trades.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/cypress/fixtures/OpenSpark/myTrade/get-pending-empty-trades.json @@ -0,0 +1 @@ +[] diff --git a/cypress/fixtures/OpenSpark/myTrade/get-pending-trades.json b/cypress/fixtures/OpenSpark/myTrade/get-pending-trades.json new file mode 100644 index 00000000..900b3f11 --- /dev/null +++ b/cypress/fixtures/OpenSpark/myTrade/get-pending-trades.json @@ -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" + } + } +] diff --git a/cypress/fixtures/OpenSpark/myTrade/start-trade.json b/cypress/fixtures/OpenSpark/myTrade/start-trade.json new file mode 100644 index 00000000..c4c90bbd --- /dev/null +++ b/cypress/fixtures/OpenSpark/myTrade/start-trade.json @@ -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" + } + ] +} diff --git a/cypress/fixtures/OpenSpark/myTrade/start-trades.json b/cypress/fixtures/OpenSpark/myTrade/start-trades.json new file mode 100644 index 00000000..e69de29b diff --git a/shared/dataTestIds.ts b/shared/dataTestIds.ts index 36d8bc09..c0d1c9d3 100644 --- a/shared/dataTestIds.ts +++ b/shared/dataTestIds.ts @@ -674,6 +674,8 @@ const testIds = { user_validPassword_consumer_flow: 'Test@123', user_validEmail_producer_flow: 'qqq@gmail.com', user_validPassword_producer_flow: 'Test@123', + user_validEmail_admin_flow: 'admin@becknprotocol.io', + 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 }