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

OBPIH-6686 Add tests for using keyboard shortcuts on receiving table #43

Merged
merged 13 commits into from
Feb 4, 2025
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
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ LOCATION_DEPOT=locationId
LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT=locationId
LOCATION_WARD=locationId
PRODUCT_ONE=productId
PRODUCT_TWO=productId
PRODUCT_TWO=productId
PRODUCT_THREE=productId
PRODUCT_FOUR=productId
PRODUCT_FIVE=productId
9 changes: 6 additions & 3 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ jobs:
LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT: ${{ secrets.LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT }}
PRODUCT_ONE: ${{ secrets.PRODUCT_ONE }}
PRODUCT_TWO: ${{ secrets.PRODUCT_TWO }}
PRODUCT_THREE: ${{ secrets.PRODUCT_THREE }}
PRODUCT_FOUR: ${{ secrets.PRODUCT_FOUR }}
PRODUCT_FIVE: ${{ secrets.PRODUCT_FIVE }}
run: |
echo "Running playwright tests on the ${{ inputs.environment || 'obdev5' }} server"
npx playwright test

- name: Upload Playwright Report to Artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
Expand All @@ -81,11 +84,11 @@ jobs:

- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: playwright-report/

- name: Deploy to Github Pages
if: ${{ always() }}
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ node_modules/
/blob-report/
/playwright/.cache/
/.authStorage/
/localFiles
/localFiles

.idea/
12 changes: 11 additions & 1 deletion src/api/ProductService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BaseServiceModel from '@/api/BaseServiceModel';
import { ApiResponse, ProductDemandResponse } from '@/types';
import { ApiResponse, ProductDemandResponse, ProductResponse } from '@/types';
import { parseRequestToJSON } from '@/utils/ServiceUtils';

class ProductService extends BaseServiceModel {
Expand All @@ -12,6 +12,16 @@ class ProductService extends BaseServiceModel {
throw new Error('Problem fetching product demand');
}
}

async get(id: string): Promise<ApiResponse<ProductResponse>> {
try {
const apiResponse = await this.request.get(`./api/products/${id}`);

return await parseRequestToJSON(apiResponse);
} catch (error) {
throw new Error('Problem fetching product data');
}
}
}

export default ProductService;
2 changes: 2 additions & 0 deletions src/api/StockMovementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class StockMovementService extends BaseServiceModel {
expirationDate: it?.expirationDate
? formatDate(it?.expirationDate)
: undefined,
palletName: it?.palletName,
boxName: it?.boxName,
})),
});
await this.updateStatusStockMovement(id, { status: 'CHECKING' });
Expand Down
31 changes: 27 additions & 4 deletions src/config/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export enum LOCATION_KEY {
export enum PRODUCT_KEY {
ONE = 'productOne',
TWO = 'productTwo',
THREE = 'productThree',
FOUR = 'productFour',
FIVE = 'productFive',
}

/**
Expand Down Expand Up @@ -224,7 +227,9 @@ class AppConfig {
noPickAndPutawayStockDepot: new LocationConfig({
id: env.get('LOCATION_NO_PICK_AND_PUTAWAY_STOCK_DEPOT').asString(),
key: LOCATION_KEY.NO_PICK_AND_PUTAWAY_STOCK,
name: this.uniqueIdentifier.generateUniqueString('no-pickandputawaystock-depot'),
name: this.uniqueIdentifier.generateUniqueString(
'no-pickandputawaystock-depot'
),
requiredActivityCodes: new Set([
ActivityCode.MANAGE_INVENTORY,
ActivityCode.DYNAMIC_CREATION,
Expand All @@ -240,9 +245,6 @@ class AppConfig {
required: false,
type: LocationTypeCode.DEPOT,
}),



};

this.products = {
Expand All @@ -260,6 +262,27 @@ class AppConfig {
quantity: 123,
required: false,
}),
productThree: new ProductConfig({
id: env.get('PRODUCT_THREE').asString(),
key: PRODUCT_KEY.THREE,
name: this.uniqueIdentifier.generateUniqueString('product-three'),
quantity: 150,
required: false,
}),
productFour: new ProductConfig({
id: env.get('PRODUCT_FOUR').asString(),
key: PRODUCT_KEY.FOUR,
name: this.uniqueIdentifier.generateUniqueString('product-four'),
quantity: 100,
required: false,
}),
productFive: new ProductConfig({
id: env.get('PRODUCT_FIVE').asString(),
key: PRODUCT_KEY.FIVE,
name: this.uniqueIdentifier.generateUniqueString('product-five'),
quantity: 160,
required: false,
}),
};
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type Fixtures = {
// PRODUCT DATA
mainProductService: ProductData;
otherProductService: ProductData;
thirdProductService: ProductData;
fourthProductService: ProductData;
fifthProductService: ProductData;
// USERS DATA
mainUserService: UserData;
altUserService: UserData;
Expand Down Expand Up @@ -144,12 +147,18 @@ export const test = baseTest.extend<Fixtures>({
wardLocationService: async ({ page }, use) =>
use(new LocationData(LOCATION_KEY.WARD, page.request)),
noPickAndPutawayStockDepotService: async ({ page }, use) =>
use(new LocationData(LOCATION_KEY.NO_PICK_AND_PUTAWAY_STOCK, page.request)),
use(new LocationData(LOCATION_KEY.NO_PICK_AND_PUTAWAY_STOCK, page.request)),
// PRODUCTS
mainProductService: async ({ page }, use) =>
use(new ProductData(PRODUCT_KEY.ONE, page.request)),
otherProductService: async ({ page }, use) =>
use(new ProductData(PRODUCT_KEY.TWO, page.request)),
thirdProductService: async ({ page }, use) =>
use(new ProductData(PRODUCT_KEY.THREE, page.request)),
fourthProductService: async ({ page }, use) =>
use(new ProductData(PRODUCT_KEY.FOUR, page.request)),
fifthProductService: async ({ page }, use) =>
use(new ProductData(PRODUCT_KEY.FIVE, page.request)),
// USERS
mainUserService: async ({ page }, use) =>
use(new UserData(USER_KEY.MAIN, page.request)),
Expand Down
2 changes: 2 additions & 0 deletions src/pages/receiving/components/ReceivingTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ class ReceivingTable extends BasePageModel {
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() {
Expand Down
Loading