Commit 728c089
authored
test: Shield E2E - Add more Claim scenarios (#38389)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
This PR adds comprehensive E2E test coverage for Shield Claims
functionality, including successful claim submission with file
attachments and error handling scenarios. The changes include:
1. **Added E2E tests for Shield Claims**:
- Successfully submit shield claim form with file attachment and verify
claim details
- Display error when transaction is not eligible (field error
validation)
- Display error toast when duplicate transaction hash is submitted
2. **Enhanced Page Object Model**:
- Added `verifyFieldError()` method for inline field error verification
- Added `verifyToastError()` method for toast error message verification
- Added `uploadTestFile()` method for file upload functionality
- Added `verifyFileUploaded()` method for file upload verification
- Organized selectors alphabetically for better maintainability
3. **Improved Mock Service**:
- Extended `ShieldMockttpService` to support error scenarios (E102:
TRANSACTION_NOT_ELIGIBLE, E203: DUPLICATE_CLAIM_EXISTS)
- Added `claimErrorCode` override parameter for flexible error testing
4. **UI Enhancement**:
- Added `data-testid="shield-claim-impacted-tx-hash-error"` to
transaction hash error field for better testability
5. **Test Data**:
- Created reusable test PDF file
(`test/e2e/test-data/test-document.pdf`) for file upload scenarios
**Motivation**: These tests ensure critical Shield Claims functionality
works correctly, including form validation, error handling, and file
upload capabilities. This improves test coverage and helps prevent
regressions in the claims submission flow.
[](https://codespaces.new/MetaMask/metamask-extension/pull/38389?quickstart=1)
## **Changelog**
CHANGELOG entry: null
*(This is a test-only change and does not affect end-user
functionality)*
## **Related issues**
Fixes:
## **Manual testing steps**
1. Navigate to Settings > Security & Privacy > Transaction Shield
2. Click "Submit Case" button
3. Fill in the claim form with valid data:
- Email address
- Reimbursement wallet address
- Select impacted wallet (Account 1)
- Select network (Mainnet)
- Enter impacted transaction hash
- Enter description
- Upload a PDF file (test-document.pdf)
4. Click "Submit" button
5. Verify success toast message appears
6. Verify claim appears in claims list with "Created" status
7. Click on the claim to view details
8. Verify all claim data is displayed correctly including uploaded file
**Error Scenarios Testing:**
1. **Transaction Not Eligible Error**:
- Submit a claim with a transaction hash that is not eligible
- Verify error message appears on the transaction hash field: "This
transaction is not done within MetaMask, hence it is not eligible for
claims"
2. **Duplicate Claim Error**:
- Submit a claim with a transaction hash that already exists
- Verify error toast appears: "A claim has already been submitted for
this transaction hash."
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
*No E2E tests existed for Shield Claims error scenarios*
### **After**
*E2E tests now cover:*
- ✅ Successful claim submission with file upload
- ✅ Transaction not eligible error (field validation)
- ✅ Duplicate transaction hash error (toast notification)
- ✅ Claim details verification in view mode
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- Added 3 new E2E test cases for Shield Claims
- Enhanced page object methods for error verification
- Extended mock service for error scenario support
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- All new page object methods include JSDoc comments
- Test methods are self-documenting with descriptive names
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- Suggested labels: `test`, `e2e`, `shield`, `enhancement`
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds E2E tests for Shield claim submission (with file upload) and
error cases, updates page objects and mocks, and tags the impacted tx
hash error for testing.
>
> - **E2E Tests (Shield Claims)**:
> - Add scenarios: successful claim with file upload and detail
verification; inline error for ineligible tx; toast error for duplicate
tx.
> - **Page Objects**
(`test/e2e/page-objects/pages/settings/shield/shield-claim-page.ts`):
> - New helpers: `uploadTestFile`, `verifyFileUploaded`,
`verifyFieldError`, `verifyToastError`; extend `fillForm` and
`verifyClaimData` to handle uploads.
> - **Mocks** (`test/e2e/helpers/shield/mocks.ts`):
> - Support submit-claim error injection via `claimErrorCode` (E102,
E203, default); return attachment in success path; propagate overrides
in setup.
> - **Test Data**: Add `test/e2e/test-data/test-document.pdf`.
> - **Constants** (`test/e2e/helpers/shield/constants.ts`): include mock
attachment in `MOCK_CLAIM_2`.
> - **UI**
(`ui/pages/settings/transaction-shield-tab/claims-form/claims-form.tsx`):
> - Add `data-testid="shield-claim-impacted-tx-hash-error"` to impacted
tx hash error help text.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b3c8a41. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent e6d39aa commit 728c089
File tree
6 files changed
+297
-60
lines changed- test/e2e
- helpers/shield
- page-objects/pages/settings/shield
- test-data
- tests/shield
- ui/pages/settings/transaction-shield-tab/claims-form
6 files changed
+297
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
310 | 311 | | |
311 | 312 | | |
312 | 313 | | |
313 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
314 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
315 | 367 | | |
316 | 368 | | |
317 | 369 | | |
| |||
Lines changed: 74 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | | - | |
29 | | - | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| |||
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
| |||
138 | 163 | | |
139 | 164 | | |
140 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
141 | 192 | | |
142 | 193 | | |
143 | 194 | | |
144 | 195 | | |
145 | 196 | | |
| 197 | + | |
146 | 198 | | |
147 | 199 | | |
148 | 200 | | |
| |||
178 | 230 | | |
179 | 231 | | |
180 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
181 | 241 | | |
182 | 242 | | |
183 | 243 | | |
| |||
191 | 251 | | |
192 | 252 | | |
193 | 253 | | |
| 254 | + | |
194 | 255 | | |
195 | 256 | | |
196 | 257 | | |
| |||
200 | 261 | | |
201 | 262 | | |
202 | 263 | | |
| 264 | + | |
203 | 265 | | |
204 | 266 | | |
205 | 267 | | |
| |||
213 | 275 | | |
214 | 276 | | |
215 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
216 | 283 | | |
217 | 284 | | |
218 | 285 | | |
| |||
Binary file not shown.
0 commit comments