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 b0ac5d6 + 9273dca commit de3446f
Show file tree
Hide file tree
Showing 29 changed files with 322 additions and 168 deletions.
14 changes: 5 additions & 9 deletions tests/pw/pages/requestForQuotationsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class RequestForQuotationsPage extends AdminPage {
// edit quote rule
async editQuoteRule(rule: requestForQuotation['quoteRule']) {
await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules);
// await this.goto(data.subUrls.backend.dokan.requestForQuoteRules);

await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(rule.title));

Expand All @@ -98,11 +97,11 @@ export class RequestForQuotationsPage extends AdminPage {

// update quote rule
async updateQuoteRule(quoteTitle: string, action: string) {
await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules);
// await this.goto(data.subUrls.backend.dokan.requestForQuoteRules);
await this.goto(data.subUrls.backend.dokan.requestForQuoteRules);

switch (action) {
case 'trash':
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.navTabs.published);
await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesTrash(quoteTitle));
break;
Expand All @@ -126,8 +125,7 @@ export class RequestForQuotationsPage extends AdminPage {

// quote rules bulk action
async quoteRulesBulkAction(action: string) {
await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules);
// await this.goto(data.subUrls.backend.dokan.requestForQuoteRules);
await this.goto(data.subUrls.backend.dokan.requestForQuoteRules);

// ensure row exists
await this.notToBeVisible(selector.admin.dokan.requestForQuotation.quoteRules.noRowsFound);
Expand Down Expand Up @@ -220,10 +218,10 @@ export class RequestForQuotationsPage extends AdminPage {
// update quote
async updateQuote(quoteTitle: string, action: string) {
await this.goto(data.subUrls.backend.dokan.requestForQuote);
// await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote);

switch (action) {
case 'trash':
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.pending);
await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteTrash(quoteTitle));
break;
Expand All @@ -248,17 +246,15 @@ export class RequestForQuotationsPage extends AdminPage {
// approve quote
async approveQuote(quoteTitle: string) {
await this.goto(data.subUrls.backend.dokan.requestForQuote);
// await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote);
await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.approveQuote);
}

// convert quote to order
async convertQuoteToOrder(quoteTitle: string) {
// await this.approveQuote(quoteTitle);
await this.goto(data.subUrls.backend.dokan.requestForQuote);
// await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote);
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.approved);
await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.convertToOrder);
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 @@ -7082,7 +7082,7 @@ export const selector = {
phoneNumber: 'input[name="phone_field"]',
},

message: '.woocommerce .is-success',
message: '.woocommerce-message',
},

// requested quote
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/spmvPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SpmvPage extends VendorPage {
}

// got to product edit from spmv
async goToProductEditFromSPMV(productName: string): Promise<void> {
async goToProductEditFromSpmv(productName: string): Promise<void> {
await this.searchSimilarProduct(productName, 'spmv');
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.vSpmv.editProduct(productName));
await this.toHaveValue(selector.vendor.product.edit.title, productName);
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 @@ -225,7 +225,7 @@ test.describe.skip('commission test', () => {
const gatewayFee = 0;
const lineItems = res.line_items;

const calculatedSubTotal = helpers.lineItemsToSubtoal(lineItems);
const calculatedSubTotal = helpers.lineItemsToSubtotal(lineItems);
const calculatedProductTax = helpers.productTax(taxRate, calculatedSubTotal);
const calculatedShippingTax = helpers.shippingTax(taxRate, providedShippingFee);
const calculatedTotalTax = calculatedProductTax + calculatedShippingTax;
Expand Down
11 changes: 7 additions & 4 deletions tests/pw/tests/e2e/_auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ setup.describe('authenticate users & set permalink', () => {
});

setup('add vendor1 @lite', async () => {
const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth);
await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth);
const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth, true);
console.log('VENDOR_ID:', sellerId);
process.env.VENDOR_ID = sellerId;
helpers.appendEnv(`VENDOR_ID=${sellerId}`); // for local testing
});

setup('add vendor2 @lite', async () => {
const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth);
await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth);
const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth, true);
console.log('VENDOR2_ID:', sellerId);
process.env.VENDOR2_ID = sellerId;
helpers.appendEnv(`VENDOR2_ID=${sellerId}`); // for local testing
Expand All @@ -76,6 +74,11 @@ setup.describe('authenticate users & set permalink', () => {
await loginPage.login(data.vendor, data.auth.vendorAuthFile);
});

setup('authenticate vendor2 @lite', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.login(data.vendor.vendor2, data.auth.vendor2AuthFile);
});

setup('dokan pro enabled or not @lite', async () => {
let res = await apiUtils.checkPluginsExistence(data.plugin.dokanPro, payloads.adminAuth);
if (res) {
Expand Down
6 changes: 2 additions & 4 deletions tests/pw/tests/e2e/_env.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ setup.describe('setup user settings', () => {
await apiUtils.deleteAllProducts(data.predefined.simpleProduct.product1.name, payloads.vendorAuth);

// create store product
const product = { ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name };
const [, productId] = await apiUtils.createProduct(product, payloads.vendorAuth);
const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name }, payloads.vendorAuth);
console.log('PRODUCT_ID', productId);
process.env.PRODUCT_ID = productId;
helpers.appendEnv(`PRODUCT_ID=${productId}`); // for local testing
Expand All @@ -142,8 +141,7 @@ setup.describe('setup user settings', () => {
await apiUtils.deleteAllProducts(data.predefined.vendor2.simpleProduct.product1.name, payloads.vendor2Auth);

// create store product
const product = { ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name };
const [, productId] = await apiUtils.createProduct(product, payloads.vendor2Auth);
const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name }, payloads.vendor2Auth);
console.log('V2_PRODUCT_ID:', productId);
process.env.V2_PRODUCT_ID = productId;
helpers.appendEnv(`V2_PRODUCT_ID=${productId}`); // for local testing
Expand Down
17 changes: 12 additions & 5 deletions tests/pw/tests/e2e/refunds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@ test.describe('Refunds test', () => {

apiUtils = new ApiUtils(await request.newContext());
[, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth);
await dbUtils.createRefund(orderResponseBody);
await dbUtils.createRefundRequest(orderResponseBody);
});

test.afterAll(async () => {
await aPage.close();
await apiUtils.dispose();
});

//admin

test('admin refunds menu page is rendering properly @pro @exp @a', async () => {
await admin.adminRefundRequestsRenderProperly();
});

test('admin can search refund requests @pro @a', async () => {
test('admin can search refund requests by order-id @pro @a', async () => {
await admin.searchRefundRequests(orderId);
// await admin.searchRefundRequests(data.predefined.vendorStores.vendor1);
});

test('admin can search refund requests by vendor @pro @a', async () => {
await admin.searchRefundRequests(data.predefined.vendorStores.vendor1);
});

test('admin can approve refund request @pro @a', async () => {
Expand All @@ -49,16 +54,18 @@ test.describe('Refunds test', () => {

test('admin can cancel refund requests @pro @a', async () => {
const [, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth);
await dbUtils.createRefund(orderResponseBody);
await dbUtils.createRefundRequest(orderResponseBody);
await admin.updateRefundRequests(orderId, 'cancel');
});

test('admin can perform refund requests bulk actions @pro @a', async () => {
const [, orderResponseBody, ,] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth);
await dbUtils.createRefund(orderResponseBody);
await dbUtils.createRefundRequest(orderResponseBody);
await admin.refundRequestsBulkAction('completed');
});

//vendor

test('vendor can full refund @pro @v', async () => {
const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth);
await vendor.refundOrder(orderId, data.predefined.simpleProduct.product1.name);
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/reports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test.describe('Reports test', () => {
const adminContext = await browser.newContext(data.auth.adminAuth);
aPage = await adminContext.newPage();
admin = new ReportsPage(aPage);

apiUtils = new ApiUtils(await request.newContext());
[, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.completed, payloads.vendorAuth);
});
Expand All @@ -33,7 +34,7 @@ test.describe('Reports test', () => {

// all logs

test('admin All Logs menu page is rendering properly @pro @exp @a', async () => {
test('admin all Logs menu page is rendering properly @pro @exp @a', async () => {
await admin.adminAllLogsRenderProperly();
});

Expand All @@ -42,7 +43,6 @@ test.describe('Reports test', () => {
});

test('admin can export all logs @pro @a', async () => {
// await admin.exportAllLogs(orderId);
await admin.exportAllLogs();
});

Expand Down
23 changes: 15 additions & 8 deletions tests/pw/tests/e2e/requestForQuoteRules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,57 @@ test.describe('Request for quotation Rules test', () => {
let admin: RequestForQuotationsPage;
let aPage: Page;
let apiUtils: ApiUtils;
const quoteRuleTitle = data.requestForQuotation.quoteRule.title();
let quoteRuleTitle: string;

test.beforeAll(async ({ browser }) => {
const adminContext = await browser.newContext(data.auth.adminAuth);
aPage = await adminContext.newPage();
admin = new RequestForQuotationsPage(aPage);

apiUtils = new ApiUtils(await request.newContext());
await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: quoteRuleTitle }, payloads.adminAuth);
[, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth);
});

test.afterAll(async () => {
await apiUtils.deleteAllQuoteRules(payloads.adminAuth);
await apiUtils.deleteAllQuoteRulesTrashed(payloads.adminAuth);
await aPage.close();
await apiUtils.dispose();
});

// quote rules

//admin

test('admin quote rules menu page is rendering properly @pro @exp @a', async () => {
await admin.adminQuoteRulesRenderProperly();
});

test('admin can add quote rule @pro @a', async () => {
await admin.addQuoteRule({ ...data.requestForQuotation.quoteRule, title: data.requestForQuotation.quoteRule.title() });
await admin.addQuoteRule(data.requestForQuotation.quoteRule());
});

test('admin can edit quote rule @pro @a', async () => {
await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule, title: quoteRuleTitle });
await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle });
});

test('admin can trash quote rule @pro @a', async () => {
const [, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth);
await admin.updateQuoteRule(quoteRuleTitle, 'trash');
});

test('admin can restore quote rule @pro @a', async () => {
const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth);
await admin.updateQuoteRule(quoteRuleTitle, 'restore');
});

test('admin can permanently delete quote rule @pro @a', async () => {
await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: data.requestForQuotation.trashedQuoteRule.title, status: data.requestForQuotation.trashedQuoteRule.status }, payloads.adminAuth);
await admin.updateQuoteRule(data.requestForQuotation.trashedQuoteRule.title, 'permanently-delete');
const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth);
await admin.updateQuoteRule(quoteRuleTitle, 'permanently-delete');
});

// todo: need order for this type of test for whole project , will fail others tests while running parallel
test('admin can perform quote rule bulk actions @pro @a', async () => {
test.skip('admin can perform quote rule bulk actions @pro @a', async () => {
// todo: might cause other tests to fail in parallel
await admin.quoteRulesBulkAction('trash');
});
});
Loading

0 comments on commit de3446f

Please sign in to comment.