Files
jdescopingtool/TestScripts/deprecated/playwright/tests/timespan-pc-extractmis.spec.ts
T

266 lines
9.7 KiB
TypeScript

import { test, expect, Page } 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 { assertNoErrorNotification, waitForNotification } from '../helpers/radzen.helper';
import { hasValidationErrors, submitAndExpectError } from '../helpers/validation.helper';
/**
* Test suite for Search Type 90: Time Span + Profit Center + Extract MIS
*
* This search type allows users to search by a date range combined with profit center(s)
* and the Extract MIS boolean flag. When Extract MIS is enabled, the search extracts
* MIS (Manufacturing Information System) data associated with work orders.
*
* Filters Enabled:
* - Timespan (Min Date, Max Date)
* - Profit Center
* - Extract MIS (checkbox)
*/
/**
* Helper to set the Extract MIS checkbox state
* @param page - Playwright page object
* @param enabled - Whether to enable (true) or disable (false) Extract MIS
*/
async function setExtractMIS(page: Page, enabled: boolean): Promise<void> {
// Find the Extract MIS checkbox panel
const extractMisPanel = page.locator('.rz-card:has-text("Extract MIS")').or(page.locator(':has-text("Extract MIS")'));
// Find checkbox within the panel or by label
const checkbox = page.locator('input[type="checkbox"]').first();
// Get current state
const isChecked = await checkbox.isChecked();
// Toggle if needed
if (isChecked !== enabled) {
await checkbox.click();
await page.waitForTimeout(300);
}
}
/**
* Helper to check if Extract MIS is enabled
* @param page - Playwright page object
* @returns true if Extract MIS checkbox is checked
*/
async function isExtractMISEnabled(page: Page): Promise<boolean> {
const checkbox = page.locator('input[type="checkbox"]').first();
return await checkbox.isChecked();
}
test.describe('Search Type 90: Time Span + Profit Center + Extract MIS', () => {
test.beforeEach(async ({ page }) => {
await navigateToSearchPage(page);
await selectSearchType(page, SearchTypes.TIMESPAN_PC_EXTRACTMIS);
});
test.describe('Positive Test Cases', () => {
test('TC-090-P01: Single Profit Center with Extract MIS Enabled', async ({ page }) => {
// Enter search name
await enterSearchName(page, 'Test 090-P01 Single PC Extract MIS');
// Set date range
await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max);
// Add profit center
await addProfitCenter(page, '1PM');
// Enable Extract MIS checkbox
await setExtractMIS(page, true);
// Verify checkbox is enabled
expect(await isExtractMISEnabled(page)).toBe(true);
// Verify no error notification
await assertNoErrorNotification(page);
// Submit search
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
// Verify success notification
await waitForNotification(page, 'success', 10000);
});
test('TC-090-P02: Multiple Profit Centers with Extract MIS Enabled', async ({ page }) => {
await enterSearchName(page, 'Test 090-P02 Multiple PC Extract MIS');
await setDateRange(page, TestDateRanges.MID_RANGE.min, TestDateRanges.MID_RANGE.max);
// Add multiple profit centers
await addProfitCenters(page, ['1AM', '1BM', '1CM']);
// Enable Extract MIS
await setExtractMIS(page, true);
// 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-090-P03: Single Profit Center with Extract MIS Disabled', async ({ page }) => {
await enterSearchName(page, 'Test 090-P03 Single PC No Extract MIS');
await setDateRange(page, '2019-01-01', '2019-12-31');
await addProfitCenter(page, '2DM');
// Disable Extract MIS
await setExtractMIS(page, false);
// Verify checkbox is disabled
expect(await isExtractMISEnabled(page)).toBe(false);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-090-P04: Historical Date Range with Multiple Profit Centers', async ({ page }) => {
await enterSearchName(page, 'Test 090-P04 Historical Multi PC');
await setDateRange(page, TestDateRanges.HISTORICAL.min, TestDateRanges.HISTORICAL.max);
// Add multiple profit centers
await addProfitCenters(page, ['3TM', '4IM']);
// Enable Extract MIS
await setExtractMIS(page, true);
const pcCount = await getAutocompleteItemCount(page, profitCenterConfig);
expect(pcCount).toBe(2);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
test('TC-090-P05: All Available Profit Centers', async ({ page }) => {
await enterSearchName(page, 'Test 090-P05 All Profit Centers');
await setDateRange(page, '2018-01-01', '2020-09-01');
// Add all profit centers
await addProfitCenters(page, TestAutocompleteData.profitCenters);
// Enable Extract MIS
await setExtractMIS(page, true);
// 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('TC-090-P06: Same Day Date Range with Extract MIS', async ({ page }) => {
await enterSearchName(page, 'Test 090-P06 Same Day');
await setDateRange(page, TestDateRanges.SAME_DAY.min, TestDateRanges.SAME_DAY.max);
await addProfitCenter(page, '1CM');
await setExtractMIS(page, true);
await assertNoErrorNotification(page);
await clickSubmitSearch(page);
await confirmSubmitSearch(page);
await waitForNotification(page, 'success', 10000);
});
});
test.describe('Negative Test Cases', () => {
test('TC-090-N01: Missing Required Date Range', async ({ page }) => {
await enterSearchName(page, 'Test 090-N01 Missing Dates');
// Leave minimum date empty
// Leave maximum date empty
await addProfitCenter(page, '1PM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N02: Missing Profit Center', async ({ page }) => {
await enterSearchName(page, 'Test 090-N02 Missing Profit Center');
await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max);
// Do NOT add any profit center
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N03: Invalid Date Range (End Before Start)', async ({ page }) => {
await enterSearchName(page, 'Test 090-N03 Invalid Date Range');
await setDateRange(page, TestDateRanges.INVALID_REVERSED.min, TestDateRanges.INVALID_REVERSED.max);
await addProfitCenter(page, '1PM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N04: Missing Minimum Date Only', async ({ page }) => {
await enterSearchName(page, 'Test 090-N04 Missing Min Date');
// Leave minimum date empty
await setMaxDate(page, '2020-09-01');
await addProfitCenter(page, '1AM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N05: Missing Maximum Date Only', async ({ page }) => {
await enterSearchName(page, 'Test 090-N05 Missing Max Date');
await setMinDate(page, '2020-01-01');
// Leave maximum date empty
await addProfitCenter(page, '1BM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N06: Missing Search Name', async ({ page }) => {
// Leave search name empty
await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max);
await addProfitCenter(page, '1PM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N07: Whitespace-Only Search Name', async ({ page }) => {
await enterSearchName(page, ' ');
await setDateRange(page, TestDateRanges.RECENT.min, TestDateRanges.RECENT.max);
await addProfitCenter(page, '1PM');
await setExtractMIS(page, true);
await submitAndExpectError(page);
});
test('TC-090-N08: Missing All Required Filters', async ({ page }) => {
await enterSearchName(page, 'Test 090-N08 No Filters');
// Leave minimum date empty
// Leave maximum date empty
// Do not add any profit centers
// Extract MIS is just a flag, doesn't cause validation error by itself
await clickSubmitSearch(page);
await page.waitForTimeout(1000);
// Should have validation errors
expect(await hasValidationErrors(page)).toBe(true);
});
});
});