-
Notifications
You must be signed in to change notification settings - Fork 215
Add end-to-end tests for vendor delivery time settings React #2770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { test, Page, expect } from "@playwright/test"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { data } from '@utils/testData'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { VendorPage } from '@pages/vendorPage'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test.describe('Delivery time test', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let vendor: VendorPage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let aPage: Page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test.beforeAll(async ({ browser }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const vendorContext = await browser.newContext(data.auth.vendorAuth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aPage = await vendorContext.newPage(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vendor = new VendorPage(aPage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test.afterAll(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.close(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('vendor can go to dashboard page and successfully found the heading', { tag: ['@pro', '@vendor'] }, async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await vendor.goToVendorDashboard(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('link', { name: ' Delivery Time' }).first().click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Wait for 5 seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.waitForTimeout( 3000 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Look for h3 inside dokan-header-title with text 'Delivery Time & Store Pickup' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const headerTitle = aPage.locator('.dokan-header-title h3:has-text("Delivery Time & Store Pickup")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(headerTitle).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.locator('.css-1nxca15-UA').click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('option', { name: 'Delivery' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Filter' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.locator('.css-1nxca15-UA').click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('option', { name: 'Store Pickup' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Filter' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.locator('.css-1nxca15-UA').click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('option', { name: 'All Events' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Filter' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Refactor repetitive dropdown interactions and avoid brittle CSS selectors. The CSS class -await aPage.locator('.css-1nxca15-UA').click();
-await aPage.getByRole('option', { name: 'Delivery' }).click();
-await aPage.getByRole('button', { name: 'Filter' }).click();
-await aPage.locator('.css-1nxca15-UA').click();
-await aPage.getByRole('option', { name: 'Store Pickup' }).click();
-await aPage.getByRole('button', { name: 'Filter' }).click();
-await aPage.locator('.css-1nxca15-UA').click();
-await aPage.getByRole('option', { name: 'All Events' }).click();
-await aPage.getByRole('button', { name: 'Filter' }).click();
+// Use a more stable selector and extract to helper method
+const selectDeliveryFilter = async (optionName: string) => {
+ await aPage.getByRole('combobox', { name: 'Event Type Filter' }).click();
+ await aPage.getByRole('option', { name: optionName }).click();
+ await aPage.getByRole('button', { name: 'Filter' }).click();
+};
+
+await selectDeliveryFilter('Delivery');
+await selectDeliveryFilter('Store Pickup');
+await selectDeliveryFilter('All Events');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'week' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'day', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'list' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Next month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Next month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Previous month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Previous month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Previous month' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'today' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add assertions for calendar view interactions. The test interacts with multiple calendar controls but doesn't verify that the interactions actually work. Consider adding assertions to validate the UI state changes. await aPage.getByRole('button', { name: 'week' }).click();
+await expect(aPage.getByRole('button', { name: 'week' })).toHaveClass(/active|selected/);
+
await aPage.getByRole('button', { name: 'day', exact: true }).click();
+await expect(aPage.getByRole('button', { name: 'day', exact: true })).toHaveClass(/active|selected/);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('vendor can go to delivery time settings and verify labels', { tag: ['@pro', '@vendor'] }, async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await vendor.goIfNotThere(data.subUrls.frontend.vDashboard.settingsDeliveryTimeReact); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Wait for the page to load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.waitForTimeout(3000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace hard-coded timeout with explicit wait. Another hard-coded timeout that should be replaced with proper wait conditions. -// Wait for the page to load
-await aPage.waitForTimeout(3000);
+// Wait for the delivery time settings page to load
+await aPage.waitForSelector('.dokan-header-title h3');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Look for h3 inside dokan-header-title with text 'Delivery Time & Store Pickup' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const headerTitle = aPage.locator('.dokan-header-title h3:has-text("Delivery Time & Store Pickup")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(headerTitle).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check for the presence of the specified labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const deliverySupportLabel = aPage.locator('label:has-text("Delivery Support:")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(deliverySupportLabel).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const deliveryBlockedBufferLabel = aPage.locator('label:has-text("Delivery blocked buffer :")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(deliveryBlockedBufferLabel).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const timeSlotLabel = aPage.locator('label:has-text("Time slot :")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(timeSlotLabel).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const orderPerSlotLabel = aPage.locator('label:has-text("Order per slot :")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(orderPerSlotLabel).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('checkbox', { name: 'Home Delivery' }).check(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('checkbox', { name: 'Home Delivery' }).uncheck(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('checkbox', { name: 'Store Pickup' }).check(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('checkbox', { name: 'Store Pickup' }).uncheck(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Delivery blocked buffer :' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Delivery blocked buffer :' }).fill('10'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Time slot :' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Time slot :' }).press('ControlOrMeta+a'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Time slot :' }).fill('60'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Order per slot :' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Order per slot :' }).press('ControlOrMeta+a'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('spinbutton', { name: 'Order per slot :' }).fill('1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+76
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve form interaction reliability. The form interactions could be more robust with proper waits and state verification. await aPage.getByRole('checkbox', { name: 'Home Delivery' }).check();
+await expect(aPage.getByRole('checkbox', { name: 'Home Delivery' })).toBeChecked();
+
await aPage.getByRole('checkbox', { name: 'Home Delivery' }).uncheck();
+await expect(aPage.getByRole('checkbox', { name: 'Home Delivery' })).not.toBeChecked();
+
await aPage.getByRole('checkbox', { name: 'Store Pickup' }).check();
+await expect(aPage.getByRole('checkbox', { name: 'Store Pickup' })).toBeChecked();
+
await aPage.getByRole('checkbox', { name: 'Store Pickup' }).uncheck();
+await expect(aPage.getByRole('checkbox', { name: 'Store Pickup' })).not.toBeChecked();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.getByRole('button', { name: 'Save Changes' }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await aPage.waitForTimeout(100); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const successMessage = aPage.locator('p:has-text("Delivery settings has been saved successfully!")'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(successMessage).toBeVisible(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace minimal timeout with proper wait condition. The 100ms timeout before checking the success message is too short and unreliable. -await aPage.waitForTimeout(100);
-const successMessage = aPage.locator('p:has-text("Delivery settings has been saved successfully!")');
-await expect(successMessage).toBeVisible();
+// Wait for the success message to appear after save
+const successMessage = aPage.locator('p:has-text("Delivery settings has been saved successfully!")');
+await expect(successMessage).toBeVisible({ timeout: 10000 });📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Replace hard-coded timeout with explicit wait.
Hard-coded timeouts make tests flaky and slower. Use explicit waits for better reliability.
📝 Committable suggestion
🤖 Prompt for AI Agents