ITADN

Fix: Update test assertions for renamed CSS Module class names

#7545Opencoderabbitai[bot] 创建于 2026-04-09
good first issuetest
## Summary Test files are asserting CSS module class names that no longer exist on DOM elements. The class names were changed in the component source but the test assertions were not updated. ## Root Cause CSS module class identifiers were renamed in component files. Tests that assert `toHaveClass()` or check `className` directly are now comparing against stale class names. ## Affected Files (Known) - `src/screens/UserPortal/UserGlobalScreen/UserGlobalScreen.spec.tsx` - `src/screens/UserPortal/Organizations/Organizations.spec.tsx` ## Stale vs. Actual Class Name Mapping | Expected (stale) | Actual (in DOM) | Shard | |---|---|---| | `pageContainer` | `contract` or `expand` | 2 | | `sidebarBrandingContainer` | _(not found)_ | 6 | | `hamburgerIconExpanded` | _(empty string)_ | 6 | | `hamburgerIconCollapsed` | `_hamburgerIcon_d1a4a8` | 6 | | `expandedDrawer` | `undefined collapsedDrawer` | 7 | ## Starter Code / Fix Approach **Step 1:** Find the current class names in the CSS module files: ```bash rg 'pageContainer\|sidebarBrandingContainer\|hamburgerIcon\|expandedDrawer' src/screens/UserPortal/ --include='*.module.css' --include='*.module.scss' ``` **Step 2:** Update the test assertions to use the new class names. For example: ```diff // UserGlobalScreen.spec.tsx (example) - expect(container).toHaveClass(styles.pageContainer); + expect(container).toHaveClass(styles.expand); // or styles.contract depending on state - expect(icon).toHaveClass(styles.hamburgerIconCollapsed); + expect(icon).toHaveClass(styles.hamburgerIcon); ``` **Step 3:** For the `expandedDrawer` → `collapsedDrawer` case, check whether the test needs to account for conditional class toggling: ```diff // Example fix for drawer state assertion - expect(drawer).toHaveClass(styles.expandedDrawer); + expect(drawer).toHaveClass(styles.collapsedDrawer); // or verify toggle logic ``` **Step 4:** Run affected tests locally to confirm: ```bash npx jest src/screens/UserPortal/UserGlobalScreen/UserGlobalScreen.spec.tsx --no-coverage npx jest src/screens/UserPortal/Organizations/Organizations.spec.tsx --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
0 条评论