This project uses Playwright and Node.js to validate that the first 100 articles on Hacker News Newest are sorted from newest to oldest.
-
Clone the repository:
git clone https://github.com/Levitiku5/qa-wolf-assignment cd qa_wolf_take_home -
Install dependencies:
npm install
-
Install required browsers via Playwright:
npx playwright install
If you're on Linux and see missing library errors (e.g.,
libdbus-glib-1.so.2), install system dependencies:sudo apt install libdbus-glib-1-2 # Debian/Ubuntu
node index.js-
The script will:
- Open Chromium via Playwright
- Navigate to the newest Hacker News page
- Paginate through articles until 100 are collected
- Validate that article IDs are strictly decreasing (newest to oldest)
- Output a success/failure message in the terminal
-
Uses
page.$$evalto extract articleitem?id=links and parse their numeric IDs. -
Handles pagination by clicking the
Morebutton until at least 100 unique articles are collected. -
Once 100 articles are gathered:
- It checks that the array of IDs is in strict descending order (i.e., each newer article has a higher ID).
-
Outputs clear messaging in the terminal with the result.
- Assumes article ID is a proxy for post time. While this holds true in practice on Hacker News, a more robust approach would validate against actual timestamps (not available directly).
- Does not currently validate the "X minutes ago" age indicators. This could be used as a secondary verification method.
- No CLI arguments or logging modes yet. It could be enhanced to allow flags like
--verbose,--limit=200, or--report=html. - HTML report output could make this suitable for CI pipelines or automated QA dashboards.