/** * E2E Tests for Search Type 150: Time Span + Work Center + Operator * * This search type allows users to search by a date range combined with work center(s) * and operator(s). It finds work order data within a specific date range, filtered by * work center and operator (user ID). * * Required filters: * - Timespan (Min Date to Max Date) * - Work Center (one or more) * - Operator (one or more) */ 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 { addWorkCenter, addWorkCenters, addOperator, addOperators, workCenterConfig, operatorConfig, getAutocompleteItemCount } from '../helpers/autocomplete.helper'; import { assertNoErrorNotification, hasErrorNotification } from '../helpers/radzen.helper'; import { hasValidationErrors } from '../helpers/validation.helper'; // Valid test data from manual test scripts const TEST_WORK_CENTERS = { SINGLE: '14305CA', MULTIPLE_AS: ['0083AS', '0278AS', '0424AS'], SINGLE_CA: '10595CA', MULTIPLE_CA: ['11275CA', '11350CA'], MIXED: ['0083AS', '10595CA', '1700CB'], // AS, CA, CB formats MANY: ['0586AS', '0696AS', '1010AS', '1011AS'], HISTORICAL: '13316CA', NARROW: '15660CA', RECENT: '11355CA', }; const TEST_OPERATORS = { SINGLE: 'AGNEWA', MULTIPLE: ['AGNEWA', 'AGNEWL', 'ALASMARB'], PAIR: ['ALEXIUCG', 'ALLENHY'], MANY: ['APONTEVE', 'ARCHILAHI', 'ARGUELLC', 'ASHARK'], HISTORICAL: 'ALURUM', NARROW: 'ALVESM1', RECENT: 'ALLENNI', MIXED: 'ASLANESA', FIRST: 'ADAMSSN', }; test.describe('Search Type 150: Time Span + Work Center + Operator', () => { test.beforeEach(async ({ page }) => { await navigateToSearchPage(page); await selectSearchType(page, SearchTypes.TIMESPAN_WC_OPERATOR); }); test.describe('Positive Test Cases', () => { test('TC-150-P01: Single Work Center and Single Operator', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P01 Single Values'); // Set date range (mid-range) await setDateRange(page, '2019-01-01', '2019-12-31'); // Add single work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add single operator await addOperator(page, TEST_OPERATORS.SINGLE); // Verify work center was added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBeGreaterThanOrEqual(1); // Verify operator was added const opCount = await getAutocompleteItemCount(page, operatorConfig); expect(opCount).toBeGreaterThanOrEqual(1); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P02: Multiple Work Centers with Single Operator', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P02 Multiple Work Centers'); // Set date range await setDateRange(page, '2018-01-01', '2019-12-31'); // Add multiple work centers await addWorkCenters(page, TEST_WORK_CENTERS.MULTIPLE_AS); // Verify work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(3); // Add single operator await addOperator(page, TEST_OPERATORS.FIRST); // Verify operator was added const opCount = await getAutocompleteItemCount(page, operatorConfig); expect(opCount).toBe(1); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P03: Single Work Center with Multiple Operators', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P03 Multiple Operators'); // Set date range (recent) await setDateRange(page, '2019-01-01', '2020-09-01'); // Add single work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_CA); // Add multiple operators await addOperators(page, TEST_OPERATORS.MULTIPLE); // Verify work center was added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(1); // Verify operators were added const opCount = await getAutocompleteItemCount(page, operatorConfig); expect(opCount).toBe(3); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P04: Multiple Work Centers and Multiple Operators', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P04 Multiple All'); // Set date range (wide) await setDateRange(page, '2018-01-01', '2020-09-01'); // Add multiple work centers await addWorkCenters(page, TEST_WORK_CENTERS.MULTIPLE_CA); // Add multiple operators await addOperators(page, TEST_OPERATORS.PAIR); // Verify work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(2); // Verify operators were added const opCount = await getAutocompleteItemCount(page, operatorConfig); expect(opCount).toBe(2); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P05: Recent Date Range', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P05 Recent Range'); // Set recent date range await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.RECENT); // Add operator await addOperator(page, TEST_OPERATORS.RECENT); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P06: Historical Date Range', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P06 Historical Range'); // Set historical date range await setDateRange(page, TestDateRanges.HISTORICAL.min, TestDateRanges.HISTORICAL.max); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.HISTORICAL); // Add operator await addOperator(page, TEST_OPERATORS.HISTORICAL); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P07: Narrow Date Range (Single Month)', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P07 Single Month'); // Set narrow date range (single month) await setDateRange(page, '2019-06-01', '2019-06-30'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.NARROW); // Add operator await addOperator(page, TEST_OPERATORS.NARROW); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P08: Many Work Centers and Many Operators', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P08 Many Values'); // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Add many work centers await addWorkCenters(page, TEST_WORK_CENTERS.MANY); // Verify work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(4); // Add many operators await addOperators(page, TEST_OPERATORS.MANY); // Verify operators were added const opCount = await getAutocompleteItemCount(page, operatorConfig); expect(opCount).toBe(4); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); test('TC-150-P09: Mixed Work Center Formats', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-P09 Mixed Formats'); // Set date range (mid-range) await setDateRange(page, '2019-01-01', '2019-12-31'); // Add work centers with different formats (AS, CA, CB) await addWorkCenters(page, TEST_WORK_CENTERS.MIXED); // Verify all work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(3); // Add operator await addOperator(page, TEST_OPERATORS.MIXED); // Verify no error notification await assertNoErrorNotification(page); // Submit search await clickSubmitSearch(page); await confirmSubmitSearch(page); // Should navigate to search page await expect(page).toHaveURL(/\/search\/\d+/); }); }); test.describe('Negative Test Cases', () => { test('TC-150-N01: Missing Date Range', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N01 No Dates'); // Do NOT set date range (leave empty) // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N02: Missing Work Center', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N02 No Work Center'); // Set date range await setDateRange(page, '2019-01-01', '2019-12-31'); // Do NOT add any work center // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N03: Missing Operator', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N03 No Operator'); // Set date range await setDateRange(page, '2019-01-01', '2019-12-31'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Do NOT add any operator // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N04: Start Date After End Date', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N04 Invalid Date Range'); // Set invalid date range (max before min) await setDateRange(page, TestDateRanges.INVALID_REVERSED.min, TestDateRanges.INVALID_REVERSED.max); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N05: Missing Search Name', async ({ page }) => { // Do NOT enter search name // Set date range await setDateRange(page, '2019-01-01', '2019-12-31'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N06: Missing Start Date Only', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N06 No Start Date'); // Set only max date await setMaxDate(page, '2019-12-31'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N07: Missing End Date Only', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N07 No End Date'); // Set only min date await setMinDate(page, '2019-01-01'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE); // Add operator await addOperator(page, TEST_OPERATORS.SINGLE); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N08: All Required Filters Missing', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N08 All Missing'); // Do NOT set date range // Do NOT add work center // Do NOT add operator // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-150-N09: Missing Work Center and Operator', async ({ page }) => { // Enter search name await enterSearchName(page, 'TC-150-N09 No WC No Op'); // Set date range await setDateRange(page, '2019-01-01', '2019-12-31'); // Do NOT add work center // Do NOT add operator // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); }); });