Skip to content

Commit

Permalink
fix: locator compatibility for bulk edit products (#251)
Browse files Browse the repository at this point in the history
* fix: locator compatibility for bulk edit products

* fix: improve locator

* fix: improve locator detail
  • Loading branch information
yusufttur authored Jan 3, 2025
1 parent 53cf2ab commit 42e6b11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/page-objects/administration/ProductBulkEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ProductBulkEdit implements PageObject {
this.changeManufacturerRow = page.locator('.sw-bulk-edit-change-field-manufacturerId');
this.changeManufacturerCheckbox = this.changeManufacturerRow.getByRole('checkbox');
this.manufacturerDropdown = this.changeManufacturerRow.locator('.sw-select__selection');
this.manufacturerDropdownInput = this.changeManufacturerRow.getByPlaceholder('Select manufacturer...');
this.manufacturerDropdownInput = this.changeManufacturerRow.locator('.sw-entity-single-select__selection-input');
this.manufacturerListResult = this.changeManufacturerRow.getByRole('list');

// Active
Expand All @@ -77,7 +77,7 @@ export class ProductBulkEdit implements PageObject {
// Price
this.changePriceRow = page.locator('.sw-bulk-edit-change-field-price');
this.changePriceCheckbox = this.changePriceRow.getByRole('checkbox');
this.grossPriceInput = this.changePriceRow.getByPlaceholder('Enter gross price...');
this.grossPriceInput = this.changePriceRow.locator('#price-gross');

// Release date
this.changeReleaseDateRow = page.locator('.sw-bulk-edit-change-field-releaseDate');
Expand All @@ -89,21 +89,21 @@ export class ProductBulkEdit implements PageObject {
this.changeStockCheckbox = this.changeStockRow.getByRole('checkbox');
this.stockChangeMethodDropdown = this.changeStockRow.locator('.sw-single-select__selection-text');
this.stockChangeMethodInput = this.changeStockRow.locator('.sw-single-select__selection-input');
this.stockInput = this.changeStockRow.getByPlaceholder('Enter quantity in stock...');
this.stockInput = this.changeStockRow.locator('#stock');

// Restock time
this.changeRestockTimeRow = page.locator('.sw-bulk-edit-change-field-restockTime');
this.changeRestockTimeCheckbox = this.changeRestockTimeRow.getByRole('checkbox');
this.restockTimeChangeMethodDropdown = this.changeRestockTimeRow.locator('.sw-single-select__selection-text');
this.restockTimeChangeMethodInput = this.changeRestockTimeRow.locator('.sw-single-select__selection-input');
this.restockTimeInput = this.changeRestockTimeRow.getByPlaceholder('Enter restock time in days...');
this.restockTimeInput = this.changeRestockTimeRow.locator('#restock-time');

// Tags
this.changeTagsRow = page.locator('.sw-bulk-edit-change-field-tags');
this.changeTagsCheckbox = this.changeTagsRow.getByRole('checkbox');
this.tagsChangeMethodDropdown = this.changeTagsRow.locator('.sw-single-select__selection-text');
this.tagsChangeMethodInput = this.changeTagsRow.locator('.sw-single-select__selection-input');
this.tagsInput = this.changeTagsRow.getByPlaceholder('Enter tags...');
this.tagsInput = this.changeTagsRow.locator('.sw-select-selection-list__input');

// Sales Channel
this.changeSalesChannelRow = page.locator('.sw-bulk-edit-change-field-visibilities');
Expand Down
2 changes: 1 addition & 1 deletion src/page-objects/administration/ProductDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class ProductDetail implements PageObject {
this.saleChannelsInput = page.locator('.sw-product-detail__select-visibility');

// Labelling
this.releaseDateInput = page.locator('.sw-block-field', { hasText: 'Release Date' } ).getByPlaceholder('Enter release date...').last();
this.releaseDateInput = page.locator('.sw-product-detail-base__labelling-card').locator('.form-control');

// Media upload interactions
this.uploadMediaButton = page.getByRole('button', { name: 'Upload file' });
Expand Down
25 changes: 13 additions & 12 deletions src/tasks/shop-admin/Product/BulkEditProducts.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { test as base, expect } from '@playwright/test';
import type { Task } from '../../../types/Task';
import type { FixtureTypes} from '../../../types/FixtureTypes';
import type { FixtureTypes } from '../../../types/FixtureTypes';
import { Product } from 'src/types/ShopwareTypes';

interface Change {
value: string;
method: string;
}
}

export const BulkEditProducts = base.extend<{ BulkEditProducts: Task }, FixtureTypes>({
BulkEditProducts: async ({ AdminProductBulkEdit, AdminProductListing }, use ) => {
const task = (products: Product[], changes: Record<string, Change> ) => {
BulkEditProducts: async ({ AdminProductBulkEdit, AdminProductListing }, use) => {
const task = (products: Product[], changes: Record<string, Change>) => {
return async function BulkEditProducts() {

for (const product of products) {
Expand Down Expand Up @@ -48,20 +48,21 @@ export const BulkEditProducts = base.extend<{ BulkEditProducts: Task }, FixtureT
expect(response.ok()).toBeTruthy();
const searchResult = await AdminProductBulkEdit.getDropdownEntry(changes['manufacturer'].value);
await searchResult.click();
}
}

if (changes['releaseDate'] != null) {
await AdminProductBulkEdit.changeReleaseDateCheckbox.click();
await AdminProductBulkEdit.releaseDateInput.fill(changes['releaseDate'].value);
await AdminProductBulkEdit.releaseDateInput.press('Enter');
}

if (changes['stock'] != null) {
await AdminProductBulkEdit.changeStockCheckbox.click();
await AdminProductBulkEdit.stockChangeMethodDropdown.click();
await (await AdminProductBulkEdit.getDropdownEntry(changes['stock'].method)).click();
if (changes['stock'].method != 'Clear') {
await AdminProductBulkEdit.stockInput.fill(changes['stock'].value);
}
}
}

if (changes['restockTime'] != null) {
Expand All @@ -70,7 +71,7 @@ export const BulkEditProducts = base.extend<{ BulkEditProducts: Task }, FixtureT
await (await AdminProductBulkEdit.getDropdownEntry(changes['restockTime'].method)).click();
if (changes['restockTime'].method != 'Clear') {
await AdminProductBulkEdit.restockTimeInput.fill(changes['restockTime'].value);
}
}
}

if (changes['tags'] != null) {
Expand All @@ -89,7 +90,7 @@ export const BulkEditProducts = base.extend<{ BulkEditProducts: Task }, FixtureT
expect(response.ok()).toBeTruthy();
const searchResult = await AdminProductBulkEdit.getDropdownEntry(changes['tags'].value);
await searchResult.click();
}
}
}

if (changes['saleschannel'] != null) {
Expand All @@ -108,13 +109,13 @@ export const BulkEditProducts = base.extend<{ BulkEditProducts: Task }, FixtureT
expect(response.ok()).toBeTruthy();
const searchResult = await AdminProductBulkEdit.getDropdownEntry(changes['saleschannel'].value);
await searchResult.click();
}
}
}

await AdminProductBulkEdit.applyChangesButton.click();
await AdminProductBulkEdit.confirmModalApplyChangesButton.click();
await AdminProductBulkEdit.confirmModalLoadingSpinner.waitFor( { state: 'visible' } );
await AdminProductBulkEdit.confirmModalLoadingSpinner.waitFor( { state: 'hidden' } );
await AdminProductBulkEdit.confirmModalLoadingSpinner.waitFor({ state: 'visible' });
await AdminProductBulkEdit.confirmModalLoadingSpinner.waitFor({ state: 'hidden' });
await expect(AdminProductBulkEdit.confirmModalSuccessHeader).toBeVisible();
await AdminProductBulkEdit.confirmModalSuccessCloseButton.click();
};
Expand Down

0 comments on commit 42e6b11

Please sign in to comment.