Files
jdescopingtool/TestScripts/playwright/tests/timespan-pc-partop.spec.ts
T
Joseph Doherty ee044d03e0 feat: add health check endpoint, file upload result handling, and Playwright E2E tests
- Add /health endpoint with anonymous access for monitoring
- Add FileUploadResult<T> model and PostMultipartForFileResultAsync for proper upload response handling
- Add ApiResult.Success() factory method for interface types
- Refactor Login.razor for cleaner code
- Add comprehensive Playwright E2E test suite with fixtures and helpers
2026-01-30 07:12:20 -05:00

264 lines
10 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { navigateToSearchPage } from '../helpers/navigation.helper';
import { selectSearchType, SearchTypes, enterSearchName, clickSubmitSearch, confirmSubmitSearch } from '../helpers/search-type.helper';
import { setDateRange, setMinDate, setMaxDate, TestDateRanges } from '../helpers/date-picker.helper';
import { addProfitCenter, addProfitCenters, profitCenterConfig, TestAutocompleteData, getAutocompleteItemCount } from '../helpers/autocomplete.helper';
import { uploadFile, partOperationConfig, getTestFile, TestFiles, getUploadedItemCount } from '../helpers/file-upload.helper';
import { assertNoErrorNotification, waitForNotification } from '../helpers/radzen.helper';
import { hasValidationErrors, submitAndExpectError } from '../helpers/validation.helper';
/**
* Test suite for Search Type 70: Time Span + Profit Center + Item/Operation/MIS
*
* This search type allows users to find work orders within a specified date range,
* filtered by profit center and part operations (Item Number, Operation Number,
* MIS Number, and MIS Revision).
*
* Filters Enabled:
* - Timespan (Min Date, Max Date)
* - Profit Center
* - Part Operations (Item Number, Operation Number, MIS Number, MIS Revision) via file upload
*/
test.describe('Search Type 70: Time Span + Profit Center + Item/Operation/MIS', () => {
test.beforeEach(async ({ page }) => {
await navigateToSearchPage(page);
await selectSearchType(page, SearchTypes.TIMESPAN_PC_PARTOP);
});
test.describe('Positive Test Cases', () => {
test('TC-070-P01: Single Profit Center with Single Part Operation', async ({ page }) => {
// Enter search name
await enterSearchName(page, 'Type70 Single PC and Part Op Test');
// Set date range
await setDateRange(page, '2018-01-01', '2020-09-01');
// Add profit center
await addProfitCenter(page, '1PM');
// Upload part operations file (contains Item, Operation, MIS, Revision)
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
// Verify no error notification
await assertNoErrorNotification(page);
// Verify part operation was uploaded
const opCount = await getUploadedItemCount(page, partOperationConfig);
expect(opCount).toBeGreaterThan(0);
// Submit search
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
// Verify success notification
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P02: Multiple Profit Centers with Single Part Operation', async ({ page }) => {
await enterSearchName(page, 'Type70 Multiple PC Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
// Add multiple profit centers
await addProfitCenters(page, ['1AM', '1BM', '1CM']);
// Upload single part operation file
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
// Verify all profit centers were added
const pcCount = await getAutocompleteItemCount(page, profitCenterConfig);
expect(pcCount).toBe(3);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P03: Single Profit Center with Multiple Part Operations', async ({ page }) => {
await enterSearchName(page, 'Type70 Multiple Part Ops Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
await addProfitCenter(page, '2DM');
// Upload multiple part operations file
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.MULTIPLE_OPERATIONS));
const opCount = await getUploadedItemCount(page, partOperationConfig);
expect(opCount).toBeGreaterThan(1);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P04: Multiple Profit Centers with Multiple Part Operations', async ({ page }) => {
await enterSearchName(page, 'Type70 Multiple PC and Part Ops Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
// Add multiple profit centers
await addProfitCenters(page, ['1PM', '2SM', '3TM']);
// Upload multiple part operations file
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.MULTIPLE_OPERATIONS));
const pcCount = await getAutocompleteItemCount(page, profitCenterConfig);
expect(pcCount).toBe(3);
const opCount = await getUploadedItemCount(page, partOperationConfig);
expect(opCount).toBeGreaterThan(1);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P05: Recent Date Range', async ({ page }) => {
await enterSearchName(page, 'Type70 Recent Range Test');
await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max);
await addProfitCenter(page, '4IM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P06: Historical Date Range', async ({ page }) => {
await enterSearchName(page, 'Type70 Historical Range Test');
await setDateRange(page, TestDateRanges.HISTORICAL.min, TestDateRanges.HISTORICAL.max);
await addProfitCenter(page, '5SM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P07: Same Day Date Range', async ({ page }) => {
await enterSearchName(page, 'Type70 Same Day Test');
await setDateRange(page, '2019-06-15', '2019-06-15');
await addProfitCenter(page, '1AM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-070-P08: All Profit Centers with Single Part Operation', async ({ page }) => {
await enterSearchName(page, 'Type70 All Profit Centers Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
// Add all profit centers
await addProfitCenters(page, TestAutocompleteData.profitCenters);
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
// Verify all 9 profit centers were added
const pcCount = await getAutocompleteItemCount(page, profitCenterConfig);
expect(pcCount).toBe(9);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
});
test.describe('Negative Test Cases', () => {
test('TC-070-N01: Missing Search Name', async ({ page }) => {
// Leave search name empty
await setDateRange(page, '2018-01-01', '2020-09-01');
await addProfitCenter(page, '1PM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N02: Missing Profit Center', async ({ page }) => {
await enterSearchName(page, 'Type70 Missing PC Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
// Do not add any profit centers
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N03: Missing Part Operation', async ({ page }) => {
await enterSearchName(page, 'Type70 Missing Part Op Test');
await setDateRange(page, '2018-01-01', '2020-09-01');
await addProfitCenter(page, '1PM');
// Do not upload any part operations
await submitAndExpectError(page);
});
test('TC-070-N04: Missing Minimum Date', async ({ page }) => {
await enterSearchName(page, 'Type70 Missing Min Date Test');
// Only set max date
await setMaxDate(page, '2020-09-01');
await addProfitCenter(page, '1PM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N05: Missing Maximum Date', async ({ page }) => {
await enterSearchName(page, 'Type70 Missing Max Date Test');
// Only set min date
await setMinDate(page, '2018-01-01');
await addProfitCenter(page, '1PM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N06: Invalid Date Range (Min > Max)', async ({ page }) => {
await enterSearchName(page, 'Type70 Invalid Date Range Test');
await setDateRange(page, TestDateRanges.INVALID_REVERSED.min, TestDateRanges.INVALID_REVERSED.max);
await addProfitCenter(page, '1PM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N07: Whitespace-Only Search Name', async ({ page }) => {
await enterSearchName(page, ' ');
await setDateRange(page, '2018-01-01', '2020-09-01');
await addProfitCenter(page, '1PM');
await uploadFile(page, partOperationConfig, getTestFile(TestFiles.SINGLE_OPERATION));
await submitAndExpectError(page);
});
test('TC-070-N08: Missing All Required Filters', async ({ page }) => {
await enterSearchName(page, 'Type70 No Filters Test');
// Leave minimum date empty
// Leave maximum date empty
// Do not add any profit centers
// Do not add any part operations
await clickSubmitSearch(page);
await page.waitForTimeout(1000);
// Should have validation errors
expect(await hasValidationErrors(page)).toBe(true);
});
});
});