-
Notifications
You must be signed in to change notification settings - Fork 204
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
Mark Order As Received Test Automation #2320
base: develop
Are you sure you want to change the base?
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,32 @@ | ||
import { BasePage } from '@pages/basePage'; | ||
import { Page } from '@playwright/test'; | ||
|
||
export default class MyAccountAuthPage extends BasePage { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
usernameInputField() { | ||
return this.page.locator('#username'); | ||
} | ||
|
||
passwordInputField() { | ||
return this.page.locator('#password'); | ||
} | ||
|
||
loginButton() { | ||
return this.page.locator('//button[@name="login"]'); | ||
} | ||
|
||
async enterUsername(username: string) { | ||
await this.usernameInputField().fill(username); | ||
} | ||
|
||
async enterPassword(password: string) { | ||
await this.passwordInputField().fill(password); | ||
} | ||
|
||
async clickOnLoginButton() { | ||
await this.loginButton().click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class AllMyOrdersPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor is redundant as it only calls the parent constructor without adding any additional logic. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
viewButtonByOrderId(orderId: string) { | ||||||||
return this.page.locator(`//td[@class="order-number"]/a[contains(text(), "${orderId}")]/../following-sibling::td[5]/a`); | ||||||||
} | ||||||||
|
||||||||
async clickOnViewButtonByOrderId(orderId: string) { | ||||||||
await this.viewButtonByOrderId(orderId).click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class CustomerOrderDetailsPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor is unnecessary as it only calls the parent constructor. Simplify the code by removing it. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
orderReceivedButtonByShipmentNumber(shipmentNumber: string) { | ||||||||
return this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/strong[@class="customer-status"]`); | ||||||||
} | ||||||||
|
||||||||
trackingStatusByShipmentNumber(shipmentNumber: string) { | ||||||||
return this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/p/strong`); | ||||||||
} | ||||||||
|
||||||||
dialogueBoxOkButton() { | ||||||||
return this.page.locator('//div[@role="dialog"]/div[6]/button[text()="OK"]'); | ||||||||
} | ||||||||
|
||||||||
async markOrderAsReceived(shipmentNumber: string) { | ||||||||
await this.orderReceivedButtonByShipmentNumber(shipmentNumber).click(); | ||||||||
} | ||||||||
|
||||||||
async clickOnDialogBoxOkButton() { | ||||||||
await this.dialogueBoxOkButton().click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class VendorDashboardSidebarPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor does not add any new functionality and can be safely removed. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
sidebarMenu(title: string) { | ||||||||
return this.page.locator(`//li[@class="${title}"]/a`); | ||||||||
} | ||||||||
|
||||||||
async clickOnOrdersTab() { | ||||||||
await this.sidebarMenu('orders').click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class VendorAllOrdersPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor is redundant as it only calls the parent constructor without adding any additional logic. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
orderTitleById(orderId: string) { | ||||||||
return this.page.locator(`//td[@data-title="Order"]/a/strong[text()="Order ${orderId}"]`); | ||||||||
} | ||||||||
|
||||||||
async clickOnOrderById(orderId: string) { | ||||||||
await this.orderTitleById(orderId).click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class VendorEditOrderPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove unnecessary constructor. The constructor is unnecessary as it only calls the parent constructor. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
createNewShipmentButton() { | ||||||||
return this.page.locator('#create-tracking-status-action'); | ||||||||
} | ||||||||
|
||||||||
shipmentItemCheckboxByIndex(itemNumber: string) { | ||||||||
return this.page.locator(`//form[@id="add-shipping-tracking-status-form"]/div/table/tbody[@id="order_line_items"]/tr[${itemNumber}]/td[1]/label/input`); | ||||||||
} | ||||||||
|
||||||||
shippingStatusDropdown() { | ||||||||
return this.page.locator('#shipment-status'); | ||||||||
} | ||||||||
|
||||||||
shippingProviderDropdown() { | ||||||||
return this.page.locator('#shipping_status_provider'); | ||||||||
} | ||||||||
|
||||||||
shippingDateField() { | ||||||||
return this.page.locator('#shipped_status_date'); | ||||||||
} | ||||||||
|
||||||||
shippingTrackingNumberField() { | ||||||||
return this.page.locator('#tracking_status_number'); | ||||||||
} | ||||||||
|
||||||||
createShipmentButton() { | ||||||||
return this.page.locator('#add-tracking-status-details'); | ||||||||
} | ||||||||
|
||||||||
async clickOnCreateNewShipmentButton() { | ||||||||
await this.createNewShipmentButton().click(); | ||||||||
} | ||||||||
|
||||||||
async clickOnShipmentItemCheckboxByIndex(itemNumber: string) { | ||||||||
await this.shipmentItemCheckboxByIndex(itemNumber).click(); | ||||||||
} | ||||||||
|
||||||||
async selectShippingStatus(status: string) { | ||||||||
await this.shippingStatusDropdown().selectOption(status); | ||||||||
} | ||||||||
|
||||||||
async selectShippingProvider(providerName: string) { | ||||||||
await this.shippingProviderDropdown().selectOption(providerName); | ||||||||
} | ||||||||
|
||||||||
async enterShippingDate(date: string) { | ||||||||
await this.shippingDateField().fill(date); | ||||||||
} | ||||||||
|
||||||||
async enterShippingTrackingNumber(trackingNumber: string) { | ||||||||
await this.shippingTrackingNumberField().fill(trackingNumber); | ||||||||
} | ||||||||
|
||||||||
async clickOnCreateShipmentButton() { | ||||||||
await this.createShipmentButton().click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class WpAdminSidebar extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor does not add any new functionality and can be safely removed. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
sideMenu(title: string) { | ||||||||
return this.page.locator('.wp-menu-name').getByText(title); | ||||||||
} | ||||||||
|
||||||||
async clickOnProductsLink() { | ||||||||
await this.sideMenu('Products').click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||||||||||||
import { BasePage } from '@pages/basePage'; | ||||||||||||||||||||||||||||||||||||
import { Page } from '@playwright/test'; | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
export default class DokanShippingStatusPage extends BasePage { | ||||||||||||||||||||||||||||||||||||
constructor(page: Page) { | ||||||||||||||||||||||||||||||||||||
super(page); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+5
to
+7
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. Remove unnecessary constructor. The constructor is unnecessary as it only calls the parent constructor. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
shippingStatusTab() { | ||||||||||||||||||||||||||||||||||||
return this.page.locator('//div[@class="nav-title"][text()="Shipping Status"]'); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
allowShipmentTrackingCheckbox() { | ||||||||||||||||||||||||||||||||||||
return this.page.locator('(//p/../following-sibling::div/label/label)[1]'); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
allowMarkAsReceivedCheckbox() { | ||||||||||||||||||||||||||||||||||||
return this.page.locator('(//p/../following-sibling::div/label/label)[2]'); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
async shippingStatusItem(status: string) { | ||||||||||||||||||||||||||||||||||||
const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all(); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
let locator; | ||||||||||||||||||||||||||||||||||||
for (const item of await list) { | ||||||||||||||||||||||||||||||||||||
const text = await item.textContent(); | ||||||||||||||||||||||||||||||||||||
if (text?.includes(status)) { | ||||||||||||||||||||||||||||||||||||
locator = item; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
return locator; | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+21
to
+33
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. Optimize the method to find the shipping status item. The method can be optimized by using array methods to find the item with the matching status. - async shippingStatusItem(status: string) {
- const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
-
- let locator;
- for (const item of await list) {
- const text = await item.textContent();
- if (text?.includes(status)) {
- locator = item;
- }
- }
-
- return locator;
- }
+ async shippingStatusItem(status: string) {
+ const list = await this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
+ return list.find(async (item) => (await item.textContent())?.includes(status));
+ } Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
saveChangesButton() { | ||||||||||||||||||||||||||||||||||||
return this.page.locator('#submit'); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
async clickOnShippingStatusTab() { | ||||||||||||||||||||||||||||||||||||
await this.shippingStatusTab().click(); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
async clickOnAllowShipmentTrackingCheckbox() { | ||||||||||||||||||||||||||||||||||||
await this.allowShipmentTrackingCheckbox().click(); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
async clickOnAllowMarkAsReceivedCheckbox() { | ||||||||||||||||||||||||||||||||||||
await this.allowMarkAsReceivedCheckbox().click(); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
async clickOnSaveChangesButton() { | ||||||||||||||||||||||||||||||||||||
await this.saveChangesButton().click(); | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class AllProductsPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor is redundant as it only calls the parent constructor without adding any additional logic. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
productTitleById(productId: string) { | ||||||||
return this.page.locator(`//tr[@id="post-${productId}"]/td[2]/strong/a`); | ||||||||
} | ||||||||
|
||||||||
async clickOnProductTitleById(productId: string) { | ||||||||
await this.productTitleById(productId).click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { BasePage } from '@pages/basePage'; | ||||||||
import { Page } from '@playwright/test'; | ||||||||
|
||||||||
export default class EditProductPage extends BasePage { | ||||||||
constructor(page: Page) { | ||||||||
super(page); | ||||||||
} | ||||||||
Comment on lines
+5
to
+7
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. Remove the unnecessary constructor. The constructor does not add any new functionality and can be safely removed. - constructor(page: Page) {
- super(page);
- } Committable suggestion
Suggested change
ToolsBiome
|
||||||||
|
||||||||
publishButton() { | ||||||||
return this.page.locator('#publish'); | ||||||||
} | ||||||||
|
||||||||
async clickOnPublishButton() { | ||||||||
await this.publishButton().click(); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { LoginPage } from '@pages/loginPage'; | ||
import DokanShippingStatusPage from '@pages/wp-admin/dokan/settings/shipping-status.page'; | ||
import test, { expect } from '@playwright/test'; | ||
|
||
let baseUrl: string; | ||
let loginPage: LoginPage; | ||
let shippingStatusPage: DokanShippingStatusPage; | ||
|
||
test.describe('Mark Order As Received - 01', () => { | ||
test.beforeEach(async ({ page }, testInfo) => { | ||
loginPage = new LoginPage(page); | ||
shippingStatusPage = new DokanShippingStatusPage(page); | ||
|
||
console.log(testInfo.project.use.baseURL); | ||
baseUrl = testInfo.project.use.baseURL as string; | ||
await page.goto(baseUrl); | ||
}); | ||
|
||
test('Receive status is added when Mark received by Customer is enabled', async ({ page }) => { | ||
await loginPage.adminLogin({ username: 'admin1', password: '[email protected]' }); | ||
await page.goto(baseUrl + '/wp-admin/admin.php?page=dokan#/settings'); | ||
await shippingStatusPage.clickOnShippingStatusTab(); | ||
await shippingStatusPage.clickOnAllowShipmentTrackingCheckbox(); | ||
await shippingStatusPage.clickOnAllowMarkAsReceivedCheckbox(); | ||
await shippingStatusPage.clickOnSaveChangesButton(); | ||
|
||
const status = await shippingStatusPage.shippingStatusItem('Received'); | ||
expect(await status?.textContent()).toContain('Received'); | ||
}); | ||
}); |
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.
Remove the unnecessary constructor.
The constructor is unnecessary as it only calls the parent constructor. Simplify the code by removing it.
Committable suggestion
Tools
Biome