Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ export default defineConfig({
workers: 1,
// Disable parallel execution within test files
fullyParallel: false,
// Global setup to perform login once before all tests
globalSetup: '@redhat-cloud-services/playwright-test-auth/global-setup',
// Global setup to perform login once before all tests (custom version with proxy support)
globalSetup: './playwright/global-setup-with-proxy.ts',
// Default timeout for element lookups and assertions
expect: {
timeout: 10000,
},
use: {
// Base URL for all tests - use environment variable or default to stage
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'https://stage.foo.redhat.com:1337',
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'https://console.stage.redhat.com',
// Reuse authentication state across all tests
storageState: './playwright/.auth/user.json',
// Ignore HTTPS errors globally
ignoreHTTPSErrors: true,
// Optional proxy support via environment variable
...(process.env.E2E_PROXY && { proxy: { server: process.env.E2E_PROXY } }),
},
});
104 changes: 104 additions & 0 deletions playwright/E2E_SETUP_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# E2E Test Setup and Troubleshooting Notes

## Setup Required

### Environment Variables
```bash
E2E_USER=<E2E_USER_PLACEHOLDER>
E2E_PASSWORD='<E2E_PASSWORD_PLACEHOLDER>'
E2E_PROXY=<E2E_PROXY_PLACEHOLDER>
```

**Note:** Contact your team for test account credentials. Do not commit real credentials to this repository.

### Running Tests Locally

```bash
# Single test file
E2E_USER=<E2E_USER_PLACEHOLDER> E2E_PASSWORD='<E2E_PASSWORD_PLACEHOLDER>' E2E_PROXY=<E2E_PROXY_PLACEHOLDER> npx playwright test help-panel-learn-tab.spec.ts

# All help panel tests
E2E_USER=<E2E_USER_PLACEHOLDER> E2E_PASSWORD='<E2E_PASSWORD_PLACEHOLDER>' E2E_PROXY=<E2E_PROXY_PLACEHOLDER> npx playwright test help-panel
```

## Key Issues Resolved

### 1. Proxy Support Was Missing
**Problem:** The `@redhat-cloud-services/playwright-test-auth` package's global setup didn't pass the proxy configuration to the browser context.

**Solution:** Created custom global setup at `playwright/global-setup-with-proxy.ts` that properly passes the proxy from `playwright.config.ts`:

```typescript
const context = await browser.newContext({
ignoreHTTPSErrors: true,
baseURL: baseURL as string,
proxy: proxy, // FIX: Pass proxy config from playwright.config.ts
});
```

### 2. Default Stage URL Was Placeholder
**Problem:** Config had `https://stage.foo.redhat.com:1337` as default.

**Solution:** Updated to real stage URL: `https://console.stage.redhat.com`

### 3. SSO Redirect Detection
**Finding:** Navigating to `/` triggers SSO redirect to:
```text
https://sso.stage.redhat.com/auth/realms/redhat-external/protocol/openid-connect/auth...
```

This is the expected behavior for unauthenticated users.

## Configuration Files

### playwright.config.ts
- Added proxy support: `...(process.env.E2E_PROXY && { proxy: { server: process.env.E2E_PROXY } })`
- Changed global setup to custom version: `./playwright/global-setup-with-proxy.ts`
- Updated default baseURL to `https://console.stage.redhat.com`

### playwright/global-setup-with-proxy.ts
Custom global setup that:
1. Reads proxy config from playwright.config.ts
2. Passes it to browser context
3. Performs SSO login
4. Saves authentication state to `./playwright/.auth/user.json`

## Current Test Status

### Learn Tab
- ✅ 2/6 tests passing
- ❌ 4/6 tests failing due to missing learning resources data
- Likely stage environment doesn't have data for this user
- Or API calls need longer timeouts

### Known Issues
1. **Empty Data State:** Some tests expect learning resources to be present but stage might not have seeded data for the test user
2. **Timing Issues:** Some assertions timeout waiting for elements (10s default)
3. **Bookmark buttons:** Not found, possibly no resources to bookmark

## Debugging Tips

### Run with headed mode (see browser)
```bash
E2E_USER=... E2E_PASSWORD=... E2E_PROXY=... npx playwright test help-panel-learn-tab.spec.ts --headed
```

### Generate trace for debugging
```bash
E2E_USER=... E2E_PASSWORD=... E2E_PROXY=... npx playwright test help-panel-learn-tab.spec.ts --trace on
npx playwright show-trace trace.zip
```

## CI/CD Considerations

In Tekton pipeline:
- Proxy is handled by Caddy server
- Credentials should come from vault/secrets
- Tests run in `mcr.microsoft.com/playwright:v1.59.0-jammy` container

## Next Steps

1. **Investigate data availability:** Check if learning resources exist on stage for test users
2. **Increase timeouts:** Some API calls might need longer than 15s on stage
3. **Add conditional checks:** Handle empty states gracefully in tests
4. **Alternative test users:** Consider using different test accounts with known data
176 changes: 176 additions & 0 deletions playwright/HELP_PANEL_E2E_TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Help Panel E2E Tests

This directory contains comprehensive E2E tests for all Help Panel tabs, covering API integration and critical user flows on stage/production.

## Test Files

| File | JIRA Ticket | Description |
|------|-------------|-------------|
| `help-panel-learn-tab.spec.ts` | RHCLOUD-45255 | Tests learning resources API, filtering, bookmarking |
| `help-panel-api-tab.spec.ts` | RHCLOUD-45256 | Tests API documentation loading, bundle filtering |
| `help-panel-search-tab.spec.ts` | RHCLOUD-45258 | Tests search API, filters, recent queries, bookmarking/favoriting |
| `help-panel-support-tab.spec.ts` | RHCLOUD-45259 | Tests support cases API, empty state, external navigation |
| `help-panel-feedback-tab.spec.ts` | RHCLOUD-45774 | Tests feedback forms, bug reporting, research opportunities |

## What We Test

### ✅ Covered in E2E Tests
- **API Integration**: Real API calls to stage endpoints
- **Data Loading**: Verify resources load from backend
- **Filtering/Scoping**: Bundle filtering, content type filtering
- **Search Functionality**: Search execution, debouncing, result display
- **Bookmarking/Favoriting**: Persisting user preferences via API
- **External Navigation**: Links to Customer Portal, API docs
- **Form Interactions**: Filling forms, validation, state changes
- **Recent History**: localStorage persistence (search queries)
- **Empty States**: No data scenarios
- **Status Indicators**: Icons, labels, badges

### ❌ NOT Tested (Covered by Storybook/Unit Tests)
- **Pagination**: Common PatternFly table component
- **UI Component Rendering**: Component states, visual layouts
- **Filter Chip Interactions**: Removal, clearing
- **Debounce Timing**: Exact millisecond delays
- **Data Formatting**: String manipulation, date formatting

## Running the Tests

### Run all Help Panel E2E tests:
```bash
npm run test:e2e -- help-panel
```

### Run a specific tab:
```bash
npm run test:e2e -- help-panel-learn-tab
npm run test:e2e -- help-panel-api-tab
npm run test:e2e -- help-panel-search-tab
npm run test:e2e -- help-panel-support-tab
npm run test:e2e -- help-panel-feedback-tab
```

### Run in headed mode (see browser):
```bash
npm run test:e2e -- help-panel-learn-tab --headed
```

### Run specific test:
```bash
npm run test:e2e -- help-panel-learn-tab -g "loads learning resources from API"
```

## Test Structure

Each test file follows this structure:

```typescript
test.describe('help panel - {Tab Name}', () => {
test.beforeEach(async ({ page }) => {
// 1. Disable cookie prompts
// 2. Navigate to dashboard
// 3. Wait for chrome header
// 4. Open help panel
// 5. Navigate to specific tab
});

test('test case name', async ({ page }) => {
// Test implementation
});
});
```

## Key Patterns

### Waiting for API Responses
```typescript
// Wait for data to load
await expect(page.locator('[data-ouia-component-id="resource-list"]'))
.toBeVisible({ timeout: 15000 });
```

### Testing External Links
```typescript
const popupPromise = page.waitForEvent('popup', { timeout: 10000 });
await linkButton.click();
const popup = await popupPromise;
expect(popup.url()).toMatch(/access\.redhat\.com/);
await popup.close();
```

### Extracting Counts
```typescript
const toolbar = page.locator('[data-ouia-component-id="toolbar"]');
const text = await toolbar.textContent();
const match = text?.match(/Results \((\d+)\)/);
const count = match ? parseInt(match[1], 10) : 0;
```

### Conditional Tests (Empty vs Data States)
```typescript
const emptyState = page.locator('[data-ouia-component-id="empty-state"]');
const isEmptyVisible = await emptyState.isVisible();

if (isEmptyVisible) {
// Test empty state behavior
} else {
// Test data display behavior
}
```

## Test Data Considerations

- Tests run against **real stage data**
- Support cases, bookmarks, and favorites may vary by user
- Some tests use conditional logic to handle empty states
- Search queries use common terms likely to return results
- Bundle filtering tests check for toggle visibility (not all pages have bundles)

## Debugging

### View test output with trace:
```bash
npm run test:e2e -- help-panel-learn-tab --trace on
```

### View detailed logs:
```bash
npm run test:e2e -- help-panel-learn-tab --debug
```

### Common Issues

1. **Timeout errors**: API is slow on stage, increase timeout in test
2. **Empty state when expecting data**: User has no bookmarks/cases/etc.
3. **Element not found**: Check data-ouia-component-id selector
4. **Popup blocked**: Browser may block new tabs in headless mode

## CI/CD Integration

These tests are designed to run on stage environment as part of E2E test suite:

```yaml
# Example CI configuration
- name: Run Help Panel E2E Tests
run: npm run test:e2e -- help-panel
env:
PLAYWRIGHT_ENV: stage
```

## Coverage Summary

| Tab | Tests | API Calls Tested | Key Features |
|-----|-------|------------------|--------------|
| Learn | 7 | fetchAllData, bookmark API | Filtering, bookmarking, bundle scope |
| API | 5 | fetchBundleInfo, fetchBundles | Bundle filtering, external links |
| Search | 11 | fetchAllData, fetchBundles, favorites API | Search, filters, recent queries, bookmarking |
| Support | 8 | Support cases API | Empty state, case display, external links |
| Feedback | 12 | Feedback submission API | Forms, validation, breadcrumbs |
| **Total** | **43** | **Multiple APIs** | **Complete E2E coverage** |

## Next Steps

After running tests on stage:
1. Review any failures - may indicate real bugs or data issues
2. Update selectors if UI changes
3. Add new tests for new features
4. Maintain tests as APIs evolve
Loading
Loading