|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { disableCookiePrompt, PAGE_LOAD_TIMEOUT, openHelpPanel, switchToHelpPanelTab, waitForSupportTabLoaded } from './test-utils'; |
| 3 | + |
| 4 | +/** |
| 5 | + * Support Case Tests |
| 6 | + * |
| 7 | + * Migrated from IQE: iqe_platform_ui/tests/test_support_case.py |
| 8 | + * |
| 9 | + * These tests verify that support case functionality is accessible from the help panel: |
| 10 | + * - "Open a support case" button appears in the help menu |
| 11 | + * - Clicking the button opens the Red Hat Customer Portal support case page |
| 12 | + * |
| 13 | + * TODO: Test #3 (test_support_case_from_apps) - Not yet migrated |
| 14 | + * This test verifies that support case data is pre-filled correctly when opened from |
| 15 | + * different apps. It requires: |
| 16 | + * - Complex setup with actual support cases created via API |
| 17 | + * - Cross-domain interaction with Customer Portal |
| 18 | + * - Authentication on the external portal to validate pre-filled data |
| 19 | + * - May be better suited for insights-chrome repository or separate E2E suite |
| 20 | + * |
| 21 | + * Requirements: |
| 22 | + * - PLATFORM_UI-INSIGHTS_CHROME |
| 23 | + * - PLATFORM_UI-SUPPORT_CASES |
| 24 | + */ |
| 25 | + |
| 26 | +test.describe('Support Case - Help Panel', () => { |
| 27 | + test.beforeEach(async ({ page }) => { |
| 28 | + // Block trustarc cookie prompts |
| 29 | + await disableCookiePrompt(page); |
| 30 | + |
| 31 | + // Navigate to home page - authentication state is already loaded from global setup |
| 32 | + await page.goto('/', { waitUntil: 'load', timeout: PAGE_LOAD_TIMEOUT }); |
| 33 | + |
| 34 | + // Wait for chrome header to be fully loaded |
| 35 | + await expect(page.getByText('Hi,')).toBeVisible(); |
| 36 | + }); |
| 37 | + |
| 38 | + test('should display "Open a support case" link in help panel', async ({ page }) => { |
| 39 | + // Step 1-3: Open help panel and navigate to Support tab |
| 40 | + await openHelpPanel(page); |
| 41 | + await switchToHelpPanelTab(page, 'Support'); |
| 42 | + |
| 43 | + // Step 4: Wait for the support panel to finish loading |
| 44 | + await waitForSupportTabLoaded(page); |
| 45 | + |
| 46 | + // Step 5: The "Open a support case" button should now be visible |
| 47 | + await expect(page.getByRole('button', { name: 'Open a support case' })).toBeVisible(); |
| 48 | + }); |
| 49 | + |
| 50 | + test('should open Customer Portal when clicking "Open a support case" link', async ({ page, context }) => { |
| 51 | + // Step 1-3: Open help panel and navigate to Support tab |
| 52 | + await openHelpPanel(page); |
| 53 | + await switchToHelpPanelTab(page, 'Support'); |
| 54 | + |
| 55 | + // Step 4: Wait for the support panel to finish loading |
| 56 | + await waitForSupportTabLoaded(page); |
| 57 | + |
| 58 | + // Step 5: Set up listener for new page/tab before clicking |
| 59 | + const pagePromise = context.waitForEvent('page'); |
| 60 | + |
| 61 | + // Step 6: Click the "Open a support case" button (use role selector to avoid strict mode violation) |
| 62 | + await page.getByRole('button', { name: 'Open a support case' }).click(); |
| 63 | + |
| 64 | + // Step 7: Wait for new page to open and verify it navigates to Red Hat Customer Portal |
| 65 | + const newPage = await pagePromise; |
| 66 | + |
| 67 | + // Wait for navigation to Red Hat Customer Portal (page starts at about:blank) |
| 68 | + await newPage.waitForURL(/access\.redhat\.com/); |
| 69 | + |
| 70 | + // Verify the destination hostname (we can't validate page content due to auth requirements) |
| 71 | + const url = new URL(newPage.url()); |
| 72 | + expect(url.hostname).toBe('access.redhat.com'); |
| 73 | + |
| 74 | + // Clean up - close the new tab |
| 75 | + await newPage.close(); |
| 76 | + }); |
| 77 | + |
| 78 | + test('should display support cases table when user has open cases', async ({ page }) => { |
| 79 | + // Step 1-3: Open help panel and navigate to Support tab |
| 80 | + await openHelpPanel(page); |
| 81 | + await switchToHelpPanelTab(page, 'Support'); |
| 82 | + |
| 83 | + // Step 4: Wait for support panel to load and check if user has support cases |
| 84 | + await waitForSupportTabLoaded(page); |
| 85 | + |
| 86 | + const supportTable = page.locator('[data-ouia-component-id="help-panel-support-cases-table"]'); |
| 87 | + const emptyState = page.locator('[data-ouia-component-id="help-panel-support-empty-state"]'); |
| 88 | + |
| 89 | + // Check if empty state is visible (user has no cases) |
| 90 | + const emptyVisible = await emptyState.isVisible().catch(() => false); |
| 91 | + if (emptyVisible) { |
| 92 | + // User has no cases, skip this test |
| 93 | + test.skip(); |
| 94 | + return; |
| 95 | + } |
| 96 | + |
| 97 | + // Verify table is visible |
| 98 | + await expect(supportTable).toBeVisible(); |
| 99 | + |
| 100 | + // Verify pagination is present |
| 101 | + const pagination = page.locator('[data-ouia-component-id="help-panel-support-pagination"]'); |
| 102 | + await expect(pagination).toBeVisible(); |
| 103 | + |
| 104 | + // Verify table has at least one row (case) |
| 105 | + const tableRows = supportTable.locator('tbody tr'); |
| 106 | + const rowCount = await tableRows.count(); |
| 107 | + expect(rowCount).toBeGreaterThan(0); |
| 108 | + }); |
| 109 | +}); |
0 commit comments