$npx -y skills add anhtester/codex-testing-kit --skill import-test-results-xrayĐẩy kết quả test automation (Playwright/JUnit/Allure) lên Xray Test Management.
| 1 | # Workflow: Import Test Results to Xray |
| 2 | |
| 3 | > **BẮT BUỘC (MANDATORY SKILL):** Bạn PHẢI nạp và đọc kỹ nội dung của skill **`$jira-integration`** (tại `.agents/skills/jira-integration/SKILL.md`) để biết cách sử dụng scripts trước khi bắt đầu. |
| 4 | |
| 5 | Workflow này giúp đẩy kết quả test automation lên Xray (Cloud hoặc Server/Data Center) để tracking trên Jira. |
| 6 | |
| 7 | ## Các bước thực hiện: |
| 8 | |
| 9 | 1. **Kiểm tra prerequisites:** |
| 10 | - Đọc skill `$jira-integration` để nắm cấu trúc scripts. |
| 11 | - Kiểm tra file `.env` đã cấu hình Xray credentials: |
| 12 | - **Xray Cloud**: `XRAY_CLIENT_ID`, `XRAY_CLIENT_SECRET` |
| 13 | - **Xray Server**: `JIRA_PAT` hoặc `JIRA_EMAIL` + `JIRA_API_TOKEN` |
| 14 | - Kiểm tra `XRAY_PLATFORM` (cloud/server) trong `.env`. |
| 15 | - Nếu chưa cài dependencies: `cd scripts/integrations && npm install` |
| 16 | |
| 17 | 2. **Verify Xray authentication:** |
| 18 | ```bash |
| 19 | node scripts/integrations/jira/xray_auth.js --verify |
| 20 | ``` |
| 21 | - Nếu thất bại: kiểm tra credentials trong `.env` |
| 22 | |
| 23 | 3. **Xác định report cần import:** |
| 24 | - Hỏi user loại report: |
| 25 | - **Playwright JSON**: `--format playwright --file <path-to-results.json>` |
| 26 | - **JUnit XML**: `--format junit --file <path-to-junit.xml>` |
| 27 | - **Xray JSON** (đã convert sẵn): `--format xray --file <path-to-xray.json>` |
| 28 | - Xác nhận **Project Key** (từ `.env` hoặc `--project`) |
| 29 | |
| 30 | 4. **Thực thi import:** |
| 31 | ```bash |
| 32 | # Playwright report |
| 33 | node scripts/integrations/jira/xray_importer.js --format playwright --file ./test-results.json --project PROJ |
| 34 | |
| 35 | # JUnit XML |
| 36 | node scripts/integrations/jira/xray_importer.js --format junit --file ./junit-results.xml --project PROJ |
| 37 | |
| 38 | # Xray JSON |
| 39 | node scripts/integrations/jira/xray_importer.js --format xray --file ./xray-payload.json |
| 40 | ``` |
| 41 | |
| 42 | 5. **Xử lý kết quả:** |
| 43 | - Kiểm tra output: Test Execution Key được tạo trên Jira. |
| 44 | - Nếu thành công: thông báo user key của Test Execution mới. |
| 45 | - Nếu thất bại: đọc log → phân tích nguyên nhân → fix → chạy lại. |
| 46 | |
| 47 | 6. **Lưu ý quan trọng:** |
| 48 | - **Test Key Convention**: Test title nên chứa Jira key để Xray mapping tự động: |
| 49 | ```typescript |
| 50 | test('[PROJ-123] Login should work', async ({ page }) => { ... }); |
| 51 | ``` |
| 52 | - **Xray Cloud** cần authenticate riêng (Client ID + Secret), khác với Jira auth. |
| 53 | - **Rate limit**: Tránh import quá nhiều lần liên tiếp. |