Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,9 @@ export class BasePage {
}

// assert element to be visible
async toBeVisible(selector: string, options?: { timeout?: number; visible?: boolean } | undefined) {
await expect(this.page.locator(selector)).toBeVisible(options);
async toBeVisible(selector: string, options?: { timeout?: number; visible?: boolean }) {
const locator = this.page.locator(selector);
await locator.waitFor({ state: 'visible', timeout: options?.timeout ?? 15000 });
}

// assert checkbox to be checked
Expand Down
35 changes: 23 additions & 12 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ export const selector = {
result: 'li.select2-results__option.select2-results__option--highlighted',
},

searchTicket: '#post-search-input',
searchTicket: '(//p[contains(@class, "search-box")]/input[@id="post-search-input"])[1]',

// Table
table: {
Expand Down Expand Up @@ -927,8 +927,8 @@ export const selector = {
summaryHeading: 'span.dokan-chat-summary',
summaryArrow: 'span.dokan-summary-arrow',

ticketId: 'div.dokan-summary-info.ticket-id',
vendorInfo: 'div.dokan-summary-info.dokan-vendor-info',
ticketId: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "ticket-id")])[1]',
vendorInfo: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "dokan-vendor-info")])[1]',
Comment on lines +930 to +931
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Stabilize ticket summary locators; drop [1] and scope to the summary container.

Indexing [1] is order‑dependent and flaky. Scope by parent to make it deterministic.

-                        ticketId: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "ticket-id")])[1]',
-                        vendorInfo: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "dokan-vendor-info")])[1]',
+                        ticketId: 'div.dokan-chat-summary-holder .dokan-summary-info.ticket-id',
+                        vendorInfo: 'div.dokan-chat-summary-holder .dokan-summary-info.dokan-vendor-info',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ticketId: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "ticket-id")])[1]',
vendorInfo: '(//div[contains(@class, "dokan-summary-info") and contains(@class, "dokan-vendor-info")])[1]',
ticketId: 'div.dokan-chat-summary-holder .dokan-summary-info.ticket-id',
vendorInfo: 'div.dokan-chat-summary-holder .dokan-summary-info.dokan-vendor-info',
🤖 Prompt for AI Agents
In tests/pw/pages/selectors.ts around lines 930-931, the ticket summary locators
use an index ([1]) which is order-dependent and flaky; remove the trailing [1]
and instead scope each locator to the summary container selector (find the
summary container element once and build ticketId and vendorInfo as children of
that container) so the locators become deterministic and reference the summary
parent rather than relying on global indexing.

customerInfo: 'div.dokan-summary-info.dokan-customer-info',
messageCount: 'div.dokan-summary-info.conversation',
createdAt: '//div[normalize-space()="Created At:"]/..//div[@class="dokan-summary-info created-at"]',
Expand Down Expand Up @@ -3072,19 +3072,19 @@ export const selector = {
metaBoxDiv: '#dokan_commission_box',
commissionsHeader: '#dokan_commission_box h2.hndle', // "Commissions" header
table: {
itemColumn: '#dokan_commission_box th:has-text("Item")',
typeColumn: '#dokan_commission_box th:has-text("Type")',
rateColumn: '#dokan_commission_box th:has-text("Rate")',
qtyColumn: '#dokan_commission_box th:has-text("Qty")',
commissionColumn: '#dokan_commission_box th:has-text("Commission")',
itemColumn: '#dokan_commission_box th:has-text("Item")',
typeColumn: '#dokan_commission_box th:has-text("Type")',
rateColumn: '#dokan_commission_box th:has-text("Rate")',
qtyColumn: '#dokan_commission_box th:has-text("Qty")',
commissionColumn: '#dokan_commission_box th:has-text("Commission")',
},
orderItemsTable: '#dokan_commission_box table.dokan_order_items',
orderLineItems: '#dokan_commission_box tbody#order_line_items tr.item',
orderTotals: '#dokan_commission_box div.wc-order-totals-items table.wc-order-totals',
netTotal: '#dokan_commission_box td.label:has-text("Net total:") + td + td.total',
vendorEarning: '#dokan_commission_box td.label:has-text("Vendor earning:") + td + td.total',
totalCommission: '#dokan_commission_box td.label:has-text("Total commission:") + td + td.total',
},
},

subOrdersMetaBox: {
metaBoxDiv: 'div#dokan_sub_or_related_orders',
Expand Down Expand Up @@ -6007,16 +6007,25 @@ export const selector = {
openTickets: '//ul[contains(@class,"dokan-support-topic-counts")]//a[contains(text(), "Open Tickets")]',
closedTickets: '//ul[contains(@class,"dokan-support-topic-counts")]//a[contains(text(), "Closed Tickets")]',
},

newMenus: {
allTickets: 'role=button[name^="All"]',
openTickets: 'role=button[name^="Open"]',
closedTickets: 'role=button[name^="Closed"]',
},
// Filter
filters: {
filterByCustomer: '//select[@id="dokan-search-support-customers"]/..//span[@class="select2-selection__arrow"]',
filterByCustomerNew: '//div[normalize-space(text())="Search customer"]',
filterByCustomerInput: '.select2-search__field',
filterByCustomerInputNew: 'input#dokan-filter-by-customer',

filterByDate: {
dateRangeInput: 'input#support_ticket_date_filter',
dateRangeInputNew: 'role=button[name="Select date range"]',
startDateInput: 'input#support_ticket_start_date_filter_alt',
startDateInputNew: 'input#dokan-daterange-start',
endDateInput: 'input#support_ticket_end_date_filter_alt',
endDateInputNew: 'input#dokan-daterange-end',
},

tickedIdOrKeyword: '#dokan-support-ticket-search-input',
Expand Down Expand Up @@ -7158,8 +7167,10 @@ export const selector = {

orderReference: {
orderReferenceSpan: 'span.order-reference',
orderReferenceText: (orderId: string) => `//strong[normalize-space()="Referenced Order #${orderId}"]`,
orderReferenceLink: (orderId: string) => `//strong[normalize-space()="Referenced Order #${orderId}"]/..`,
orderReferenceText: (orderId: string) =>
`//strong[contains(normalize-space(), "Referenced Order #${orderId}")]`,
orderReferenceLink: (orderId: string) =>
`//strong[contains(normalize-space(), "Referenced Order #${orderId}")]/..`,
},

chatBox: {
Expand Down
59 changes: 45 additions & 14 deletions tests/pw/pages/storeSupportsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,46 @@ export class StoreSupportsPage extends AdminPage {
// vendor

// vendor store support render properly
async vendorStoreSupportRenderProperly() {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.storeSupport);

async vendorStoreSupportRenderProperly(newUI?: boolean) {
if(newUI)
await this.goIfNotThere(data.subUrls.frontend.vDashboard.storeSupportNew);
else
await this.goIfNotThere(data.subUrls.frontend.vDashboard.storeSupport);
// store support menu elements are visible
await this.multipleElementVisible(storeSupportsVendor.menus);

const { filterByCustomerInput, filterByDate, result, ...filters } = storeSupportsVendor.filters;
await this.toBeVisible(storeSupportsVendor.filters.filterByDate.dateRangeInput);
await this.multipleElementVisible(filters);
await this.multipleElementVisible(storeSupportsVendor.newMenus);

if (newUI) {
// For new UI, use the new selectors
await this.toBeVisible(storeSupportsVendor.filters.filterByDate.dateRangeInputNew);
await this.toBeVisible(storeSupportsVendor.filters.filterByCustomerInputNew);
// Check if search elements exist (they might not be present in new UI)
const searchInputExists = await this.isVisible(storeSupportsVendor.filters.tickedIdOrKeyword);
if (searchInputExists) {
await this.toBeVisible(storeSupportsVendor.filters.tickedIdOrKeyword);
}
const searchButtonExists = await this.isVisible(storeSupportsVendor.filters.search);
if (searchButtonExists) {
await this.toBeVisible(storeSupportsVendor.filters.search);
}
} else {
// For old UI, use the old selectors
const { filterByCustomerInput, filterByDate, result, ...filters } = storeSupportsVendor.filters;
await this.multipleElementVisible(filters);
}

const noSupportTicket = await this.isVisible(storeSupportsVendor.noSupportTicketFound);
if (noSupportTicket) {
console.log('No Support Tickets Found!!');
return;
}

// store support table elements are visible
await this.multipleElementVisible(storeSupportsVendor.table);
// store support table elements are visible (check if table exists)
const tableExists = await this.isVisible(storeSupportsVendor.table.table);
if (tableExists) {
await this.multipleElementVisible(storeSupportsVendor.table);
} else {
console.log('Support table not found - might be using different UI structure');
}
}

// vendor view support ticket details
Expand Down Expand Up @@ -475,11 +497,20 @@ export class StoreSupportsPage extends AdminPage {
}

// customer cant send message to closed support ticket
async viewOrderReferenceNumberOnSupportTicket(supportTicketId: string, orderId: string): Promise<void> {
formatOrderId(orderId: number | string): string {
return Number(orderId).toLocaleString(); // adds commas automatically
}

async viewOrderReferenceNumberOnSupportTicket(supportTicketId: string, orderId: string | number): Promise<void> {
const formattedOrderId = this.formatOrderId(orderId);

await this.goIfNotThere(data.subUrls.frontend.supportTicketDetails(supportTicketId));
await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceSpan);
await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceText(orderId));
await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceLink(orderId));

const orderRef = supportsTicketsCustomer.supportTicketDetails.orderReference;

await this.toBeVisible(orderRef.orderReferenceSpan);
await this.toBeVisible(orderRef.orderReferenceText(formattedOrderId));
await this.toBeVisible(orderRef.orderReferenceLink(formattedOrderId));
}

// customer send message to support ticket
Expand Down
Loading
Loading