Skip to content
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

feat: add new address #300

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions src/page-objects/storefront/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export class Account implements PageObject {
public readonly newsletterCheckbox: Locator;
public readonly newsletterRegistrationSuccessMessage: Locator;
public readonly customerGroupRequestMessage: Locator;

public readonly cannotDeliverToCountryAlert: Locator;
public readonly shippingToAddressNotPossibleAlert: Locator;
constructor(public readonly page: Page, public readonly instanceMeta: HelperFixtureTypes['InstanceMeta']) {
this.headline = page.getByRole('heading', { name: 'Overview' });
this.personalDataCardTitle = page.getByRole('heading', { name: 'Personal data' });
Expand All @@ -27,7 +28,9 @@ export class Account implements PageObject {
} else {
this.customerGroupRequestMessage = page.locator('.alert-content-container');
}

this.cannotDeliverToCountryAlert = page.getByText('We can not deliver to the country that is stored in your delivery address.');
this.shippingToAddressNotPossibleAlert = page.getByText('Shipping to the selected shipping address is currently not possible.');

}

async getCustomerGroupAlert(customerGroup: string): Promise<Locator> {
Expand Down
5 changes: 5 additions & 0 deletions src/page-objects/storefront/AccountAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ export class AccountAddresses implements PageObject {
public readonly editShippingAddressButton: Locator;
public readonly useDefaultBillingAddressButton: Locator;
public readonly useDefaultShippingAddressButton: Locator;
public readonly deliveryNotPossibleAlert: Locator;
public readonly otherShippingAddress: Locator;

constructor(public readonly page: Page) {
this.addNewAddressButton = page.getByRole('link', { name: /Add (new )?address/ });
this.editBillingAddressButton = page.getByRole('link', { name: 'Edit address' }).first();
this.editShippingAddressButton = page.getByRole('link', { name: 'Edit address' }).nth(1);
this.useDefaultBillingAddressButton = page.getByRole('button', { name: 'Use as default billing address' });
this.useDefaultShippingAddressButton = page.getByRole('button', { name: 'Use as default shipping address' });
const otherAddress = page.locator('.other-address');
this.deliveryNotPossibleAlert = otherAddress.getByText('A delivery to this country is not possible.');
this.otherShippingAddress = otherAddress.locator('.address').nth(1);
}

url() {
Expand Down
2 changes: 2 additions & 0 deletions src/page-objects/storefront/AccountAddresssCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AccountAddressCreate implements PageObject {
public readonly cityInput: Locator;
public readonly countryDropdown: Locator;
public readonly saveAddressButton: Locator;
public readonly stateDropdown: Locator;

constructor(public readonly page: Page) {
this.salutationDropdown = page.locator('#addresspersonalSalutation');
Expand All @@ -23,6 +24,7 @@ export class AccountAddressCreate implements PageObject {
this.zipcodeInput = page.locator('#addressAddressZipcode');
this.cityInput = page.locator('#addressAddressCity');
this.countryDropdown = page.locator('#addressAddressCountry');
this.stateDropdown = page.locator('#addressAddressCountryState');
this.saveAddressButton = page.locator('.address-form-submit');
}

Expand Down
27 changes: 27 additions & 0 deletions src/page-objects/storefront/AccountLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ export class AccountLogin implements PageObject {
public readonly postalCodeInput: Locator;
public readonly registerButton: Locator;

//Input for shipping address
public readonly differentShippingAddressCheckbox: Locator;
public readonly registerShippingAddressFormArea: Locator;
public readonly shippingAddressSalutationSelect: Locator;
public readonly shippingAddressFirstNameInput: Locator;
public readonly shippingAddressLastNameInput: Locator;
public readonly shippingAddressStreetAddressInput: Locator;
public readonly shippingAddressCityInput: Locator;
public readonly shippingAddressCountryInput: Locator;
public readonly shippingAddressPostalCodeInput: Locator;
public readonly shippingAddressStateInput: Locator;


constructor(public readonly page: Page) {
this.emailInput = page.getByLabel('Your email address');
this.passwordInput = page.getByLabel('Your password');
Expand All @@ -52,10 +65,24 @@ export class AccountLogin implements PageObject {
this.cityInput = this.billingAddressFormArea.getByLabel('City');
this.countryInput = this.billingAddressFormArea.getByLabel('Country');
this.postalCodeInput = this.billingAddressFormArea.getByLabel('Postal code');
this.differentShippingAddressCheckbox = page.getByRole('checkbox', { name: 'Shipping and billing address do not match.' });
this.registerShippingAddressFormArea = page.locator('.register-shipping');
this.shippingAddressSalutationSelect = this.registerShippingAddressFormArea.locator('.form-group').filter({ has: page.getByLabel('Salutation') }).locator('.form-select');
this.shippingAddressFirstNameInput = this.registerShippingAddressFormArea.getByLabel('First name');
this.shippingAddressLastNameInput = this.registerShippingAddressFormArea.getByLabel('Last name');
this.shippingAddressStreetAddressInput = this.registerShippingAddressFormArea.getByLabel('Street address');
this.shippingAddressCityInput = this.registerShippingAddressFormArea.getByLabel('City');
this.shippingAddressCountryInput = this.registerShippingAddressFormArea.getByLabel('Country');
this.shippingAddressPostalCodeInput = this.registerShippingAddressFormArea.getByLabel('Postal code');
this.shippingAddressStateInput = this.registerShippingAddressFormArea.getByLabel('State');
this.registerButton = page.getByRole('button', { name: 'Continue' });
this.logoutLink = page.getByRole('link', { name: 'Log out'});
this.successAlert = page.getByText('Successfully logged out.');
this.passwordUpdatedAlert = page.getByText('Your password has been updated.');
}

async getShippingCountryLocatorByName(countryName: string): Promise<Locator> {
return this.shippingAddressCountryInput.locator('option').filter({ hasText: countryName });
}

url() {
Expand Down
2 changes: 1 addition & 1 deletion src/services/TestDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class TestDataService {
*
* @private
*/
private highPriorityEntities = ['order', 'product', 'landing_page', 'shipping_method', 'sales_channel_domain', 'sales_channel_currency', 'sales_channel_country', 'customer'];
private highPriorityEntities = ['order', 'product', 'landing_page', 'shipping_method', 'sales_channel_domain', 'sales_channel_currency', 'sales_channel_country', 'customer', 'customer_address'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm having an issue cleaning up country data in after hook(409 conflict error), despite having added customer_address here.

Copy link
Contributor

@yusufttur yusufttur Feb 4, 2025

Choose a reason for hiding this comment

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

Somehow the address data is still in use when you try to delete it.


/**
* A registry of all created records.
Expand Down
2 changes: 2 additions & 0 deletions src/tasks/shop-customer-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Logout } from './shop-customer/Account/Logout';
import { Register } from './shop-customer/Account/Register';
import { RegisterGuest } from './shop-customer/Account/RegisterGuest';
import { ChangeStorefrontCurrency } from './shop-customer/Account/ChangeStorefrontCurrency';
import { AddNewAddress } from './shop-customer/Account/AddNewAddress';

import { AddProductToCart } from './shop-customer/Product/AddProductToCart';
import { ProceedFromProductToCheckout } from './shop-customer/Product/ProceedFromProductToCheckout';
Expand All @@ -31,6 +32,7 @@ export const test = mergeTests(
Register,
RegisterGuest,
ChangeStorefrontCurrency,
AddNewAddress,
AddProductToCart,
ChangeProductQuantity,
ProceedFromProductToCheckout,
Expand Down
31 changes: 31 additions & 0 deletions src/tasks/shop-customer/Account/AddNewAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { test as base } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes} from '../../../types/FixtureTypes';
import { Address } from '../../../types/ShopwareTypes';

export const AddNewAddress = base.extend<{ AddNewAddress: Task }, FixtureTypes>({
AddNewAddress: async ({ ShopCustomer, StorefrontAccountAddresses, StorefrontAccountAddressCreate }, use)=> {
const task = (address: Address) => {
return async function AddNewAddress() {

await ShopCustomer.goesTo(StorefrontAccountAddresses.url());
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put that line (goesTo) into the test so that It is more transparent where you create the address.

Copy link
Contributor

Choose a reason for hiding this comment

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

and we save execution time because the fixture ShopCustomer is large and takes much more time to generate compared to a simple page object.

await StorefrontAccountAddresses.addNewAddressButton.click();

await StorefrontAccountAddressCreate.firstNameInput.fill(address.firstName);
await StorefrontAccountAddressCreate.lastNameInput.fill(address.lastName);
await StorefrontAccountAddressCreate.companyInput.fill(address.company);
await StorefrontAccountAddressCreate.departmentInput.fill(address.department);
await StorefrontAccountAddressCreate.streetInput.fill(address.street);
await StorefrontAccountAddressCreate.zipcodeInput.fill(address.zipCode);
await StorefrontAccountAddressCreate.cityInput.fill(address.city);
await StorefrontAccountAddressCreate.countryDropdown.selectOption({label: address.country});
await StorefrontAccountAddressCreate.stateDropdown.selectOption({label: address.state});

await StorefrontAccountAddressCreate.saveAddressButton.click();

}
};

await use(task);
},
});
19 changes: 18 additions & 1 deletion src/types/ShopwareTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ export type CustomerAddress = components['schemas']['CustomerAddress'] & {
id: string,
}

export interface Address {
salutation: string,
firstName: string,
lastName: string,
company: string,
department: string,
street: string,
city: string,
zipCode: string,
country: string,
state: string,
}

export type Salutation = components['schemas']['Salutation'] & {
id: string,
}
Expand Down Expand Up @@ -106,8 +119,12 @@ export type Currency = components['schemas']['Currency'] & {
id: string,
}

export type Country = components['schemas']['Country'] & {
export type Country = Omit<components['schemas']['Country'], 'states'> & {
id: string,
states: [{
name: string,
shortCode: string,
}],
}

export type SystemConfig = components['schemas']['SystemConfig'] & {
Expand Down
Loading