Skip to content

Commit

Permalink
Fixes PalisadoesFoundation#1514 added the test for the PostCard and H…
Browse files Browse the repository at this point in the history
…ome.tsx
  • Loading branch information
gauravsingh94 committed Mar 22, 2024
2 parents 067e871 + b9df0aa commit b7fe98a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:

jobs:
Code-Quality-Checks:
name: Performs linting, formatting, type-checking
name: Performs linting, formatting, type-checking, checking for different source and target branch
runs-on: ubuntu-latest
steps:
- name: Checkout the Repository
Expand Down Expand Up @@ -66,6 +66,13 @@ jobs:
chmod +x .github/workflows/compare_translations.py
python .github/workflows/compare_translations.py --directory public/locales
- name: Check if the source and target branches are different
if: ${{ github.event.pull_request.base.ref == github.event.pull_request.head.ref }}
run: |
echo "Source Branch ${{ github.event.pull_request.head.ref }}"
echo "Target Branch ${{ github.event.pull_request.base.ref }}"
echo "Error: Source and Target Branches are the same. Please ensure they are different."
exit 1
Check-Changed-Files:
name: File count, sensitive files and branch check
Expand Down
4 changes: 0 additions & 4 deletions src/assets/svgs/pinUserCardFilled.svg

This file was deleted.

9 changes: 5 additions & 4 deletions src/components/UserPortal/PostCard/PostCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('PostCard compoenent', () => {
creator: {
firstName: 'John',
lastName: 'Doe',
image: '',
image: 'https://example.com/authorimage.jpg',
id: '1',
},
image: 'https://example.com/image.jpg',
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('PostCard compoenent', () => {
</BrowserRouter>
</MockedProvider>,
);
const Image = screen.getByRole('img');
const Image = screen.getByRole('img', { name: 'postImg' });
expect(Image).toBeInTheDocument();
expect(Image).toHaveAttribute('src', postWithImage.image);
});
Expand All @@ -109,7 +109,8 @@ describe('PostCard compoenent', () => {
</BrowserRouter>
</MockedProvider>,
);
const authorProfile = screen.getByRole('button', { name: 'profileImg' });
expect(authorProfile).toBeInTheDocument();
const imgElement = screen.getByRole('img', { name: 'profileImg' });
expect(imgElement).toBeInTheDocument();
expect(imgElement).toHaveAttribute('src', postWithImage.creator.image);
});
});
9 changes: 7 additions & 2 deletions src/components/UserPortal/PostCard/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ export default function postCard(props: InterfacePostCardProps): JSX.Element {
)}
</div>
</div>
{/* image */}
{props.image && <img src={props.image} className={`${styles.img}`} />}
{props.image && (
<img
src={props.image}
className={`${styles.img}`}
aria-label="postImg"
/>
)}
{!props.image && <div className={`${styles.imgNotPresent}`}></div>}
<div className={`${styles.postCardContent}`}>
<span className={`${styles.postHeading}`}>{props.title}</span>
Expand Down

0 comments on commit b7fe98a

Please sign in to comment.