adding beta stage implementation
Some checks failed
Production CI/CD Pipeline / build-and-test (push) Failing after 3s
Production CI/CD Pipeline / deploy-prod (push) Has been skipped

This commit is contained in:
vickytechkey 2026-08-09 12:29:56 +05:30
parent d45ae569d1
commit b54a897b88
4 changed files with 157 additions and 12 deletions

80
cypress/e2e/api.cy.ts Normal file
View file

@ -0,0 +1,80 @@
describe('Seller Central Django Backend API E2E Tests', () => {
const backendUrl = 'http://localhost:8000/api';
it('verifies product list', () => {
cy.request({
method: 'GET',
url: `${backendUrl}/products/`
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.be.an('array');
});
});
it('creates and deletes a product', () => {
const testSku = `CY-SKU-${Date.now()}`;
cy.request({
method: 'POST',
url: `${backendUrl}/products/`,
body: {
title: 'Cypress Test Pot',
category: 'Home Decor',
price: '45.00',
stock: 5,
sku: testSku
}
}).then((response) => {
expect(response.status).to.eq(201);
expect(response.body.sku).to.eq(testSku);
const productId = response.body.id;
// Delete the product
cy.request({
method: 'DELETE',
url: `${backendUrl}/products/${productId}/`
}).then((delResponse) => {
expect(delResponse.status).to.eq(204);
});
});
});
it('verifies order list and acceptance', () => {
cy.request({
method: 'GET',
url: `${backendUrl}/orders/`
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.be.an('array');
const order = response.body.find((o: any) => o.status === 'Pending Acceptance');
if (order) {
cy.request({
method: 'POST',
url: `${backendUrl}/orders/${order.id}/accept/`
}).then((acceptResponse) => {
expect(acceptResponse.status).to.eq(200);
expect(acceptResponse.body.status).to.eq('Ready to Ship');
});
}
});
});
it('verifies wallet summary and payout withdrawal', () => {
cy.request({
method: 'GET',
url: `${backendUrl}/wallet/`
}).then((response) => {
expect(response.status).to.eq(200);
const initialOutstanding = parseFloat(response.body.outstanding);
if (initialOutstanding > 10) {
cy.request({
method: 'POST',
url: `${backendUrl}/wallet/withdraw/`,
body: { amount: '10.00' }
}).then((withdrawResponse) => {
expect(withdrawResponse.status).to.eq(200);
expect(parseFloat(withdrawResponse.body.outstanding)).to.eq(initialOutstanding - 10);
});
}
});
});
});

View file

@ -1,5 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react'
import { describe, it, expect, vi, beforeAll } from 'vitest'
import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'
import App from './App'
// Mock window.scrollTo since jsdom does not implement it
@ -7,6 +7,10 @@ beforeAll(() => {
window.scrollTo = vi.fn()
})
beforeEach(() => {
localStorage.clear()
})
describe('Supplier Portal Onboarding & Active Dashboard Tests', () => {
it('renders landing page with correct primary titles', () => {
render(<App />)

View file

@ -40,16 +40,41 @@ interface ReturnRequest {
}
export default function App() {
const [currentPage, setCurrentPage] = useState<Page>('home')
const [currentPage, setCurrentPage] = useState<Page>(() => {
if (typeof window !== 'undefined') {
return (localStorage.getItem('seller_page') as Page) || 'home'
}
return 'home'
})
const [activeTab, setActiveTab] = useState<'login' | 'register'>('login')
// Onboarding Status
const [isProfileComplete, setIsProfileComplete] = useState(false)
const [profileStep, setProfileStep] = useState(1)
const [isProfileComplete, setIsProfileComplete] = useState<boolean>(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('seller_is_profile_complete') === 'true'
}
return false
})
const [profileStep, setProfileStep] = useState<number>(() => {
if (typeof window !== 'undefined') {
return Number(localStorage.getItem('seller_profile_step')) || 1
}
return 1
})
// Registration / Onboarding Form States
const [email, setEmail] = useState('')
const [phone, setPhone] = useState('')
const [email, setEmail] = useState(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('seller_email') || ''
}
return ''
})
const [phone, setPhone] = useState(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('seller_phone') || ''
}
return ''
})
const [password, setPassword] = useState('')
// Step 1: Verification
@ -67,7 +92,12 @@ export default function App() {
const [panFile, setPanFile] = useState<string | null>(null)
// Step 3: Store and Location details
const [storeName, setStoreName] = useState('My Artisan Handloom')
const [storeName, setStoreName] = useState(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('seller_store_name') || 'My Artisan Handloom'
}
return 'My Artisan Handloom'
})
const [storeLogo, setStoreLogo] = useState<string | null>(null)
const [businessBio, setBusinessBio] = useState('Traditional weaving and local sustainable designs.')
const [address, setAddress] = useState({
@ -159,32 +189,55 @@ export default function App() {
const publicPages: Page[] = ['home', 'about', 'contact', 'login', 'signup', 'forgot-password', 'login-otp']
const complete = isProfileComplete || forceComplete
let target = page
if (!complete && !publicPages.includes(page) && page !== 'profile-completion') {
alert('Access Denied: Please complete your supplier profile first!')
setCurrentPage('profile-completion')
} else {
setCurrentPage(page)
target = 'profile-completion'
}
setCurrentPage(target)
localStorage.setItem('seller_page', target)
window.scrollTo({ top: 0, behavior: 'smooth' })
}
const handleLogout = () => {
localStorage.clear()
setIsProfileComplete(false)
setProfileStep(1)
setEmail('')
setPhone('')
setPassword('')
setStoreName('My Artisan Handloom')
navigateTo('home')
}
const handleRegisterSubmit = (e: React.FormEvent) => {
e.preventDefault()
localStorage.setItem('seller_email', email)
localStorage.setItem('seller_phone', phone)
navigateTo('profile-completion')
}
const handleLoginSubmit = (e: React.FormEvent) => {
e.preventDefault()
setIsProfileComplete(true)
localStorage.setItem('seller_is_profile_complete', 'true')
localStorage.setItem('seller_email', email)
navigateTo('dashboard', true)
}
const handleProfileSubmit = (e: React.FormEvent) => {
e.preventDefault()
if (profileStep < 3) {
setProfileStep(prev => prev + 1)
const nextStep = profileStep + 1
setProfileStep(nextStep)
localStorage.setItem('seller_profile_step', String(nextStep))
} else {
setIsProfileComplete(true)
localStorage.setItem('seller_is_profile_complete', 'true')
localStorage.setItem('seller_store_name', storeName)
localStorage.setItem('seller_phone', phone)
localStorage.setItem('seller_email', email)
navigateTo('welcome-tour', true)
}
}
@ -328,7 +381,7 @@ export default function App() {
</nav>
<div className="nav-buttons">
{currentPage === 'dashboard' ? (
<button className="btn btn-secondary" onClick={() => navigateTo('home')}>
<button className="btn btn-secondary" onClick={handleLogout}>
Logout
</button>
) : (

View file

@ -1,4 +1,12 @@
const getApiBaseUrl = () => {
if (typeof window !== 'undefined' && window.location.hostname === 'betasuppliers.tipro.in') {
return 'http://16.113.57.127:8000';
}
return 'http://localhost:8000';
};
export const CONFIG = {
apiBaseUrl: getApiBaseUrl(),
companyName: 'Global Artisans Hub',
logoLetter: 'A',
supportEmail: 'support@globalartisanshub.com',