From 68bba1c9052ffc59cdbf09ea4de7788cdbf614ef Mon Sep 17 00:00:00 2001 From: Ikechukwu-Patrick <151846949+Ikechukwu-Patrick@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:57:09 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01dc33c..4920cde 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This repository (`SwiftChain-Frontend`) contains the frontend application built ## 🚀 Project Overview ### Core Problem - +//Temproary fix for pr and commit Traditional logistics systems suffer from: - Lack of trust between senders and independent drivers. From 751e3b5b68484958cc8973a12f4d57e7890d1a4d Mon Sep 17 00:00:00 2001 From: Ikechukwu-Patrick Date: Tue, 1 Sep 2026 10:46:45 +0100 Subject: [PATCH 2/2] Test: Implement E2E: Driver Job Marketplace Filtering and Bidding --- cypress/e2e/driver-marketplace.cy.ts | 99 ++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 cypress/e2e/driver-marketplace.cy.ts diff --git a/cypress/e2e/driver-marketplace.cy.ts b/cypress/e2e/driver-marketplace.cy.ts new file mode 100644 index 0000000..31df1dc --- /dev/null +++ b/cypress/e2e/driver-marketplace.cy.ts @@ -0,0 +1,99 @@ +// cypress/e2e/driver-marketplace.cy.ts + +describe('E2E: Driver Job Marketplace Filtering and Bidding', () => { + beforeEach(() => { + // Mock driver session + cy.window().then((win) => { + win.localStorage.setItem('role', 'driver'); + win.localStorage.setItem('token', 'mock-driver-jwt'); + }); + + // Mock external API dependencies + cy.intercept('GET', '**/api/jobs*', { + statusCode: 200, + body: { + jobs: [ + { id: '1', origin: 'Lagos', destination: 'Abuja', cargoType: 'Heavy', payout: '50000' }, + { id: '2', origin: 'Ibadan', destination: 'Kano', cargoType: 'Standard', payout: '25000' } + ] + } + }).as('fetchJobs'); + + cy.intercept('POST', '**/api/jobs/*/bid', { + statusCode: 200, + body: { success: true, message: 'Bid submitted successfully' } + }).as('submitBid'); + + cy.visit('/marketplace'); + }); + + it('applies cargo and location filters to the marketplace list', () => { + cy.wait('@fetchJobs'); + + // Apply cargo type filter + cy.get('select[name="cargoType"], select[id="cargoType"]').select('Heavy'); + + // Apply location filter + cy.get('input[name="location"], input[id="location"]').type('Lagos'); + + cy.get('button').contains(/apply filters/i).click(); + + // Verify the UI updates to reflect the filtered state + // (Assuming the frontend sends updated query params to the mocked endpoint) + cy.get('[data-testid="job-card"]').should('have.length.at.least', 1); + cy.get('[data-testid="job-card"]').first().should('contain.text', 'Lagos'); + cy.get('[data-testid="job-card"]').first().should('contain.text', 'Heavy'); + }); + + it('successfully opens the bid modal and submits a valid bid', () => { + cy.wait('@fetchJobs'); + + // Open bid modal for the first available job + cy.get('[data-testid="job-card"]').first().find('button').contains(/place bid/i).click(); + + // Fill out the bidding form + cy.get('input[name="bidAmount"]').type('45000'); + cy.get('textarea[name="proposal"]').type('Available for immediate pickup with a 5-ton truck.'); + + // Submit the bid + cy.get('button[type="submit"]').contains(/submit bid/i).click(); + + // Wait for the mutation and verify success state + cy.wait('@submitBid').its('request.body').should('deep.include', { + bidAmount: 45000, + proposal: 'Available for immediate pickup with a 5-ton truck.' + }); + + cy.contains(/bid submitted successfully/i).should('be.visible'); + cy.get('[data-testid="bid-modal"]').should('not.exist'); + }); + + it('displays validation errors for an invalid bid amount', () => { + cy.wait('@fetchJobs'); + + cy.get('[data-testid="job-card"]').first().find('button').contains(/place bid/i).click(); + + // Submit a bid without an amount + cy.get('button[type="submit"]').contains(/submit bid/i).click(); + + // Assert validation error + cy.contains(/bid amount is required/i).should('be.visible'); + }); + + it('handles server rejection gracefully', () => { + cy.wait('@fetchJobs'); + + // Override the successful mock with a server error + cy.intercept('POST', '**/api/jobs/*/bid', { + statusCode: 400, + body: { success: false, message: 'Bid amount is too high for this route' } + }).as('submitBidError'); + + cy.get('[data-testid="job-card"]').first().find('button').contains(/place bid/i).click(); + cy.get('input[name="bidAmount"]').type('999999'); + cy.get('button[type="submit"]').contains(/submit bid/i).click(); + + cy.wait('@submitBidError'); + cy.contains(/bid amount is too high for this route/i).should('be.visible'); + }); +}); \ No newline at end of file