Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import StockMovementService from '@/api/StockMovementService';
import ImpersonateBanner from '@/components/ImpersonateBanner';
import LocationChooser from '@/components/LocationChooser';
import Navbar from '@/components/Navbar';
import AppConfig, {
LOCATION_KEY,
USER_KEY,
} from '@/config/AppConfig';
import AppConfig, { LOCATION_KEY, USER_KEY } from '@/config/AppConfig';
import CreateInbound from '@/pages/inbound/create/CreateInboundPage';
import InboundListPage from '@/pages/inbound/list/InboundListPage';
import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage';
Expand All @@ -28,6 +25,7 @@ import OrganizationListPage from '@/pages/oranization/OrganizationListPage';
import CreatePersonPage from '@/pages/people/CreatePersonPage';
import PersonsListPage from '@/pages/people/PersonsListPage';
import CreateProductPage from '@/pages/product/CreateProductPage';
import ProductEditPage from '@/pages/product/productEdit/ProductEditPage';
import ProductShowPage from '@/pages/product/productShow/ProductShowPage';
import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage';
import PutawayListPage from '@/pages/putaway/list/PutawayListPage';
Expand Down Expand Up @@ -72,6 +70,7 @@ type Fixtures = {
transactionListPage: TransactionListPage;
oldViewShipmentPage: OldViewShipmentPage;
putawayListPage: PutawayListPage;
productEditPage: ProductEditPage;
// COMPONENTS
navbar: Navbar;
locationChooser: LocationChooser;
Expand Down Expand Up @@ -145,6 +144,7 @@ export const test = baseTest.extend<Fixtures>({
oldViewShipmentPage: async ({ page }, use) =>
use(new OldViewShipmentPage(page)),
putawayListPage: async ({ page }, use) => use(new PutawayListPage(page)),
productEditPage: async ({ page }, use) => use(new ProductEditPage(page)),
// COMPONENTS
navbar: async ({ page }, use) => use(new Navbar(page)),
locationChooser: async ({ page }, use) => use(new LocationChooser(page)),
Expand Down Expand Up @@ -179,8 +179,7 @@ export const test = baseTest.extend<Fixtures>({
internalLocation2Service: async ({ page }, use) =>
use(new LocationData(LOCATION_KEY.BIN_LOCATION2, page.request)),
// PRODUCTS
productService: async ({ page }, use) =>
use(new ProductData(page.request)),
productService: async ({ page }, use) => use(new ProductData(page.request)),
// USERS
mainUserService: async ({ page }, use) =>
use(new UserData(USER_KEY.MAIN, page.request)),
Expand Down
27 changes: 27 additions & 0 deletions src/pages/product/productEdit/ProductEditPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Page } from '@playwright/test';

import BasePageModel from '@/pages/BasePageModel';
import InventoryLevelsTabSection from '@/pages/product/productEdit/tabs/InventoryLevelsTabSection';

class ProductEditPage extends BasePageModel {
inventoryLevelsTabSection: InventoryLevelsTabSection;

constructor(page: Page) {
super(page);
this.inventoryLevelsTabSection = new InventoryLevelsTabSection(page);
}

async goToPage(id: string) {
await this.page.goto(`./product/edit/${id}`);
}

get detailskTab() {
return this.page.getByRole('link', { name: 'Details' });
}

get inventoryLevelsTab() {
return this.page.getByRole('link', { name: 'Inventory Levels' });
}
}

export default ProductEditPage;
45 changes: 45 additions & 0 deletions src/pages/product/productEdit/components/createStockLevelModal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Page } from '@playwright/test';

import BasePageModel from '@/pages/BasePageModel';

class CreateStockLevelModal extends BasePageModel {
constructor(page: Page) {
super(page);
}

get modal() {
return this.page.getByRole('dialog');
}

get receivingTab() {
return this.page.getByRole('link', { name: 'Receiving' });
}

get defaultPutawayLocation() {
return this.modal.locator(
'select[name="preferredBinLocation"] + .chosen-container'
);
Comment on lines +19 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't there a better selector?

}

getDefaultPutawayLocation(putawayLocation: string) {
return this.defaultPutawayLocation
.locator('.chosen-results')
.getByRole('listitem')
.getByText(putawayLocation, { exact: true });
}

get createButton() {
return this.modal.getByRole('button', { name: 'Create' });
}

get deleteInventoryLevelButton() {
return this.modal.getByRole('link', { name: 'Delete' });
}

async clickDeleteInventoryLevel() {
this.page.once('dialog', (dialog) => dialog.accept());
await this.deleteInventoryLevelButton.click();
}
}

export default CreateStockLevelModal;
45 changes: 45 additions & 0 deletions src/pages/product/productEdit/tabs/InventoryLevelsTabSection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Locator, Page } from '@playwright/test';

import BasePageModel from '@/pages/BasePageModel';
import CreateStockLevelModal from '@/pages/product/productEdit/components/createStockLevelModal';

class InventoryLevelsTabSection extends BasePageModel {
createStockLevelModal: CreateStockLevelModal;

constructor(page: Page) {
super(page);
this.createStockLevelModal = new CreateStockLevelModal(page);
}

get createStockLevelButton() {
return this.page.getByRole('link', { name: 'Create stock level' });
}

get table() {
return this.page.locator('#ui-tabs-3').getByRole('table');
}

get rows() {
return this.table.getByRole('row');
}

row(index: number) {
return new Row(this.page, this.rows.nth(index));
}
}

class Row extends BasePageModel {
row: Locator;
constructor(page: Page, row: Locator) {
super(page);
this.row = row;
}

get editInventoryLevelButton() {
return this.row
.getByRole('cell')
.locator('a.btn-show-dialog', { hasText: 'Edit' });
}
}

export default InventoryLevelsTabSection;
4 changes: 4 additions & 0 deletions src/pages/product/productShow/ProductShowPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ProductShowPage extends BasePageModel {
get stockHistoryTab() {
return this.page.getByRole('link', { name: 'Stock History' });
}

get editProductkButton() {
return this.page.getByRole('link', { name: 'Edit Product' });
}
}

export default ProductShowPage;
4 changes: 4 additions & 0 deletions src/pages/product/productShow/tabs/InStockTabSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Row extends BasePageModel {
.getByRole('link');
}

get defaultBinLocation() {
return this.row.locator('.line').getByText('Default');
}

get zoneLocation() {
return this.row.locator('.line').locator('.line-base').getByRole('link');
}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/putaway/components/StartPutawayTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class Row extends BasePageModel {
return this.row.getByTestId('cell-0-currentBin').getByText(currentBin);
}

getPreferredBin(rowIndex: number) {
return this.row.getByTestId(`cell-${rowIndex}-preferredBin`);
}

get quantityField() {
return this.row.getByTestId('cell-0-quantity').getByRole('spinbutton');
}
Expand Down
12 changes: 12 additions & 0 deletions src/pages/putaway/steps/CompleteStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ class CompleteStep extends BasePageModel {
get completePutawayButton() {
return this.page.getByTestId('complete-putaway-button').nth(1);
}

get confirmPutawayDialog() {
return this.page.locator('.react-confirm-alert');
}

get yesButtonOnConfirmPutawayDialog() {
return this.confirmPutawayDialog.getByRole('button', { name: 'Yes' });
}

get noButtonOnConfirmPutawayDialog() {
return this.confirmPutawayDialog.getByRole('button', { name: 'No' });
}
Comment on lines +22 to +33
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the dialog be a separated class?

}

export default CompleteStep;
Loading
Loading