Skip to content

Commit

Permalink
Add tests for creating and deleting customer
Browse files Browse the repository at this point in the history
  • Loading branch information
karola312 committed Feb 2, 2024
1 parent 6473419 commit 7e25bd4
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 177 deletions.
192 changes: 103 additions & 89 deletions playwright/data/e2eTestData.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
export const VOUCHERS_AND_DISCOUNTS = {
vouchers: {
voucherToBeEditedWithFreeShipping: {
id: "Vm91Y2hlcjoyMDI%3D",
},
voucherToBeEditedUsageLimits: {
id: "Vm91Y2hlcjoyMDM%3D",
},
voucherToBeEditedMinimumQuantity: {
id: "Vm91Y2hlcjoyMDQ%3D",
},
voucherToBeEditedAssignCategoryProductCollection: {
id: "Vm91Y2hlcjoyMDk%3D",
name: "Assign category, product, collection",
},
voucherToBeBulkDeleted: {
names: ["Bulk delete voucher 1/2", "Bulk delete voucher 2/2"],
},
voucherToBeDeleted: {
name: "Delete voucher",
id: "Vm91Y2hlcjoyMDY%3D",
},
export const CHANNELS = {
channelToBeEditedSettings: {
id: "Q2hhbm5lbDoyMzkx",
},
};
export const CUSTOMER_ADDRESS = {
changeBillingAddress: {
firstName: "Change Billing Address",
lastName: "Automation",
companyName: "Saleor",
phone: "123456789",
addressLine1: "Teczowa",
addressLine2: "7",
cityName: "WROCLAW",
zip: "53-601",
country: "Poland",
channelToBeDeleted: {
name: "z - channel to be deleted",
},
changeShippingAddress: {
firstName: "Change Shipping Address",
lastName: "Automation",
companyName: "Saleor",
phone: "123456789",
addressLine1: "Teczowa",
addressLine2: "7",
cityName: "WROCLAW",
zip: "53-601",
country: "Poland",
channelForTaxEdition: {
name: "a channel for tax tests",
},
plnChannel: {
id: "VGF4Q29uZmlndXJhdGlvbjox",
},
};
export const CATEGORIES = {
Expand Down Expand Up @@ -80,18 +46,45 @@ export const COUNTRIES = {
name: "Bosnia and Herzegovina",
},
};
export const CHANNELS = {
channelToBeEditedSettings: {
id: "Q2hhbm5lbDoyMzkx",
export const CUSTOMERS = {
deleteCustomer: {
// id: "VXNlcjoxNzM=",
id: "VXNlcjo5MTA=",
},
channelToBeDeleted: {
name: "z - channel to be deleted",
};
export const CUSTOMER_ADDRESS = {
changeBillingAddress: {
firstName: "Change Billing Address",
lastName: "Automation",
companyName: "Saleor",
phone: "123456789",
addressLine1: "Teczowa",
addressLine2: "7",
cityName: "WROCLAW",
zip: "53-601",
country: "Poland",
},
channelForTaxEdition: {
name: "a channel for tax tests",
changeShippingAddress: {
firstName: "Change Shipping Address",
lastName: "Automation",
companyName: "Saleor",
phone: "123456789",
addressLine1: "Teczowa",
addressLine2: "7",
cityName: "WROCLAW",
zip: "53-601",
country: "Poland",
},
plnChannel: {
id: "VGF4Q29uZmlndXJhdGlvbjox",
createCustomerAddress: {
firstName: "Create customer address",
lastName: "Automation",
companyName: "Saleor",
phone: "123456789",
addressLine1: "Teczowa",
addressLine2: "7",
cityName: "WROCLAW",
zip: "53-601",
country: "Poland",
},
};
export const GIFT_CARDS = {
Expand All @@ -115,16 +108,33 @@ export const GIFT_CARDS = {
name: "Code ending with d_10",
},
};
export const WAREHOUSES = {
warehouseToBeEdited: {
id: "V2FyZWhvdXNlOjgzNGQwYjQwLWMwZGItNGRhZi04N2RjLWQ2ODBiYzY3NGVlMw%3D%3D",
name: "warehouse to be edited",
export const ORDERS = {
draftOrdersToBeDeleted: {
ids: ["#3266", "#3265"],
},
warehouseToBeDeleted: {
name: "warehouseto be deleted",
ordersWithinTransactionFlow: {
markAsPaidOrder: {
orderId: "T3JkZXI6MDE4ZWM0NGUtNTgwMC00NGM0LTliMzAtZDE3YTIxYjljOTgz",
info: "Order used to mark as paid and fulfill",
},
captureManualTransactionOrder: {
orderId: "T3JkZXI6MmE1NTNkMzktOWU0OS00ZWE5LWIyNzEtNzk2ZWI5OGJhNzcz",
info: "Order used to capture manual transactions and fulfill",
},
},
orderToAddTrackingNumberTo: {
id: "T3JkZXI6M2NkYWE4NGItNzgxNi00ZWI2LWE1MGMtODE0NzY5YWM0MTEw",
},
orderToMarkAsPaidAndFulfill: {
id: "T3JkZXI6Yzg2ZDMzYmEtMTA5Yi00MzUyLTkzYWItOTljMGE3Zjk4ZGE5",
},
orderFulfilledToChangeBillingAddress: {
id: "T3JkZXI6MDIzNDhmMjktNzJiOC00ZTBkLWI1ODYtY2U3OTYwZDI0Y2Q0",
},
orderNotFulfilledToChangeShippingAddress: {
id: "T3JkZXI6ZWFhZjA0MzgtNzkyYi00ZTdlLWIyODUtMTBkMjViMjM0MzRk",
},
};

export const PRODUCTS = {
singleProductType: {
id: "UHJvZHVjdFR5cGU6Njcy",
Expand Down Expand Up @@ -190,35 +200,6 @@ export const PRODUCTS = {
],
},
};

export const ORDERS = {
draftOrdersToBeDeleted: {
ids: ["#3266", "#3265"],
},
ordersWithinTransactionFlow: {
markAsPaidOrder: {
orderId: "T3JkZXI6MDE4ZWM0NGUtNTgwMC00NGM0LTliMzAtZDE3YTIxYjljOTgz",
info: "Order used to mark as paid and fulfill",
},
captureManualTransactionOrder: {
orderId: "T3JkZXI6MmE1NTNkMzktOWU0OS00ZWE5LWIyNzEtNzk2ZWI5OGJhNzcz",
info: "Order used to capture manual transactions and fulfill",
},
},
orderToAddTrackingNumberTo: {
id: "T3JkZXI6M2NkYWE4NGItNzgxNi00ZWI2LWE1MGMtODE0NzY5YWM0MTEw",
},
orderToMarkAsPaidAndFulfill: {
id: "T3JkZXI6Yzg2ZDMzYmEtMTA5Yi00MzUyLTkzYWItOTljMGE3Zjk4ZGE5",
},
orderFulfilledToChangeBillingAddress: {
id: "T3JkZXI6MDIzNDhmMjktNzJiOC00ZTBkLWI1ODYtY2U3OTYwZDI0Y2Q0",
},
orderNotFulfilledToChangeShippingAddress: {
id: "T3JkZXI6ZWFhZjA0MzgtNzkyYi00ZTdlLWIyODUtMTBkMjViMjM0MzRk",
},
};

export const SHIPPING_METHODS = {
shippingMethodWithoutRates: {
id: "U2hpcHBpbmdab25lOjIzOTA%3D",
Expand Down Expand Up @@ -268,3 +249,36 @@ export const USERS = {
lastName: "user",
},
};
export const WAREHOUSES = {
warehouseToBeEdited: {
id: "V2FyZWhvdXNlOjgzNGQwYjQwLWMwZGItNGRhZi04N2RjLWQ2ODBiYzY3NGVlMw%3D%3D",
name: "warehouse to be edited",
},
warehouseToBeDeleted: {
name: "warehouseto be deleted",
},
};
export const VOUCHERS_AND_DISCOUNTS = {
vouchers: {
voucherToBeEditedWithFreeShipping: {
id: "Vm91Y2hlcjoyMDI%3D",
},
voucherToBeEditedUsageLimits: {
id: "Vm91Y2hlcjoyMDM%3D",
},
voucherToBeEditedMinimumQuantity: {
id: "Vm91Y2hlcjoyMDQ%3D",
},
voucherToBeEditedAssignCategoryProductCollection: {
id: "Vm91Y2hlcjoyMDk%3D",
name: "Assign category, product, collection",
},
voucherToBeBulkDeleted: {
names: ["Bulk delete voucher 1/2", "Bulk delete voucher 2/2"],
},
voucherToBeDeleted: {
name: "Delete voucher",
id: "Vm91Y2hlcjoyMDY%3D",
},
},
};
61 changes: 57 additions & 4 deletions playwright/pages/customersPage.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,65 @@
import type { Page } from "@playwright/test";
import { URL_LIST } from "@data/url";
import { Page, expect } from "@playwright/test";
import { AddressForm, customerAddress} from "@forms/addressForm";
import { BasePage } from "@pages/basePage";
import { DeleteDialog } from '@dialogs/deleteDialog';

export class CustomersPage {
readonly page: Page;
export class CustomersPage extends BasePage {
readonly addressForm: AddressForm;
readonly deleteDialog: DeleteDialog;

constructor(
page: Page,
readonly createCustomerButton = page.getByTestId("create-customer"),
readonly customerFirstNameInput = page
.getByTestId("customer-first-name")
.locator("input"),
readonly customerLastNameInput = page
.getByTestId("customer-last-name")
.locator("input"),
readonly customerEmailInput = page
.getByTestId("customer-email")
.locator("input"),
readonly customerNoteInput = page
.getByTestId("customer-note")
.locator("textarea[name='note']"),
readonly saveButton = page.getByTestId("button-bar-confirm"),
readonly deleteButton = page.getByTestId("button-bar-delete")
) {
this.page = page;
super(page);
this.addressForm = new AddressForm(page);
this.deleteDialog = new DeleteDialog(page);
}

async goToCustomersListView() {
await this.page.goto(URL_LIST.customers);
}
async gotoCustomerDetailsPage(customerId: string) {
const existingCustomerUrl = `${URL_LIST.customers}${customerId}`;
console.info(`Navigating to existing customer: ${existingCustomerUrl}`);
await this.page.goto(existingCustomerUrl);
await expect(this.pageHeader).toBeVisible({ timeout: 10000 });
}
async clickOnCreateCustomer() {
await this.createCustomerButton.click();
}
async fillName(firstName: string, lastName: string) {
await this.customerFirstNameInput.fill(firstName, { timeout: 1000000 });
await this.customerLastNameInput.fill(lastName);
}
async fillEmail(email: string) {
await this.customerEmailInput.fill(email);
}
async fillAddress(customerInfo: customerAddress) {
await this.addressForm.fillAddressFormAllFields(customerInfo);
}
async fillNote(note: string) {
await this.customerNoteInput.fill(note);
}
async saveCustomer() {
await this.saveButton.click();
}
async deleteCustomer() {
await this.deleteButton.click();
}
}
Loading

0 comments on commit 7e25bd4

Please sign in to comment.