Skip to content

Commit

Permalink
add data-testid attributes for toggle state for improved testability
Browse files Browse the repository at this point in the history
  • Loading branch information
im-vedant committed Dec 16, 2024
1 parent 326226b commit b9f0830
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/OrganizationScreen/OrganizationScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ describe('Testing OrganizationScreen', () => {
fireEvent.click(closeButton);

// Check for contract class after closing
expect(
screen.getByTestId('mainpageright').className.includes('expand'),
).toBeTruthy();
expect(screen.getByTestId('mainpageright')).toHaveAttribute(
'data-expanded',
'true',
);

const openButton = screen.getByTestId('openMenu');
fireEvent.click(openButton);

// Check for expand class after opening
expect(
screen.getByTestId('mainpageright').className.includes('contract'),
).toBeTruthy();
expect(screen.getByTestId('mainpageright')).toHaveAttribute(
'data-expanded',
'false',
);
});

test('handles window resize', () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/OrganizationScreen/OrganizationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const OrganizationScreen = (): JSX.Element => {
: styles.contract
} `}
data-testid="mainpageright"
data-expanded={hideDrawer === null ? '' : hideDrawer ? 'true' : 'false'}
>
<div className="d-flex justify-content-between align-items-center">
<div style={{ flex: 1 }}>
Expand Down

0 comments on commit b9f0830

Please sign in to comment.