Fix: Correct button attribute and disabled-state assertions in Shard 4 spec files
good first issueinvalidtestno-issue-activityui/ux
## Summary
Shard 4 CI failures involve incorrect assertions on button DOM attributes and state. Tests expect specific `type`, `data-fill`, and disabled attributes on button elements, but the component implementation no longer matches these expectations.
## Root Cause
Component button implementations were modified (e.g. button type changed, disabled logic changed, or `data-fill` attribute removed/renamed), but the test assertions were not updated.
## Affected Shard
- Shard 4 (CI run: https://github.com/PalisadoesFoundation/talawa-admin/actions/runs/24164752343/job/70524317282)
## Failing Assertions
```
expect(element).toHaveAttribute('type', 'button') // FAILS
expect(element).toBeDisabled() // FAILS
expect(element).toHaveAttribute('data-fill', 'var(--bs-secondary)') // FAILS
// Invalid argument type passed to an assertion
```
## Starter Code / Fix Approach
**Step 1:** Identify the specific spec file in Shard 4 by checking the test output:
```bash
gh api /repos/PalisadoesFoundation/talawa-admin/actions/jobs/70524317282/logs | grep -E 'FAIL|●' | head -30
```
**Step 2:** Inspect the button rendering in the component to find the current attribute values:
```bash
rg 'data-fill\|isDisabled\|disabled\|type="button"' src/ --include='*.tsx' -n | grep -v spec
```
**Step 3:** Update assertions to match current component output. For example:
```diff
// Example: if button type was changed to 'submit'
- expect(btn).toHaveAttribute('type', 'button');
+ expect(btn).toHaveAttribute('type', 'submit');
// Example: if disabled is now controlled by aria-disabled
- expect(btn).toBeDisabled();
+ expect(btn).toHaveAttribute('aria-disabled', 'true');
// Example: if data-fill attribute was removed
- expect(btn).toHaveAttribute('data-fill', 'var(--bs-secondary)');
+ // Remove assertion or update to new attribute name
```
**Step 4:** Fix any invalid argument types passed to assertions (ensure element references are non-null before asserting):
```diff
- expect(someVar).toBeDisabled();
+ const btn = screen.getByRole('button', { name: /submit/i });
+ expect(btn).toBeDisabled();
```
**Step 5:** Run the test file locally to confirm:
```bash
npx jest <affected-spec-file> --no-coverage
```
## References
- PR: https://github.com/PalisadoesFoundation/talawa-admin/pull/7543
- Analysis comment: https://github.com/PalisadoesFoundation/talawa-admin/pull/7543#issuecomment-4210543487
- Requested by: @palisadoes
2 条评论