154 lines
7 KiB
TypeScript
154 lines
7 KiB
TypeScript
describe('Supplier Portal Onboarding & Feature E2E Flow', () => {
|
|
it('completes the registration, contact verification, document upload, location pinning, welcome tour, order acceptance, and barcode generation', () => {
|
|
// 1. Visit Landing Page
|
|
cy.visit('/');
|
|
cy.contains('Sell Globally.').should('be.visible');
|
|
|
|
// 2. Registration Page
|
|
cy.contains('Get Started Today').click();
|
|
const randUser = `test_seller_${Date.now()}@example.com`;
|
|
cy.get('input#reg-email').type(randUser);
|
|
cy.get('input#reg-phone').type('9876543210');
|
|
cy.get('input#reg-pass').type('super_secure_pass_123');
|
|
cy.get('input#reg-confirm-pass').type('super_secure_pass_123');
|
|
cy.get('input#reg-policy').check();
|
|
cy.get('button').contains('Register Business').click();
|
|
|
|
// 3. Step 1: Contact Verification
|
|
cy.contains('Step 1 of 3: Contact Verification').should('be.visible');
|
|
cy.contains('Send WhatsApp OTP').click();
|
|
cy.get('input[placeholder="Enter 123456"]').first().type('123456');
|
|
cy.contains('Verify Code').first().click();
|
|
cy.contains('✓ Mobile & WhatsApp Verified').should('be.visible');
|
|
|
|
cy.contains('Send Email OTP').click();
|
|
cy.get('input[placeholder="Enter 123456"]').last().type('123456');
|
|
cy.contains('Verify Code').last().click();
|
|
cy.contains('✓ Email Verified').should('be.visible');
|
|
cy.contains('Next Step: Identity Verification').click();
|
|
|
|
// 4. Step 2: Tax & Identity Verification
|
|
cy.contains('Step 2 of 3: Tax & Identity Verification').should('be.visible');
|
|
cy.get('input#verify-gst').clear().type('29AAAAA1111A1Z1');
|
|
cy.contains('Submit GSTIN').click();
|
|
cy.contains('verification will be completed within next 24 hrs').should('be.visible');
|
|
|
|
// Upload mock Aadhaar & PAN files
|
|
cy.get('input#aadhar-upload').selectFile({
|
|
contents: Cypress.Buffer.from('mock aadhaar pdf'),
|
|
fileName: 'aadhar_card.pdf',
|
|
mimeType: 'application/pdf',
|
|
}, { force: true });
|
|
cy.contains('Selected: aadhar_card.pdf').should('be.visible');
|
|
|
|
cy.get('input#pan-upload').selectFile({
|
|
contents: Cypress.Buffer.from('mock pan pdf'),
|
|
fileName: 'pan_card.pdf',
|
|
mimeType: 'application/pdf',
|
|
}, { force: true });
|
|
cy.contains('Selected: pan_card.pdf').should('be.visible');
|
|
|
|
cy.contains('Next Step: Store & Location').click();
|
|
|
|
// 5. Step 3: Store & Pickup Location Setup
|
|
cy.contains('Step 3 of 3: Store & Pickup Location').should('be.visible');
|
|
cy.get('input#store-name').clear().type('Teak Wood Craft Store');
|
|
cy.get('textarea#store-bio').clear().type('Teak wood hand-carved home decor elements.');
|
|
|
|
// Test interactive map coordinate pinning
|
|
cy.contains('Store Location on Map *').should('be.visible');
|
|
cy.get('span').contains('Click anywhere on the map grid to pin location').parent().click(100, 80);
|
|
cy.contains('Coordinates: Lat').should('be.visible');
|
|
|
|
cy.get('input#location-text').should('not.have.value', '');
|
|
cy.get('input#loc-city').clear().type('Bangalore');
|
|
cy.get('input#loc-pincode').clear().type('560001');
|
|
cy.contains('Submit Supplier Profile').click();
|
|
|
|
// 6. Setup Welcome Tour Stepper
|
|
cy.contains('Supplier Account Under Review ⏳').should('be.visible');
|
|
cy.contains('Start Guided Tour 🎬').click();
|
|
cy.contains('📦 Products & Inventory Management').should('be.visible');
|
|
cy.contains('Next: Order Management').click();
|
|
cy.contains('🚚 Order Acceptance Control').should('be.visible');
|
|
cy.contains('Next: Barcode Generation').click();
|
|
cy.contains('🏷️ Barcode Identification & Tracking').should('be.visible');
|
|
cy.contains('Next: Earnings & Wallet').click();
|
|
cy.contains('💼 Wallet & Payout Withdrawals').should('be.visible');
|
|
cy.contains('Explore Dashboard 🚀').click();
|
|
|
|
// 7. Check Active Dashboard Tab
|
|
cy.contains('Performance Analytics').should('be.visible');
|
|
|
|
// 8. Manage Products tab & Bulk template download
|
|
cy.contains('Manage Products').click();
|
|
cy.contains('Active Inventory').should('be.visible');
|
|
cy.contains('📥 Download Sample Excel Template').click();
|
|
|
|
// 9. Orders Acceptance Flow
|
|
cy.contains('Orders & Transit').click();
|
|
cy.contains('Active Orders & Payout status').should('be.visible');
|
|
cy.contains('Pending Acceptance').should('be.visible');
|
|
cy.get('button').contains('Accept').first().click();
|
|
cy.contains('Ready to Ship').should('be.visible');
|
|
|
|
// 10. Barcode Generator
|
|
cy.contains('Barcode Generator').click();
|
|
cy.contains('Product Barcode Generator').should('be.visible');
|
|
cy.get('select#barcode-product').select(1);
|
|
cy.contains('Generate Barcode Graphic').click();
|
|
cy.contains('Generated Barcode Preview').should('be.visible');
|
|
cy.contains('Print Label').should('be.visible');
|
|
cy.contains('Download SVG').should('be.visible');
|
|
});
|
|
|
|
it('enforces security constraints and validation rules (negative test cases)', () => {
|
|
// 1. Visit Home and verify dashboard components are not in DOM (route guarding)
|
|
cy.visit('/');
|
|
cy.get('.dashboard-container').should('not.exist');
|
|
cy.get('.sidebar-menu').should('not.exist');
|
|
|
|
// 2. Go to Registration
|
|
cy.contains('Get Started Today').click();
|
|
const randSecurityUser = `security_test_${Date.now()}@example.com`;
|
|
cy.get('input#reg-email').type(randSecurityUser);
|
|
cy.get('input#reg-phone').type('9000000000');
|
|
cy.get('input#reg-pass').type('password123');
|
|
cy.get('input#reg-confirm-pass').type('password123');
|
|
cy.get('input#reg-policy').check();
|
|
cy.get('button').contains('Register Business').click();
|
|
|
|
// 3. Step 1: Negative OTP validations
|
|
cy.contains('Step 1 of 3: Contact Verification').should('be.visible');
|
|
|
|
// Proceed button must be disabled initially
|
|
cy.get('button').contains('Next Step: Identity Verification').should('be.disabled');
|
|
|
|
// Submit invalid WhatsApp OTP
|
|
cy.contains('Send WhatsApp OTP').click();
|
|
cy.get('input[placeholder="Enter 123456"]').first().type('000000');
|
|
|
|
// Capture alert for incorrect OTP
|
|
const alertStub = cy.stub();
|
|
cy.on('window:alert', alertStub);
|
|
|
|
cy.contains('Verify Code').first().click().then(() => {
|
|
expect(alertStub).to.have.been.calledWith('Incorrect code. Enter 123456');
|
|
});
|
|
cy.contains('✓ Mobile & WhatsApp Verified').should('not.exist');
|
|
|
|
// Correct the code to enable proceed
|
|
cy.get('input[placeholder="Enter 123456"]').first().clear().type('123456');
|
|
cy.contains('Verify Code').first().click();
|
|
cy.contains('✓ Mobile & WhatsApp Verified').should('be.visible');
|
|
|
|
// Submit invalid Email OTP
|
|
cy.contains('Send Email OTP').click();
|
|
cy.get('input[placeholder="Enter 123456"]').last().type('999999');
|
|
cy.contains('Verify Code').last().click().then(() => {
|
|
expect(alertStub).to.have.been.calledWith('Incorrect code. Enter 123456');
|
|
});
|
|
cy.contains('✓ Email Verified').should('not.exist');
|
|
cy.get('button').contains('Next Step: Identity Verification').should('be.disabled');
|
|
});
|
|
});
|