updates on the ui and updates agents
This commit is contained in:
@@ -97,6 +97,7 @@ const fillValidForm = async () => {
|
||||
fill('Mobile number', '98765 43210');
|
||||
fill('Login email', ' Ops@Acme.Example ');
|
||||
fill('Operating city', '1');
|
||||
fill('What do they deliver', 'Clothing');
|
||||
fireEvent.change(document.getElementById('onboard-password'), { target: { value: 's3cure-pass' } });
|
||||
fill('Confirm password', 's3cure-pass');
|
||||
fireEvent.click(screen.getAllByRole('button', { name: 'Pick Client address' })[0]);
|
||||
@@ -221,6 +222,7 @@ describe('Client onboarding page', () => {
|
||||
phone: '9876543210',
|
||||
password: 's3cure-pass',
|
||||
applocationid: 1,
|
||||
deliverycategory: 'Clothing',
|
||||
requiredeliveryotp: false,
|
||||
address: '14 DB Road, RS Puram, Coimbatore',
|
||||
city: 'Coimbatore',
|
||||
@@ -263,6 +265,7 @@ describe('Client onboarding page', () => {
|
||||
fill('Mobile number', '9876543210');
|
||||
fill('Login email', 'ops@acme.example');
|
||||
fill('Operating city', '1');
|
||||
fill('What do they deliver', 'Clothing');
|
||||
fireEvent.change(document.getElementById('onboard-password'), { target: { value: 's3cure-pass' } });
|
||||
fill('Confirm password', 's3cure-pass');
|
||||
// Typed, never picked: no map location.
|
||||
@@ -281,6 +284,41 @@ describe('Client onboarding page', () => {
|
||||
expect(await screen.findByText('5 Avinashi Road · 641004')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// The feature itself: what they ship decides whether returns apply.
|
||||
it('offers reverse logistics for a clothing client', async () => {
|
||||
renderPage();
|
||||
await fillValidForm();
|
||||
fill('What do they deliver', 'Clothing');
|
||||
expect(await screen.findByText(/Reverse logistics available/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/can be returned to this client/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// A returned meal is waste, not inventory — nothing to restock or resell.
|
||||
it('withdraws reverse logistics for a food client, and says why', async () => {
|
||||
renderPage();
|
||||
await fillValidForm();
|
||||
fill('What do they deliver', 'Food');
|
||||
expect(await screen.findByText(/No reverse logistics/i)).toBeInTheDocument();
|
||||
// Stated, not silently hidden: an absent row reads as an oversight, and the
|
||||
// operator needs to know before promising a client a return path.
|
||||
expect(screen.getByText(/cannot be restocked or resold/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('says nothing about returns until a category is chosen', () => {
|
||||
renderPage();
|
||||
expect(screen.queryByText(/Reverse logistics available/i)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/No reverse logistics/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('refuses to submit without a delivery category', async () => {
|
||||
renderPage();
|
||||
await fillValidForm();
|
||||
fill('What do they deliver', '');
|
||||
fireEvent.click(screen.getByRole('button', { name: /Onboard client/ }));
|
||||
expect(await screen.findByText(/choose what this client delivers/i)).toBeInTheDocument();
|
||||
expect(api.onboardClient).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('puts a server conflict under the field it is about', async () => {
|
||||
api.onboardClient.mockRejectedValue({ response: { status: 409, data: { success: false, message: 'this email already has a console login' } } });
|
||||
renderPage();
|
||||
@@ -359,7 +397,7 @@ describe('client onboarding helpers', () => {
|
||||
expect(pw).toMatch(/\d/);
|
||||
expect(pw).toMatch(/[a-z]/i);
|
||||
const errors = validateOnboarding({
|
||||
companyname: 'Acme', contactname: 'Priya', email: 'a@b.co', phone: '9876543210', applocationid: 1, password: pw, confirm: pw,
|
||||
companyname: 'Acme', contactname: 'Priya', email: 'a@b.co', phone: '9876543210', applocationid: 1, deliverycategory: 'Clothing', password: pw, confirm: pw,
|
||||
address: '14 DB Road, RS Puram', pincode: '641002', latitude: 11.009, longitude: 76.95,
|
||||
});
|
||||
expect(errors).toEqual({});
|
||||
@@ -374,7 +412,7 @@ describe('client onboarding helpers', () => {
|
||||
});
|
||||
|
||||
it('mirrors the server rules', () => {
|
||||
const base = { companyname: 'Acme', contactname: 'Priya', email: 'a@b.co', phone: '9876543210', applocationid: 1, password: 'longenough1', confirm: 'longenough1' };
|
||||
const base = { companyname: 'Acme', contactname: 'Priya', email: 'a@b.co', phone: '9876543210', applocationid: 1, deliverycategory: 'Clothing', password: 'longenough1', confirm: 'longenough1' };
|
||||
expect(validateOnboarding({ ...base, phone: '5876543210' }).phone).toBeTruthy();
|
||||
expect(validateOnboarding({ ...base, email: 'Ops <a@b.co>' }).email).toBeTruthy();
|
||||
expect(validateOnboarding({ ...base, password: 'a@b.co', confirm: 'a@b.co' }).password).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user