/** * E2E Tests for Search Type 110: Time Span + Work Center + Extract MIS * * This search type allows users to search by a date range combined with work center(s) * and the Extract MIS boolean flag. When this search type is selected, the ExtractMisData * flag is automatically set to true - there is no interactive checkbox. * * Required filters: * - Timespan (Min Date to Max Date) * - Work Center (one or more) * - Extract MIS (automatically enabled when this search type is selected) */ 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, workCenterConfig, 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_CA: '11275CA', SINGLE_AS: '0083AS', MULTIPLE_CA: ['10595CA', '11275CA', '11350CA'], MULTIPLE_AS: ['1010AS', '1011AS'], MIXED_SUFFIXES: ['0696AS', '13316CA', '1700CB'], MANY: ['0083AS', '0278AS', '0424AS', '0586AS', '0696AS', '1010AS'], }; test.describe('Search Type 110: Time Span + Work Center + Extract MIS', () => { test.beforeEach(async ({ page }) => { await navigateToSearchPage(page); await selectSearchType(page, SearchTypes.TIMESPAN_WC_EXTRACTMIS); }); test.describe('Positive Test Cases', () => { test('TC-110-P01: Single Work Center with Extract MIS Enabled', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P01 Single WC Extract MIS'); // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Add single work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_CA); // Note: Extract MIS is automatically enabled when this search type is selected // Verify the Extract MIS checkbox is visible and checked const extractMisCheckbox = page.locator('text=Extract MIS data'); await expect(extractMisCheckbox).toBeVisible(); // Verify work center was added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).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-110-P02: Multiple Work Centers with Extract MIS Enabled', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P02 Multi WC Extract MIS'); // Set date range (recent) await setDateRange(page, '2019-01-01', '2020-09-01'); // Add multiple work centers await addWorkCenters(page, TEST_WORK_CENTERS.MULTIPLE_CA); // Verify work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).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-110-P03: Single Work Center (AS suffix) with Extract MIS', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P03 Single WC AS Suffix'); // Set date range (mid-range) await setDateRange(page, '2018-01-01', '2019-12-31'); // Add single work center with AS suffix await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_AS); // 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-110-P04: Historical Date Range with Multiple Work Centers', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P04 Historical Multi WC'); // Set historical date range await setDateRange(page, TestDateRanges.HISTORICAL.min, TestDateRanges.HISTORICAL.max); // 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(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-110-P05: Work Center Code Variants with Extract MIS', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P05 WC Code Variants'); // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Add work centers with different suffixes (AS, CA, CB) await addWorkCenters(page, TEST_WORK_CENTERS.MIXED_SUFFIXES); // Verify all work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).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-110-P06: Recent Date Range with Single Work Center', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P06 Recent Range'); // Set recent date range await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max); // Add work center await addWorkCenter(page, '14305CA'); // 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-110-P07: Large Work Center Selection', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-P07 Many Work Centers'); // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Add many work centers await addWorkCenters(page, TEST_WORK_CENTERS.MANY); // Verify all work centers were added const wcCount = await getAutocompleteItemCount(page, workCenterConfig); expect(wcCount).toBe(6); // 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-110-N01: Missing Required Date Range', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N01 Missing Dates'); // Do NOT set date range (leave empty) // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_CA); // Extract MIS is automatically enabled // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N02: Missing Work Center', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N02 Missing Work Center'); // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Do NOT add any work center // Extract MIS is automatically enabled // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N03: Invalid Date Range (End Before Start)', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N03 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_CA); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N04: Missing Minimum Date Only', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N04 Missing Min Date'); // Set only max date await setMaxDate(page, '2020-09-01'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_AS); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N05: Missing Maximum Date Only', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N05 Missing Max Date'); // Set only min date await setMinDate(page, '2018-01-01'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_CA); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N06: Missing Search Name', async ({ page }) => { // Do NOT enter search name // Set date range await setDateRange(page, '2018-01-01', '2020-09-01'); // Add work center await addWorkCenter(page, TEST_WORK_CENTERS.SINGLE_CA); // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); test('TC-110-N07: All Required Filters Missing', async ({ page }) => { // Enter search name await enterSearchName(page, 'Test 110-N07 All Filters Missing'); // Do NOT set date range // Do NOT add work center // (Extract MIS is automatically enabled but requires other filters) // Attempt to submit await clickSubmitSearch(page); // Should show validation error expect(await hasValidationErrors(page) || await hasErrorNotification(page)).toBe(true); }); }); });