Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve parser's e2e test #3373

Merged
merged 2 commits into from
Apr 5, 2022
Merged

Conversation

TueeNguyen
Copy link
Contributor

@TueeNguyen TueeNguyen commented Apr 1, 2022

Issue This PR Addresses

Fixes #3369
Fixes #3369

  • Use blog from test-web-content,
  • Change invalid urls
  • Specify jest.mock() to return a mock function

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Steps to test the PR

  • pnpm i
  • pnpm services:start
  • stop the parser container before running the test
  • pnpm jest:e2e src/api/parser

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@@ -58,10 +58,10 @@ const processFeeds = (feeds) => {
*/
const processAllFeeds = async () => {
try {
// Get an Array of Feed objects from the wiki feed list and Redis
const [all, wiki] = await Promise.all([Feed.all(), getWikiFeeds()]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feed.all() and getWikiFeeds() each returns all feeds => Feed.all() not needed and easier to test

url: 'http://www.hodgin.ca/?feed=rss2&cat=4',
},
];
jest.mock('../../src/utils/wiki-feed-parser', () => jest.fn());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tells The mock factory returns a mocked function so it wouldn't look for __mocks__

const valid = [
{
author: 'Tue Nguyen',
url: 'http://localhost:8888/feed.xml',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses feed.xml from test-web-content instead of doing real network request

},
{
author: 'Jane Doe',
url: 'https://janehasinvalidfeed.com/feed',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these urls don't exist/are invalid => response is fast shouldn't affect test's time

@gitpod-io
Copy link

gitpod-io bot commented Apr 1, 2022

humphd
humphd previously approved these changes Apr 1, 2022
@@ -94,6 +94,7 @@ services:
- elasticsearch
- traefik
- redis
restart: unless-stopped
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #3369

menghif
menghif previously approved these changes Apr 5, 2022
* Use blog from test-web-content
* Change invalid url
* Specify jest.mock() factory to return mocked function => to not look for __mocks__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parser crashes if Elasticsearch not available
3 participants