Skip to content

Commit

Permalink
Merge branch 'testlite' into e2e-pw
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Feb 15, 2024
2 parents 4f7756b + 5279260 commit 9816e4d
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 42 deletions.
2 changes: 1 addition & 1 deletion tests/pw/api.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
// globalTeardown: './global-teardown' /* Path to the global teardown file. This file will be required and run after all the tests. */,
globalTimeout: process.env.CI ? 20 * (60 * 1000) : 20 * (60 * 1000) /* Maximum time in milliseconds the whole test suite can run */,
maxFailures: process.env.CI ? 30 : 30 /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */,
timeout: process.env.CI ? 15 * 1000 : 15 * 1000 /* Maximum time one test can run for. */,
timeout: process.env.CI ? 15 * 1000 : 20 * 1000 /* Maximum time one test can run for. */,
expect: {
timeout: 5 * 1000 /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/,
} /* Configuration for the expect assertion library */,
Expand Down
8 changes: 5 additions & 3 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,16 @@ export class BasePage {

// type & wait for response
async typeViaPageAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise<Response> {
const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.page.locator(selector).pressSequentially(text, { delay: 100 })]);
const [response] = await Promise.all([
this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code),
this.page.locator(selector).pressSequentially(text, { delay: 100 })]);
return response;
}

// type & wait for response
async typeAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise<Response> {
const [response] = await Promise.all([
this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code),
// await this.page.locator(selector).pressSequentially(text),
this.clearAndFill(selector, text),
]);
return response;
Expand Down Expand Up @@ -874,7 +875,8 @@ export class BasePage {
// check locator
async checkLocator(selector: string): Promise<void> {
const locator = this.page.locator(selector);
await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error
await locator.check();
// await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error
}

// click locator
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/pages/productAddonsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export class ProductAddonsPage extends VendorPage {
// create new addon text is visible
await this.toBeVisible(selector.vendor.vAddonSettings.createNewAddon);

// create new text is visible
// create new text is visible
await this.toBeVisible(selector.vendor.vAddonSettings.createNew);

// product addon table elements are visible
await this.multipleElementVisible(selector.vendor.vAddonSettings.table);

await this.click(selector.vendor.vAddonSettings.createNewAddon);
await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.createNewAddon);
await this.click(selector.vendor.vAddonSettings.addon.addField);
await this.check(selector.vendor.vAddonSettings.addon.enableDescription);

Expand Down Expand Up @@ -69,7 +69,7 @@ export class ProductAddonsPage extends VendorPage {
// add addon
async addAddon(addon: vendor['addon']) {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon);
await this.click(selector.vendor.vAddonSettings.createNewAddon);
await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.createNewAddon);
await this.updateAddonFields(addon);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/reportsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ReportsPage extends AdminPage {
await this.goIfNotThere(data.subUrls.backend.dokan.allLogs);

await this.clearInputField(selector.admin.dokan.reports.allLogs.search);
await this.typeViaPageAndWaitForResponse(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId);
await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId);
await this.toBeVisible(selector.admin.dokan.reports.allLogs.orderIdCell(orderId));
const count = (await this.getElementText(selector.admin.dokan.reports.allLogs.numberOfRowsFound))?.split(' ')[0];
expect(Number(count)).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3463,7 +3463,7 @@ export const selector = {

// Product Sub Options
numberOfRowsFound: '#dokan-product-list-table tbody tr',
productCell: (productName: string) => `//a[contains(text(),'${productName}')]/../..`,
productCell: (productName: string) => `//strong//a[contains(text(),'${productName}')]/../..`,
productLink: (productName: string) => `//strong//a[contains(text(),'${productName}')]`,
editProduct: (productName: string) => `//a[contains(text(),'${productName}')]/../..//span[@class="edit"]//a`,
buyAdvertisement: (productName: string) => `//a[contains(text(),'${productName}')]/../../..//td[@class="product-advertisement-td"]//span`,
Expand Down
1 change: 1 addition & 0 deletions tests/pw/tests/api/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test.describe('announcements api test', () => {

test('get single announcement @pro', async () => {
const [response, responseBody] = await apiUtils.get(endPoints.getSingleAnnouncement(announcementId));
console.log(responseBody);
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
expect(responseBody).toMatchSchema(schemas.announcementsSchema.announcementSchema);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/api/calculation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ test.describe.skip('commission test', () => {
];
console.table(table);
} else {
// todo: modify for lite as well
// todo: modify for lite as well
const table = [
[`OID: ${oid}`, 'OrderTotal', 'VendorEarning', 'AdmminCommission', 'GatewayFee', 'ShippingFee', 'ShippingTax', 'ProductTax'],
['Expected', calculatedOrderTotal, calculatedVendorEarning, calculatedAdminCommission, gatewayFee, providedShippingFee, calculatedShippingTax, calculatedProductTax],
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/api/refunds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ test.describe('refunds api test', () => {
});

test('approve a refund @pro', async () => {
const [, refundId] = await dbUtils.createRefund(orderResponseBody);
const [, refundId] = await dbUtils.createRefundRequest(orderResponseBody);
const [response, responseBody] = await apiUtils.put(endPoints.approveRefund(refundId));
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('update batch refunds @pro', async () => {
await dbUtils.createRefund(orderResponseBody);
await dbUtils.createRefundRequest(orderResponseBody);
const allPendingRefundsIds = (await apiUtils.getAllRefunds('pending', payloads.vendorAuth)).map((a: { id: unknown }) => a.id);
const [response, responseBody] = await apiUtils.put(endPoints.updateBatchRefunds, { data: { cancelled: allPendingRefundsIds } });
expect(response.ok()).toBeTruthy();
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/tests/api/supportTickets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ test.describe('support ticket api test', () => {
expect(responseBody).toBeTruthy();

// reopen all support tickets
for (const supportTicketId of allSupportTicketIds) {
await apiUtils.updateSupportTicketStatus(supportTicketId, 'open');
}
// for (const supportTicketId of allSupportTicketIds) {
// await apiUtils.updateSupportTicketStatus(supportTicketId, 'open');
// }
});
});
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test.describe('Announcements test (admin)', () => {
});

test.skip('admin can perform announcements bulk action @pro @a', async () => {
// todo: might cause other tests to fail in parallel
// todo: might cause other tests to fail in parallel
// await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await admin.announcementBulkAction('trash');
});
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/productAddons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.describe('Product addon functionality test', () => {
await apiUtils.deleteAllProductAddons(payloads.adminAuth);
await vPage.close();
await apiUtils.dispose();
});
});

test('vendor product addons menu page is rendering properly @pro @exp @v', async () => {
await vendor.vendorProductAddonsSettingsRenderProperly();
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/products.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ test.describe('Product functionality test', () => {
await vendor.addProductDescription(productName, data.product.productInfo.description);
});

test.skip('vendor can add product quantity discount @pro @v', async ( ) => {
await vendor.addProductQuantityDiscount(productName, data.product.productInfo.quantityDiscount);
test.skip('vendor can add product quantity discount @pro @v', async () => {
await vendor.addProductQuantityDiscount(productName, data.product.productInfo.quantityDiscount);
});

test('vendor can add product rma options @pro @v', async () => {
Expand Down
1 change: 0 additions & 1 deletion tests/pw/tests/e2e/setting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,4 @@ test.describe.skip('Settings test', () => {
await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, order_status_change: 'off' });
await vendor.setOrderStatusChangeCapability(orderId, 'off');
});

});
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ test.describe('Tools test', () => {
await admin.regenerateVariableProductVariationsAuthorIds();
});

test.skip('admin can import dummy data @pro', async ( ) => {
test.skip('admin can import dummy data @pro', async () => {
// todo: need to fix
await admin.importDummyData();
await admin.importDummyData();
});

test('admin can clear dummy data @pro @a', async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@payloads": ["utils/payloads"],
"@schemas": ["utils/schemas"],
"@testData": ["utils/testData"],
"@pwMatchers": ["utils/pwMatchers"],
"@pwMatchers": ["utils/pwMatchers"]
},
"esModuleInterop": true /* fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module*/,
"moduleResolution": "node" /* Pretty much always node for modern JS. Other option is "classic"*/,
Expand Down Expand Up @@ -56,7 +56,7 @@
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noUncheckedIndexedAccess": true /* accessing index must always check for undefined*/,
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
"forceConsistentCasingInFileNames": true /* Force consistent Casing In File Names */,
"forceConsistentCasingInFileNames": true /* Force consistent Casing In File Names */
},
"exclude": ["node_modules/**/*", "playwright/**/*", "playwright-report/**/*"],
"exclude": ["node_modules/**/*", "playwright/**/*", "playwright-report/**/*"]
}
3 changes: 1 addition & 2 deletions tests/pw/utils/apiEndPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,13 @@ export const endPoints = {
updateProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`,
deleteProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`,
updateBatchProductQuestions: `${SERVER_URL}/dokan/v1/product-questions/bulk_action`, // method: delete, read, unread

getAllProductQuestionAnswers: `${SERVER_URL}/dokan/v1/product-answers`,
getSingleProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`,
createProductQuestionAnswer: `${SERVER_URL}/dokan/v1/product-answers`,
updateProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`,
deleteProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`,


wc: {
// coupons
getAllCoupons: `${SERVER_URL}/wc/v3/coupons`,
Expand Down
32 changes: 17 additions & 15 deletions tests/pw/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,21 +605,23 @@ export const schemas = {
adminExportLogsSchema: z.object({
step: z.string().or(z.number()),
percentage: z.number(),
columns: z.object({
order_id: z.string(),
vendor_id: z.string(),
vendor_name: z.string(),
previous_order_total: z.string(),
order_total: z.string(),
vendor_earning: z.string(),
commission: z.string(),
dokan_gateway_fee: z.string(),
gateway_fee_paid_by: z.string(),
shipping_total: z.string(),
tax_total: z.string(),
status: z.string(),
date: z.string(),
}).or(z.null()),
columns: z
.object({
order_id: z.string(),
vendor_id: z.string(),
vendor_name: z.string(),
previous_order_total: z.string(),
order_total: z.string(),
vendor_earning: z.string(),
commission: z.string(),
dokan_gateway_fee: z.string(),
gateway_fee_paid_by: z.string(),
shipping_total: z.string(),
tax_total: z.string(),
status: z.string(),
date: z.string(),
})
.or(z.null()),
}),
},

Expand Down

0 comments on commit 9816e4d

Please sign in to comment.