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

fix(KUI-1369): noIndexMiddleware and noIndexMiddleware.test has been added to make sure that URL with aap*. is not indexed by google #357

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

amirhossein-haerian
Copy link
Contributor

I had to make some tiny changes comparing (KTH/kopps-public-react-web@56e9d6f):

  1. In the server/utils/noIndexMiddleware.js instead of directly exporting the middleware I had to define the function first and then export the function variable because of some ESLint errors.
  2. Since my test cases failed I had to change expect(mock).toHaveBeenCalledOnce() to expect(next).toHaveBeenCalledTimes(1).

…added to make sure that URL with aap*. is not indexed by google
Copy link
Contributor

@belanglos belanglos left a comment

Choose a reason for hiding this comment

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

Good stuff!
Added explanatory comment about toHaveBeenCalledOnce

noIndexMiddleware(req, res, next)

expect(res.getHeader('X-Robots-Tag')).toBeUndefined()
expect(next).toHaveBeenCalledTimes(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good solution. The reason why this works in KP, is that we there use jest-extended

In KP's jest.config.js:
setupFilesAfterEnv: ['jest-extended/all'],

If you want, you can also include jest-extended in kursinfo-web and include it as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing this, I have added the est-extended package and the required config. I also changed "toHaveBeenCalledTimes()" to "toHaveBeenCalledOnce()".

@amirhossein-haerian amirhossein-haerian merged commit 3e82f9f into master Jun 25, 2024
3 checks passed
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.

2 participants