Closed nash1111 closed 3 days ago
Latest commit: |
d7f9fda
|
Status: | โ Deploy successful! |
Preview URL: | https://1a6318bc.nash1111-tech-blog.pages.dev |
Branch Preview URL: | https://issue-92.nash1111-tech-blog.pages.dev |
โฑ๏ธ Estimated effort to review [1-5] | 2 |
๐งช Relevant tests | Yes |
๐ Security concerns | No |
โก Key issues to review |
Possible Bug: The screenshots taken in tests/task.spec.tsx do not have a specified format (e.g., PNG, JPEG). It's recommended to specify the format to ensure consistent output across different environments. |
Code Quality: The lastUpdated.ts file does not have a newline at the end of the file. It's a common practice to end files with a newline to comply with POSIX standards. |
Category | Suggestion | Score |
Best practice |
Ensure elements are present before taking screenshots to capture fully loaded pages___ **It's a good practice to check for the presence of elements before taking screenshots toensure the page has loaded correctly. This can prevent screenshots of incomplete or loading pages.** [tests/task.spec.tsx [5-6]](https://github.com/nash1111/nash1111-tech-blog/pull/93/files#diff-267b23c47783cce9f2ec506ab35728afd899f7b64c0a8a39ee429ca5fd2af106R5-R6) ```diff await page.goto('http://localhost:5173/task'); +await page.waitForSelector('#expected-element'); // Adjust selector as needed await page.screenshot({ path: `test-results/screenshots/task-page.png` }); ``` Suggestion importance[1-10]: 10Why: This suggestion addresses a critical aspect of visual testing by ensuring that screenshots are taken only after the page has fully loaded, preventing incomplete captures. | 10 |
Set the viewport size before navigating to the page for consistent screenshot results___ **Consider setting the viewport size before navigating to the page to ensure the screenshotcaptures the intended layout immediately. This avoids potential issues where the layout might change after navigation but before the screenshot is taken.** [tests/task.spec.tsx [12-15]](https://github.com/nash1111/nash1111-tech-blog/pull/93/files#diff-267b23c47783cce9f2ec506ab35728afd899f7b64c0a8a39ee429ca5fd2af106R12-R15) ```diff +await page.setViewportSize({ width: 375, height: 667 }); // iPhone 6/7/8 dimensions await page.goto('http://localhost:5173/blog'); await page.screenshot({ path: `test-results/screenshots/blog-page.png` }); -await page.setViewportSize({ width: 375, height: 667 }); // iPhone 6/7/8 dimensions await page.screenshot({ path: `test-results/screenshots/blog-page-iphone.png` }); ``` Suggestion importance[1-10]: 9Why: This suggestion improves the reliability of the screenshots by ensuring the layout is consistent before navigation, which is crucial for accurate visual testing. | 9 | |
Reset the viewport size after each test to ensure test isolation___ **To ensure test isolation and avoid potential side effects, consider resetting the viewportsize after each test or setting a default size in a global setup function.** [tests/task.spec.tsx [14]](https://github.com/nash1111/nash1111-tech-blog/pull/93/files#diff-267b23c47783cce9f2ec506ab35728afd899f7b64c0a8a39ee429ca5fd2af106R14-R14) ```diff await page.setViewportSize({ width: 375, height: 667 }); // iPhone 6/7/8 dimensions +// Reset to default after test +test.afterEach(async ({ page }) => { + await page.setViewportSize({ width: 1920, height: 1080 }); // Default dimensions +}); ``` Suggestion importance[1-10]: 7Why: This suggestion promotes test isolation and prevents side effects between tests, which is a good practice for reliable test results. | 7 | |
Maintainability |
Use a function to generate paths for screenshots to improve maintainability___ **To avoid hardcoding paths and improve maintainability, consider using a function or aconstant to generate paths for screenshots. This makes it easier to change the base path in one place rather than in multiple test cases.** [tests/task.spec.tsx [6-15]](https://github.com/nash1111/nash1111-tech-blog/pull/93/files#diff-267b23c47783cce9f2ec506ab35728afd899f7b64c0a8a39ee429ca5fd2af106R6-R15) ```diff -await page.screenshot({ path: `test-results/screenshots/task-page.png` }); -await page.screenshot({ path: `test-results/screenshots/blog-page.png` }); -await page.screenshot({ path: `test-results/screenshots/blog-page-iphone.png` }); +const screenshotPath = (filename) => `test-results/screenshots/${filename}`; +await page.screenshot({ path: screenshotPath('task-page.png') }); +await page.screenshot({ path: screenshotPath('blog-page.png') }); +await page.screenshot({ path: screenshotPath('blog-page-iphone.png') }); ``` Suggestion importance[1-10]: 8Why: This suggestion enhances maintainability by centralizing the path generation, making it easier to update paths in the future. | 8 |
User description
Why
Closes #92
What
PR Type
Enhancement, Tests
Description
lastUpdated
timestamp inpublic/lastUpdated.ts
.tests/task.spec.tsx
.public/currentIssues.json
to include a new issue.Changes walkthrough ๐
lastUpdated.ts
Update lastUpdated timestamp
public/lastUpdated.ts - Updated the `lastUpdated` timestamp.
currentIssues.json
Update current issues list
public/currentIssues.json - Updated the list of current issues to include a new issue.
task.spec.tsx
Add Playwright tests for page screenshots
tests/task.spec.tsx
smartphone-sized screenshot.