Skip to content
Merged
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
19 changes: 19 additions & 0 deletions src/api/InventoryService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BaseServiceModel from '@/api/BaseServiceModel';
import { INVENTORY_IMPORT } from '@/constants/apiUrls';
import { MIGRATION_URL } from '@/constants/applicationUrls';
import { jsonToCsv } from '@/utils/ServiceUtils';

class InventoryService extends BaseServiceModel {
Expand All @@ -19,6 +20,24 @@ class InventoryService extends BaseServiceModel {
throw new Error(`Problem importing inventories: ${error instanceof Error ? error.message : String(error)}`);
}
}

/**
Recalculates product_availability for a location from the transaction
ledger. product_availability is a denormalized cache read by several
features (e.g. putaway candidates), so it can go stale relative to the
ledger after certain operations are rolled back; this is the app's own
admin action for reconciling it.
*/
async refreshProductAvailability(locationId: string) {
const apiResponse = await this.request.post(
MIGRATION_URL.refreshProductAvailability(locationId)
);
if (!apiResponse.ok()) {
throw new Error(
`Problem refreshing product availability for location: ${locationId}`
);
}
}
}

export default InventoryService;
7 changes: 7 additions & 0 deletions src/constants/applicationUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const ORDER_URL = {
`${ORDER_URL.list()}?orderType=PUTAWAY_ORDER&status=${status}`,
};

const MIGRATION_URL = {
base: './migration',
refreshProductAvailability: (locationId: string) =>
`${MIGRATION_URL.base}/refreshProductAvailability?location.id=${locationId}`,
};

export {
AUTH_URL,
CYCLE_COUNT_URL,
Expand All @@ -103,6 +109,7 @@ export {
INVOICE_URL,
LOCATION_GROUP_URL,
LOCATION_URL,
MIGRATION_URL,
ORDER_URL,
ORGANIZATION_URL,
PERSON_URL,
Expand Down
4 changes: 4 additions & 0 deletions src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BrowserContext, test as baseTest } from '@playwright/test';
import AuthService from '@/api/AuthService';
import CycleCountService from '@/api/CycleCountService';
import GenericService from '@/api/GenericService';
import InventoryService from '@/api/InventoryService';
import LocationService from '@/api/LocationService';
import PutawayService from '@/api/PutawayService';
import ReceivingService from '@/api/ReceivingService';
Expand Down Expand Up @@ -101,6 +102,7 @@ type Fixtures = {
putawayService: PutawayService;
transactionService: TransactionService;
cycleCountService: CycleCountService;
inventoryService: InventoryService;
// LOCATIONS DATA
mainLocationService: LocationData;
noManageInventoryDepotService: LocationData;
Expand Down Expand Up @@ -200,6 +202,8 @@ export const test = baseTest.extend<Fixtures>({
use(new TransactionService(page.request)),
cycleCountService: async ({ page }, use) =>
use(new CycleCountService(page.request)),
inventoryService: async ({ page }, use) =>
use(new InventoryService(page.request)),
// LOCATIONS
mainLocationService: async ({ page }, use) =>
use(new LocationData(LOCATION_KEY.MAIN, page.request)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class LineItemsTable extends BasePageModel {
getRowByLot(lot: string) {
return this.table.locator(`tr:has-text("${lot}")`);
}

getRowByBinLocation(binLocation: string) {
return new Row(this.page, this.rows.filter({ hasText: binLocation }));
}
}

class Row extends BasePageModel {
Expand Down
16 changes: 9 additions & 7 deletions src/pages/receiving/ReceivingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ReceivingPage extends BasePageModel {
}

get wizzardTitle() {
return this.page.getByTestId('wizardTitle');
return this.page.getByTestId('wizard-title');
}

async assertHeaderIsVisible({
Expand All @@ -54,14 +54,16 @@ class ReceivingPage extends BasePageModel {
return this.page.getByRole('tooltip');
}

assertColumnHeaderTooltipOnReceivingStep = async (columnName: string) => {
await this.receivingStep.table.getColumnHeader(columnName).hover();
await expect(this.tooltip).toContainText(columnName);
assertColumnHeaderIsVisibleOnReceivingStep = async (columnName: string) => {
await expect(
this.receivingStep.table.getColumnHeader(columnName)
).toBeVisible();
};

assertColumnHeaderTooltipOnCheckingStep = async (columnName: string) => {
await this.checkStep.table.getColumnHeader(columnName).hover();
await expect(this.tooltip).toContainText(columnName);
assertColumnHeaderIsVisibleOnCheckingStep = async (columnName: string) => {
await expect(
this.checkStep.table.getColumnHeader(columnName)
).toBeVisible();
};
}

Expand Down
27 changes: 27 additions & 0 deletions src/pages/receiving/components/AutosaveStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect, Page } from '@playwright/test';

import BasePageModel from '@/pages/BasePageModel';

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

get indicator() {
return this.page.getByTestId('receiving-autosave-status');
}

async isSaved() {
await expect(this.indicator).toContainText('Your work is auto-saved');
}

async isSaving() {
await expect(this.indicator).toContainText('Your work is being saved');
}

async hasError() {
await expect(this.indicator).toContainText('Your work was not saved');
}
}

export default AutosaveStatus;
28 changes: 13 additions & 15 deletions src/pages/receiving/components/CheckTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ class CheckTable extends BasePageModel {
}

get table() {
return this.page.getByTestId('items-table');
return this.page.getByTestId('confirm-receipt-table');
}

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

// rows are 1-indexed by convention (row 1 is the first item). Unlike the
// old table, the header row no longer carries role="row", so it doesn't
// occupy index 0 on its own.
row(index: number) {
return new Row(this.page, this.rows.nth(index));
return new Row(this.page, this.rows.nth(index - 1));
}

// rows mixes container rows with item rows (e.g. the first item is at
// row(1), and multi-container shipments leave gaps), so it can't be indexed
// by item position.
get itemRows() {
return this.rows.filter({
has: this.page
.getByTestId('label-field')
.and(this.page.getByLabel('Code', { exact: true })),
has: this.page.locator('[aria-label="Code"]'),
});
}

Expand All @@ -36,15 +37,12 @@ class CheckTable extends BasePageModel {

getColumnHeader(columnName: string) {
return this.table
.locator('.table-header')
.locator('.rt-thead')
.getByText(columnName, { exact: true });
}

getCellValue(row: number, column: string) {
return this.table
.getByRole('row')
.nth(row)
.getByRole('cell', { name: column, exact: true });
return this.rows.nth(row - 1).locator(`[aria-label="${column}"]`);
}
}

Expand All @@ -57,17 +55,17 @@ class Row extends BasePageModel {
}

getItem(name: string) {
return this.row.getByTestId('label-field').getByText(name);
return this.row.locator('[aria-label="Product"]').getByText(name);
}

get code() {
return this.row
.getByTestId('label-field')
.and(this.row.getByLabel('Code', { exact: true }));
return this.row.locator('[aria-label="Code"]');
}

get cancelRemainingCheckbox() {
return this.row.getByTestId('form-field').getByTestId('checkbox');
return this.row
.locator('[data-column-id="cancelRemaining"]')
.getByRole('checkbox');
}
}

Expand Down
48 changes: 13 additions & 35 deletions src/pages/receiving/components/ReceivingTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,51 @@ class ReceivingTable extends BasePageModel {
}

get table() {
return this.page.getByTestId('items-table');
return this.page.getByTestId('receiving-table');
}

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

// rows are 1-indexed by convention (row 1 is the first item), matching the
// rest of the receiving page objects. Unlike the old table, the header row
// no longer carries role="row", so it doesn't occupy index 0 on its own.
row(index: number) {
return new Row(this.page, this.rows.nth(index));
return new Row(this.page, this.rows.nth(index - 1));
}

getColumnHeader(columnName: string) {
return this.table.locator('.table-header').getByText(columnName);
return this.table
.locator('.rt-thead')
.getByText(columnName, { exact: true });
}

getCellValue(row: number, column: string) {
return this.table
.getByRole('row')
.nth(row)
.getByRole('cell', { name: column });
return this.rows.nth(row - 1).locator(`[aria-label="${column}"]`);
}
}

class Row extends BasePageModel {
row: Locator;
receivingNowField: TextField;
commentField: TextField;

constructor(page: Page, row: Locator) {
super(page);
this.row = row;
this.receivingNowField = new TextField(page, 'Receiving now', row);
this.commentField = new TextField(page, 'Comment', row);
}

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

get editButton() {
return this.row.getByRole('button', { name: 'Edit' });
}

getItem(name: string) {
return this.row.getByTestId('label-field').getByText(name);
}

get binLocationSelect() {
return this.row.getByRole('cell', { name: 'Bin Location' });
}

getBinLocation(binLocation: string) {
return this.page
.getByTestId('custom-select-dropdown-menu')
.getByRole('listitem')
.getByText(binLocation, { exact: true });
get commentButton() {
return this.row.getByRole('button', { name: 'Comment' });
}

getZoneLocation(zoneLocation: string) {
return this.page
.getByTestId('custom-select-dropdown-menu')
.locator('.css-5ih5ya-group react-select__group-heading')
.getByText(zoneLocation, { exact: true });
}

get recipientField() {
return this.row.getByRole('cell', { name: 'Recipient' });
getItem(name: string) {
return this.row.locator('[aria-label="Product"]').getByText(name);
}
}

Expand Down
26 changes: 20 additions & 6 deletions src/pages/receiving/steps/CheckStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,44 @@ class CheckStep extends BasePageModel {

async isLoaded() {
await expect(this.table.table).toBeVisible();
await expect(this.table.table.getByText('Loading...')).toBeHidden({
timeout: 20_000,
});
}

get receiveShipmentButton() {
return this.page.getByRole('button', { name: 'Receive shipment' });
return this.page
.locator('.submit-buttons')
.getByRole('button', { name: 'Complete Receipt' });
}

get shimpentInformation() {
return this.page.locator('.form-title');
return this.page.getByTestId('confirm-receipt-details');
}

get originField() {
return this.page.getByRole('textbox', { name: 'Origin' });
return this.shimpentInformation
.locator('.item-details__field')
.filter({ hasText: 'Origin:' })
.locator('.item-details__value');
}

get destinationField() {
return this.page.getByRole('textbox', { name: 'Destination' });
return this.shimpentInformation
.locator('.item-details__field')
.filter({ hasText: 'Destination:' })
.locator('.item-details__value');
}

get shippedOnField() {
return this.page.getByRole('textbox', { name: 'Shipped on' });
return this.shimpentInformation
.locator('.item-details__field')
.filter({ hasText: 'Shipped on:' })
.locator('.item-details__value');
}

get cancelAllRemainingButton() {
return this.page.getByRole('button', { name: 'Cancel all remaining' });
return this.page.getByRole('button', { name: 'Cancel All Remaining' });
}

get validationOnDeliveredOnPastDatePopup() {
Expand Down
Loading
Loading