From 6cf2bfb60d27ed3e8eb09c83570ae818269f887b Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Tue, 18 Aug 2026 11:41:43 +0530 Subject: [PATCH] test: align vitest onboarding expectations with new 7-step onboarding layout --- src/App.test.tsx | 101 +++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/src/App.test.tsx b/src/App.test.tsx index c51a53a..6b020bb 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -103,73 +103,88 @@ describe('Supplier Portal Onboarding & Active Dashboard Tests', () => { const registerBtn = screen.getByRole('button', { name: /Register Business/i }) fireEvent.click(registerBtn) - // Step 1: Contact Verification - expect(await screen.findByText(/Step 1 of 3: Contact Verification/i)).toBeInTheDocument() - + // Step 1: Welcome + expect(await screen.findByText(/Step 1 of 7: Welcome/i)).toBeInTheDocument() + const beginSetupBtn = screen.getByRole('button', { name: /Begin Setup →/i }) + fireEvent.click(beginSetupBtn) + + // Step 2: Business Details + expect(await screen.findByText(/Step 2 of 7: Business Details/i)).toBeInTheDocument() + const taxInput = screen.getByLabelText(/GSTIN Number \*/i) + fireEvent.change(taxInput, { target: { value: '29AAAAA1111A1Z1' } }) + const verifyGstinBtn = screen.getByRole('button', { name: /Submit GSTIN/i }) + fireEvent.click(verifyGstinBtn) + expect(await screen.findByText(/GSTIN verification will be completed within the next 24 hrs/i)).toBeInTheDocument() + const nextStep2Btn = screen.getByRole('button', { name: /Next Step →/i }) + fireEvent.click(nextStep2Btn) + + // Step 3: Identity Verification + expect(await screen.findByText(/Step 3 of 7: Identity Verification/i)).toBeInTheDocument() + const aadharInput = screen.getByLabelText(/Aadhaar Card Upload \*/i) + const panInput = screen.getByLabelText(/PAN Card Upload \*/i) + fireEvent.change(aadharInput, { target: { files: [{ name: 'aadhar_card.pdf' }] } }) + expect(await screen.findByText(/Selected: aadhar_card.pdf/i)).toBeInTheDocument() + fireEvent.change(panInput, { target: { files: [{ name: 'pan_card.pdf' }] } }) + expect(await screen.findByText(/Selected: pan_card.pdf/i)).toBeInTheDocument() + const nextStep3Btn = screen.getByRole('button', { name: /Next Step →/i }) + fireEvent.click(nextStep3Btn) + + // Step 4: Contact Verification + expect(await screen.findByText(/Step 4 of 7: Contact Verification/i)).toBeInTheDocument() const sendWhatsappBtn = screen.getByText(/Send WhatsApp OTP/i) fireEvent.click(sendWhatsappBtn) - const whatsappCodeInput = screen.getByPlaceholderText(/Enter 123456/i) fireEvent.change(whatsappCodeInput, { target: { value: '123456' } }) const verifyWhatsappBtn = screen.getByRole('button', { name: /Verify Code/i }) fireEvent.click(verifyWhatsappBtn) expect(await screen.findByText(/✓ Mobile & WhatsApp Verified/i)).toBeInTheDocument() - + const sendEmailBtn = screen.getByText(/Send Email OTP/i) fireEvent.click(sendEmailBtn) - - // There are now multiple placeholder elements with "Enter 123456". Let's fetch the visible inputs. const codeInputs = screen.getAllByPlaceholderText(/Enter 123456/i) fireEvent.change(codeInputs[codeInputs.length - 1], { target: { value: '123456' } }) const verifyButtons = screen.getAllByRole('button', { name: /Verify Code/i }) fireEvent.click(verifyButtons[verifyButtons.length - 1]) expect(await screen.findByText(/✓ Email Verified/i)).toBeInTheDocument() - - const nextStep1Btn = screen.getByRole('button', { name: /Next Step: Identity Verification/i }) - fireEvent.click(nextStep1Btn) - - // Step 2: Tax & Identity Verification - expect(await screen.findByText(/Step 2 of 3: Tax & Identity Verification/i)).toBeInTheDocument() - - const taxInput = screen.getByLabelText(/GSTIN Number \*/i) - fireEvent.change(taxInput, { target: { value: '29AAAAA1111A1Z1' } }) - const verifyGstinBtn = screen.getByRole('button', { name: /Submit GSTIN/i }) - fireEvent.click(verifyGstinBtn) - expect(await screen.findByText(/verification will be completed within next 24 hrs/i)).toBeInTheDocument() - - // Upload files - const aadharInput = screen.getByLabelText(/Aadhaar Card Upload \*/i) - const panInput = screen.getByLabelText(/PAN Card Upload \*/i) - - // Trigger file changes - fireEvent.change(aadharInput, { target: { files: [{ name: 'aadhar_card.pdf' }] } }) - expect(await screen.findByText(/Selected: aadhar_card.pdf/i)).toBeInTheDocument() - - fireEvent.change(panInput, { target: { files: [{ name: 'pan_card.pdf' }] } }) - expect(await screen.findByText(/Selected: pan_card.pdf/i)).toBeInTheDocument() - - const nextStep2Btn = screen.getByRole('button', { name: /Next Step: Store & Location/i }) - fireEvent.click(nextStep2Btn) - - // Step 3: Store Details & Location Map - expect(await screen.findByText(/Step 3 of 3: Store & Pickup Location/i)).toBeInTheDocument() - + const nextStep4Btn = screen.getByRole('button', { name: /Next Step →/i }) + fireEvent.click(nextStep4Btn) + + // Step 5: Choose Categories + expect(await screen.findByText(/Step 5 of 7: Choose Categories/i)).toBeInTheDocument() + const categoryBtn = screen.getByText('Sustainable Products') + fireEvent.click(categoryBtn) + const nextStep5Btn = screen.getByRole('button', { name: /Next Step →/i }) + fireEvent.click(nextStep5Btn) + + // Step 6: Store Setup + expect(await screen.findByText(/Step 6 of 7: Store Setup/i)).toBeInTheDocument() const storeNameInput = screen.getByLabelText(/Store Display Name \*/i) fireEvent.change(storeNameInput, { target: { value: 'Crafty Store' } }) - - const bioText = screen.getByLabelText(/About Your Craft \/ Business \*/i) + const storeSlugInput = screen.getByLabelText(/Store Slug \/ Custom URL \*/i) + fireEvent.change(storeSlugInput, { target: { value: 'crafty-store' } }) + const supportEmailInput = screen.getByLabelText(/Support Email \*/i) + fireEvent.change(supportEmailInput, { target: { value: 'support@crafty.com' } }) + const supportPhoneInput = screen.getByLabelText(/Support Phone \*/i) + fireEvent.change(supportPhoneInput, { target: { value: '+919876543210' } }) + const bioText = screen.getByLabelText(/Store Description \/ Bio \*/i) fireEvent.change(bioText, { target: { value: 'Handmade pottery.' } }) - - const streetInput = screen.getByLabelText(/Location in Text \(Address\) \*/i) + + const streetInput = screen.getByLabelText(/Pickup Address \*/i) const cityInput = screen.getByLabelText(/City \*/i) + const stateInput = screen.getByLabelText(/State \*/i) const pincodeInput = screen.getByLabelText(/Pincode \*/i) - fireEvent.change(streetInput, { target: { value: '123 Loom Lane' } }) fireEvent.change(cityInput, { target: { value: 'Handloom City' } }) + fireEvent.change(stateInput, { target: { value: 'Karnataka' } }) fireEvent.change(pincodeInput, { target: { value: '560001' } }) - + const submitBtn = screen.getByRole('button', { name: /Submit Supplier Profile/i }) fireEvent.click(submitBtn) + + // Step 7: Success page + expect(await screen.findByText(/Step 7 of 7: Verification/i)).toBeInTheDocument() + const goDashBtn = screen.getByRole('button', { name: /Go to Dashboard/i }) + fireEvent.click(goDashBtn) // Welcome Page & Setup Tour (Account Under Review) expect(await screen.findByText(/Supplier Account Under Review/i)).toBeInTheDocument()