Skip to content

Commit 86b1b04

Browse files
authored
Merge branch 'main' into RHOAIENG-36419-Improve-error-handling-in-BFF-API-for-LlamaStack-errors-to-UI
2 parents b1103dc + 7b5484f commit 86b1b04

977 files changed

Lines changed: 55698 additions & 11032 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/contract-tests.mdc

Lines changed: 987 additions & 0 deletions
Large diffs are not rendered by default.

.cursor/rules/cypress-e2e.mdc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ alwaysApply: false
4949

5050
### Folder Structure
5151
```
52-
frontend/src/__tests__/cypress/cypress/
52+
packages/cypress/cypress/
5353
├── fixtures/e2e/ # Test data files (YAML only)
5454
├── pages/ # Page Object Model files
5555
├── tests/e2e/ # Test files organized by feature area
@@ -183,11 +183,10 @@ pageObject.findStatusText().should('contain', 'Running');
183183

184184
**MANDATORY: Always lint before claiming test is complete**:
185185

186-
> **Linting/fixing commands (frontend only):**
187-
> - From the frontend directory, run:
186+
> **Linting/fixing commands (cypress only):**
187+
> - From the packages/cypress directory, run:
188188
> ```bash
189-
> npm run test:lint
190-
> npm run test:fix
189+
> npm run lint -- --fix
191190
> ```
192191

193192
**All linting errors must be fixed**:
@@ -367,14 +366,13 @@ describe('[Product Bug: RHOAIENG-33609] Verify Jupyter Notebook Launch', () => {
367366
```bash
368367
# Check for any remaining quarantine markers
369368
grep -r "@Bug\|@Maintain\|\[Product Bug\|\[Automation Bug" \
370-
frontend/src/__tests__/cypress/cypress/tests/e2e/
369+
packages/cypress/cypress/tests/e2e/
371370
```
372371

373372
5. **Run linting**:
374373
```bash
375-
cd frontend
376-
npm run test:lint
377-
npm run test:fix
374+
cd packages/cypress
375+
npm run lint -- --fix
378376
```
379377

380378
6. **Stage changes and review**:
@@ -487,7 +485,7 @@ During implementation:
487485
- [ ] Never include tags in fixture files
488486

489487
After implementation:
490-
- [ ] Run linting: `npm run test:lint && npm run test:fix` (from the frontend directory)
488+
- [ ] Run linting: `npm run lint -- --fix` (from the packages/cypress directory)
491489
- [ ] Fix ALL linting errors before claiming test is complete
492490
- [ ] Verify test independence and cleanup
493491
- [ ] Test on clean environment

.cursor/rules/cypress-mock.mdc

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ alwaysApply: false
4848

4949
### Folder Structure
5050

51-
**Main Dashboard Tests** (`frontend/src/__tests__/cypress/cypress/`):
51+
**Main Dashboard Tests** (`packages/cypress/cypress/`):
5252
```
53-
frontend/src/__tests__/cypress/cypress/
53+
packages/cypress/cypress/
5454
├── fixtures/mocked/ # Test fixture files (rarely used for mocks)
5555
├── pages/ # Page Object Model files (shared with E2E)
5656
├── tests/mocked/ # Mock test files organized by feature area
@@ -165,17 +165,17 @@ Each module may have specific setup requirements. Always check:
165165

166166
### Test Data Management
167167

168-
**MANDATORY: Use mocks from `__mocks__` folder**:
169-
- All mock data MUST come from the `__mocks__` folder
168+
**MANDATORY: Use mocks from `@odh-dashboard/internal/__mocks__`**:
169+
- All mock data MUST come from the `@odh-dashboard/internal/__mocks__` package (source: `frontend/src/__mocks__/`)
170170
- NEVER create inline mock data in test files
171171
- Import and use existing mock functions (e.g., `mockDashboardConfig`, `mockK8sResourceList`)
172-
- If a mock doesn't exist, create it in `__mocks__` and make it reusable
172+
- If a mock doesn't exist, create it in `frontend/src/__mocks__` and make it reusable
173173
- Mock functions should accept partial data and merge with defaults
174174

175175
**Example mock usage**:
176176
```typescript
177-
import { mockDashboardConfig, mockK8sResourceList } from '#~/__mocks__';
178-
import { mockConnectionTypeConfigMap } from '#~/__mocks__/mockConnectionType';
177+
import { mockDashboardConfig, mockK8sResourceList } from '@odh-dashboard/internal/__mocks__';
178+
import { mockConnectionTypeConfigMap } from '@odh-dashboard/internal/__mocks__/mockConnectionType';
179179

180180
cy.interceptOdh('GET /api/config', mockDashboardConfig({ disableConnectionTypes: false }));
181181
cy.interceptOdh('GET /api/connection-types', [mockConnectionTypeConfigMap({})]);
@@ -1114,9 +1114,9 @@ cy.interceptOdh('POST /api/connection-types', {
11141114

11151115
**Kubernetes API interceptor patterns**:
11161116
```typescript
1117-
import { mockK8sResourceList } from '#~/__mocks__';
1118-
import { mockProjectK8sResource } from '#~/__mocks__/mockProjectK8sResource';
1119-
import { ProjectModel } from '#~/__tests__/cypress/cypress/utils/models';
1117+
import { mockK8sResourceList } from '@odh-dashboard/internal/__mocks__';
1118+
import { mockProjectK8sResource } from '@odh-dashboard/internal/__mocks__/mockProjectK8sResource';
1119+
import { ProjectModel } from '../../../utils/models';
11201120

11211121
// List resources
11221122
cy.interceptK8sList(
@@ -1180,7 +1180,7 @@ cy.findByTestId('status').should('have.text', 'Active');
11801180

11811181
**Use helper utilities for common assertions**:
11821182
```typescript
1183-
import { be } from '#~/__tests__/cypress/cypress/utils/should';
1183+
import { be } from '../../../utils/should';
11841184

11851185
// Table sorting
11861186
table.findTableHeaderButton('Name').should(be.sortAscending);
@@ -1251,7 +1251,7 @@ it('should sort table columns', () => {
12511251

12521252
**Table pagination**:
12531253
```typescript
1254-
import { testPagination } from '#~/__tests__/cypress/cypress/utils/pagination';
1254+
import { testPagination } from '../../../utils/pagination';
12551255

12561256
it('should paginate table results', () => {
12571257
const totalItems = 50;
@@ -1349,7 +1349,7 @@ it('should redirect from old v2 route to new v3 route', () => {
13491349

13501350
**User mocking**:
13511351
```typescript
1352-
import { asProductAdminUser, asProjectAdminUser, asProjectEditUser } from '#~/__tests__/cypress/cypress/utils/mockUsers';
1352+
import { asProductAdminUser, asProjectAdminUser, asProjectEditUser } from '../../../utils/mockUsers';
13531353

13541354
// Product admin (full access)
13551355
asProductAdminUser();
@@ -1363,8 +1363,8 @@ asProjectEditUser();
13631363

13641364
**Common test utilities**:
13651365
```typescript
1366-
import { be } from '#~/__tests__/cypress/cypress/utils/should';
1367-
import { testPagination } from '#~/__tests__/cypress/cypress/utils/pagination';
1366+
import { be } from '../../../utils/should';
1367+
import { testPagination } from '../../../utils/pagination';
13681368

13691369
// Assertion helpers
13701370
element.should(be.sortAscending);
@@ -1412,11 +1412,10 @@ describe('Feature', () => {
14121412

14131413
**MANDATORY: Always lint before claiming test is complete**:
14141414

1415-
> **Linting/fixing commands (must run from frontend directory):**
1415+
> **Linting/fixing commands (must run from packages/cypress directory):**
14161416
> ```bash
1417-
> cd frontend
1418-
> npm run test:lint
1419-
> npm run test:fix
1417+
> cd packages/cypress
1418+
> npm run lint -- --fix
14201419
> ```
14211420

14221421
**All linting errors must be fixed**:
@@ -1435,7 +1434,7 @@ describe('Feature', () => {
14351434
- Complex data structure used in multiple tests
14361435
- Default test data needs to be consistent across tests
14371436

1438-
**Mock function pattern** (in `__mocks__` folder):
1437+
**Mock function pattern** (in `frontend/src/__mocks__` folder, exposed as `@odh-dashboard/internal/__mocks__`):
14391438
```typescript
14401439
// mockFeature.ts
14411440
import type { Feature } from '#~/types';
@@ -1460,7 +1459,7 @@ export const mockFeatureList = (count: number = 3): Feature[] =>
14601459

14611460
**Using mock functions in tests**:
14621461
```typescript
1463-
import { mockFeature } from '#~/__mocks__/mockFeature';
1462+
import { mockFeature } from '@odh-dashboard/internal/__mocks__/mockFeature';
14641463

14651464
// Default mock
14661465
cy.interceptOdh('GET /api/features/:id', mockFeature({}));
@@ -1535,6 +1534,8 @@ npm run test:cypress-ci -- --spec "**/featureName.cy.ts"
15351534

15361535
**Development workflow** (requires separate terminals):
15371536
```bash
1537+
cd frontend
1538+
15381539
# Terminal 1: Start dev server (auto-rebuilds on changes)
15391540
npm run cypress:server:dev
15401541

@@ -1618,7 +1619,7 @@ DEBUG=cypress:* npm run cypress:run:mock
16181619
- [ ] Include accessibility testing (`cy.testA11y()`)
16191620

16201621
### After implementation:
1621-
- [ ] Run linting: `cd frontend && npm run test:lint && npm run test:fix`
1622+
- [ ] Run linting: `cd packages/cypress && npm run lint -- --fix`
16221623
- [ ] Fix ALL linting errors
16231624
- [ ] Run test locally: `npm run test:cypress-ci -- --spec "**/yourTest.cy.ts"`
16241625
- [ ] Verify test passes consistently (run 2-3 times)
@@ -1630,7 +1631,7 @@ DEBUG=cypress:* npm run cypress:run:mock
16301631
### Quality gates:
16311632
- [ ] No direct `cy.findByTestId`, `cy.findByRole`, or `cy.get` in tests
16321633
- [ ] All selectors are in page objects
1633-
- [ ] All mock data comes from `__mocks__` folder
1634+
- [ ] All mock data comes from `@odh-dashboard/internal/__mocks__`
16341635
- [ ] All network requests are mocked
16351636
- [ ] No arbitrary `cy.wait(milliseconds)`
16361637
- [ ] Test is independent (doesn't depend on other tests)
@@ -1642,10 +1643,10 @@ DEBUG=cypress:* npm run cypress:run:mock
16421643

16431644
### Test Structure Template
16441645
```typescript
1645-
import { mockResource } from '#~/__mocks__/mockResource';
1646-
import { featurePage } from '#~/__tests__/cypress/cypress/pages/feature';
1647-
import { asProductAdminUser } from '#~/__tests__/cypress/cypress/utils/mockUsers';
1648-
import { mockDashboardConfig } from '#~/__mocks__';
1646+
import { mockResource } from '@odh-dashboard/internal/__mocks__/mockResource';
1647+
import { mockDashboardConfig } from '@odh-dashboard/internal/__mocks__';
1648+
import { featurePage } from '../../../pages/feature';
1649+
import { asProductAdminUser } from '../../../utils/mockUsers';
16491650

16501651
// Access control test (outside describe block)
16511652
it('Feature should not be available for non-admins', () => {
@@ -1780,7 +1781,7 @@ export const featurePage = new FeaturePage();
17801781
| **Backend** | All requests mocked | Real cluster APIs |
17811782
| **Speed** | Very fast (seconds) | Slower (minutes) |
17821783
| **Setup** | No cluster needed | Requires cluster access |
1783-
| **Data** | Mocked from `__mocks__` | Real cluster resources |
1784+
| **Data** | Mocked from `@odh-dashboard/internal/__mocks__` | Real cluster resources |
17841785
| **Test Variables** | Not used | Uses `test-variables.yml` |
17851786
| **OC Commands** | Never used | Used for setup/cleanup |
17861787
| **Intercepts** | ALWAYS required | Not used |
@@ -1930,7 +1931,7 @@ myPage.clickButton(); // Safe
19301931
**Best practices summary**:
19311932
1. Always use page objects (never direct selectors in tests)
19321933
2. Always mock network requests (use interceptors)
1933-
3. Always use reusable mocks from `__mocks__`
1934+
3. Always use reusable mocks from `@odh-dashboard/internal/__mocks__`
19341935
4. Always test access control and feature flags
19351936
5. Always test error scenarios
19361937
6. Always lint before finishing

0 commit comments

Comments
 (0)