ee044d03e0
- 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
506 lines
18 KiB
TypeScript
506 lines
18 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, clearDateRange, TestDateRanges } from '../helpers/date-picker.helper';
|
|
import {
|
|
addWorkCenter,
|
|
addWorkCenters,
|
|
clearAutocompleteItems,
|
|
workCenterConfig,
|
|
getAutocompleteItemCount,
|
|
removeAutocompleteItem,
|
|
isAutocompletePanelVisible,
|
|
} from '../helpers/autocomplete.helper';
|
|
import { assertNoErrorNotification, hasSuccessNotification } from '../helpers/radzen.helper';
|
|
import { hasValidationErrors, submitAndExpectError, ValidationMessages } from '../helpers/validation.helper';
|
|
|
|
/**
|
|
* Test suite for Search Type 40: Time Span + Work Center
|
|
*
|
|
* This search type allows users to search by a date range combined with
|
|
* one or more work center codes.
|
|
*
|
|
* Filters Enabled: Timespan, Work Center
|
|
*/
|
|
test.describe('Search Type 40: Time Span + Work Center', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await navigateToSearchPage(page);
|
|
});
|
|
|
|
// Valid work center test data
|
|
const validWorkCenters = {
|
|
AS_SUFFIX: ['0083AS', '0278AS', '0424AS', '0586AS', '0696AS', '1010AS', '1011AS'],
|
|
CA_SUFFIX: ['10595CA', '11275CA', '11350CA', '11355CA', '13316CA', '14305CA', '15660CA', '200038CA', '200039CA', '200041CA', '200042CA'],
|
|
CB_SUFFIX: ['1700CB'],
|
|
NO_SUFFIX: ['200039'],
|
|
};
|
|
|
|
// ============================================================================
|
|
// POSITIVE TEST CASES
|
|
// ============================================================================
|
|
|
|
test.describe('Positive Tests', () => {
|
|
test('TC-040-P01: Single work center with standard date range', async ({ page }) => {
|
|
// Select search type
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
|
|
// Verify filter panels are visible
|
|
await expect(page.locator('text=Filter by Work Center')).toBeVisible();
|
|
await expect(page.locator('text=Filter by Time Span')).toBeVisible();
|
|
|
|
// Enter search name
|
|
await enterSearchName(page, 'TC-040-P01 Single Work Center');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Verify work center appears in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(1);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
// Verify no error notification
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P02: Multiple work centers search', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P02 Multiple Work Centers');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2018-01-01', '2019-12-31');
|
|
|
|
// Add multiple work centers from different categories
|
|
await addWorkCenters(page, ['0083AS', '10595CA', '1700CB']);
|
|
|
|
// Verify all work centers appear in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(3);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P03: Work centers by suffix type (AS)', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P03 AS Work Centers');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add all AS-suffix work centers
|
|
await addWorkCenters(page, validWorkCenters.AS_SUFFIX);
|
|
|
|
// Verify all work centers appear in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(7);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P04: Work centers by suffix type (CA)', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P04 CA Work Centers');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2018-01-01', '2020-09-01');
|
|
|
|
// Add all CA-suffix work centers
|
|
await addWorkCenters(page, validWorkCenters.CA_SUFFIX);
|
|
|
|
// Verify all work centers appear in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(11);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P05: All work centers search', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P05 All Work Centers');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2019-06-01', '2019-12-31');
|
|
|
|
// Add all work centers from all categories
|
|
const allWorkCenters = [
|
|
...validWorkCenters.AS_SUFFIX,
|
|
...validWorkCenters.CA_SUFFIX,
|
|
...validWorkCenters.CB_SUFFIX,
|
|
...validWorkCenters.NO_SUFFIX,
|
|
];
|
|
await addWorkCenters(page, allWorkCenters);
|
|
|
|
// Verify all work centers appear in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(20);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P06: Minimum date range (same day)', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P06 WC Same Day Range');
|
|
|
|
// Set same day date range
|
|
await setDateRange(page, '2019-07-15', '2019-07-15');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '10595CA');
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P07: Boundary date - start of data range', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P07 WC Start Boundary');
|
|
|
|
// Set earliest date boundary
|
|
await setDateRange(page, TestDateRanges.START_BOUNDARY.min, TestDateRanges.START_BOUNDARY.max);
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P08: Boundary date - end of data range', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P08 WC End Boundary');
|
|
|
|
// Set latest date boundary
|
|
await setDateRange(page, TestDateRanges.END_BOUNDARY.min, TestDateRanges.END_BOUNDARY.max);
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '11275CA');
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P09: Historical date range search', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P09 WC Historical Search');
|
|
|
|
// Set historical date range
|
|
await setDateRange(page, TestDateRanges.HISTORICAL.min, TestDateRanges.HISTORICAL.max);
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '14305CA');
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P10: Work center remove and re-add', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P10 WC Remove Re-add');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add work centers
|
|
await addWorkCenter(page, '0083AS');
|
|
await addWorkCenter(page, '0278AS');
|
|
|
|
// Verify both are added
|
|
let itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(2);
|
|
|
|
// Remove first work center (0083AS)
|
|
await removeAutocompleteItem(page, workCenterConfig, 0);
|
|
|
|
// Verify only one remains
|
|
itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(1);
|
|
|
|
// Add another work center
|
|
await addWorkCenter(page, '0424AS');
|
|
|
|
// Verify two work centers in list
|
|
itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(2);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
|
|
test('TC-040-P11: Work center with no suffix (200039)', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-P11 WC No Suffix');
|
|
|
|
// Set date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add work center without suffix
|
|
await addWorkCenter(page, '200039');
|
|
|
|
// Verify work center appears in the list
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(1);
|
|
|
|
// Submit search
|
|
await clickSubmitSearch(page);
|
|
await confirmSubmitSearch(page);
|
|
|
|
await assertNoErrorNotification(page);
|
|
});
|
|
});
|
|
|
|
// ============================================================================
|
|
// NEGATIVE TEST CASES
|
|
// ============================================================================
|
|
|
|
test.describe('Negative Tests', () => {
|
|
test('TC-040-N01: Missing search name', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
|
|
// Do NOT enter search name
|
|
|
|
// Set valid date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
|
|
// Verify user remains on the page
|
|
await expect(page.locator('text=Filter by Work Center')).toBeVisible();
|
|
});
|
|
|
|
test('TC-040-N02: No search type selected', async ({ page }) => {
|
|
// Enter search name without selecting search type
|
|
await enterSearchName(page, 'TC-040-N02 No Type');
|
|
|
|
// Verify filter panels are not visible
|
|
const workCenterPanelVisible = await isAutocompletePanelVisible(page, workCenterConfig);
|
|
expect(workCenterPanelVisible).toBe(false);
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N03: Missing minimum date', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N03 WC Missing Min Date');
|
|
|
|
// Only set maximum date
|
|
await setMaxDate(page, '2019-12-31');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N04: Missing maximum date', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N04 WC Missing Max Date');
|
|
|
|
// Only set minimum date
|
|
await setMinDate(page, '2019-01-01');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N05: Empty work center list', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N05 Empty Work Centers');
|
|
|
|
// Set valid date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Do NOT add any work centers
|
|
|
|
// Verify work center list is empty
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(0);
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N06: Invalid date range (min > max)', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N06 WC Invalid Date Range');
|
|
|
|
// Set invalid date range (min date after max date)
|
|
await setDateRange(page, '2019-12-31', '2019-01-01');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N07: Invalid work center code', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N07 Invalid WC Code');
|
|
|
|
// Set valid date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Try to add invalid work center
|
|
const panel = page.locator(`.rz-card:has-text("${workCenterConfig.panelHeader}")`);
|
|
const autocomplete = panel.locator('.rz-autocomplete input');
|
|
await autocomplete.fill('INVALIDWC');
|
|
|
|
// Wait for autocomplete to search
|
|
await page.waitForTimeout(500);
|
|
|
|
// Verify no autocomplete suggestions appear
|
|
const dropdown = page.locator('.rz-autocomplete-list');
|
|
const dropdownVisible = await dropdown.isVisible({ timeout: 2000 }).catch(() => false);
|
|
|
|
if (dropdownVisible) {
|
|
const items = dropdown.locator('.rz-autocomplete-list-item');
|
|
const count = await items.count();
|
|
expect(count).toBe(0);
|
|
}
|
|
|
|
// Verify work center list is still empty
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(0);
|
|
});
|
|
|
|
test('TC-040-N08: Future date range', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N08 WC Future Dates');
|
|
|
|
// Set future date range
|
|
await setDateRange(page, TestDateRanges.FUTURE.min, TestDateRanges.FUTURE.max);
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Submit search - may be accepted but will return no results
|
|
await clickSubmitSearch(page);
|
|
|
|
// Check if there's a validation error or if it proceeds
|
|
const hasErrors = await hasValidationErrors(page);
|
|
if (!hasErrors) {
|
|
await confirmSubmitSearch(page);
|
|
await assertNoErrorNotification(page);
|
|
}
|
|
});
|
|
|
|
test('TC-040-N09: Invalid date format', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N09 WC Invalid Date Format');
|
|
|
|
// Try to enter invalid date format
|
|
const minDateInput = page.locator('input[name="MinimumDt"]');
|
|
await minDateInput.fill('31-12-2019');
|
|
|
|
await setMaxDate(page, '2019-12-31');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Attempt to submit
|
|
await submitAndExpectError(page);
|
|
});
|
|
|
|
test('TC-040-N10: Work center with special characters', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N10 WC Special Chars');
|
|
|
|
// Set valid date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Try to add work center with special characters
|
|
const panel = page.locator(`.rz-card:has-text("${workCenterConfig.panelHeader}")`);
|
|
const autocomplete = panel.locator('.rz-autocomplete input');
|
|
await autocomplete.fill('0083AS!@#');
|
|
|
|
// Wait for autocomplete to search
|
|
await page.waitForTimeout(500);
|
|
|
|
// Verify no autocomplete suggestions appear for invalid input
|
|
const dropdown = page.locator('.rz-autocomplete-list');
|
|
const dropdownVisible = await dropdown.isVisible({ timeout: 2000 }).catch(() => false);
|
|
|
|
if (dropdownVisible) {
|
|
const items = dropdown.locator('.rz-autocomplete-list-item');
|
|
const count = await items.count();
|
|
expect(count).toBe(0);
|
|
}
|
|
|
|
// Verify work center list is still empty
|
|
const itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(0);
|
|
});
|
|
|
|
test('TC-040-N11: Duplicate work center entry', async ({ page }) => {
|
|
await selectSearchType(page, SearchTypes.TIMESPAN_WORK_CENTER);
|
|
await enterSearchName(page, 'TC-040-N11 WC Duplicate');
|
|
|
|
// Set valid date range
|
|
await setDateRange(page, '2019-01-01', '2019-12-31');
|
|
|
|
// Add work center
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Verify one entry
|
|
let itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(1);
|
|
|
|
// Attempt to add the same work center again
|
|
await addWorkCenter(page, '0083AS');
|
|
|
|
// Wait for any duplicate handling
|
|
await page.waitForTimeout(500);
|
|
|
|
// Verify only one entry remains (duplicate should be rejected)
|
|
itemCount = await getAutocompleteItemCount(page, workCenterConfig);
|
|
expect(itemCount).toBe(1);
|
|
});
|
|
});
|
|
});
|