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

test: Tests for colorPreference and getUserPRVelocity #190

Merged
merged 6 commits into from
Jun 20, 2023

Conversation

TheLazron
Copy link
Contributor

@TheLazron TheLazron commented Jun 19, 2023

What type of PR is this? (check all applicable)

  •  🍕 Feature
  •  🐛 Bug Fix
  •  📝 Documentation Update
  •  🎨 Style
  •  🧑‍💻 Code Refactor
  •  🔥 Performance Improvements
  •  ✅ Test
  •  🤖 Build
  •  🔁 CI
  •  📦 Chore (Release)
  •  ⏩ Revert

Description

This PR is related to Write tests for utility functions #188 and adds tests for the following files:

  • src/utils/colorPreference.ts
  • src/utils/getUserPRVelocity.ts

In order to work with window object, modifications were made to the Vite config, setting the environment to 'jsdom',
No other files or tests were changed or affected.

Related Tickets & Documents

[#188]

Mobile & Desktop Screenshots/Recordings

image

Added tests?

  •  👍 yes
  •  🙅 no, because they aren't needed
  •  🙋 no, because I need help

Added to documentation?

  •  📜 README.md
  •  📓 docs.opensauced.pizza
  •  🍕 dev.to/opensauced
  •  📕 storybook
  •  🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

anime-computer-gurl

@TheLazron TheLazron changed the title tests: Tests for colorPreference and getUserPRVelocity test: Tests for colorPreference and getUserPRVelocity Jun 19, 2023
test/utils/colorPreference.test.ts Outdated Show resolved Hide resolved
Copy link
Member

@Anush008 Anush008 left a comment

Choose a reason for hiding this comment

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

Thank you for this. 👍👍

@Anush008 Anush008 marked this pull request as ready for review June 20, 2023 17:06
@TheLazron
Copy link
Contributor Author

The failing test is passing in my local dev environment.

@Anush008
Copy link
Member

The failing test is passing in my local dev environment.

Same with me.
@diivi can you try running the tests on your machine?

@diivi
Copy link
Contributor

diivi commented Jun 20, 2023

Weird 😕, can you try changing the test just a bit so the value changes to something else? It passes for me too.

@TheLazron
Copy link
Contributor Author

Sure, will revert back

@Anush008
Copy link
Member

Anush008 commented Jun 20, 2023

This could be due to the varying timezone of the test runner. The new Date() constructor uses the local timezone by default.
https://github.com/TheLazron/ai/blob/2296205cede6ecd77c1dfb4b6356f42d1e9f5ca8/src/utils/getUserPRVelocity.ts#L8-L13

Edit: This shouldn't be a problem since we're getting the difference in days of 2 dates of the same timezone.

@TheLazron
Copy link
Contributor Author

TheLazron commented Jun 20, 2023

This could be due to the varying timezone of the test runner. The new Date() constructor uses the local timezone by default. https://github.com/TheLazron/ai/blob/2296205cede6ecd77c1dfb4b6356f42d1e9f5ca8/src/utils/getUserPRVelocity.ts#L8-L13

So should I try changing the time zone in the tests?

@Anush008
Copy link
Member

Anush008 commented Jun 20, 2023

So should I try changing the time in the tests?

Can you try using Math.floor()here and pushing the commit to rerun the tests with the change?
https://github.com/TheLazron/ai/blob/2296205cede6ecd77c1dfb4b6356f42d1e9f5ca8/src/utils/getUserPRVelocity.ts#L13

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Watched Files

This pull request modifies specific files that require careful review by the maintainers.

Files Matched

  • npm-shrinkwrap.json
  • package.json

@TheLazron
Copy link
Contributor Author

Why did changing it to Math.floor work?

@Anush008
Copy link
Member

Anush008 commented Jun 20, 2023

I suggested Math.floor() assuming that the issue was arising due to the difference in values after the decimal point in the test runner. Math.floor() rounds down to the nearest int, disregarding the decimal value.

Now that the tests pass, there are a few linting errors at https://github.com/open-sauced/ai/actions/runs/5325886058/jobs/9647205001?pr=190. Once they are resolved, we can get this merged.

@bdougie bdougie merged commit 6b9a5c3 into open-sauced:beta Jun 20, 2023
github-actions bot pushed a commit that referenced this pull request Jun 20, 2023
## [1.8.1-beta.1](v1.8.0...v1.8.1-beta.1) (2023-06-20)

### ✅ Tests

* Tests for colorPreference and getUserPRVelocity ([#190](#190)) ([6b9a5c3](6b9a5c3))
@github-actions
Copy link

🎉 This PR is included in version 1.8.1-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Jun 29, 2023
## [1.9.0](v1.8.0...v1.9.0) (2023-06-29)

### ✅ Tests

* Tests for colorPreference and getUserPRVelocity ([#190](#190)) ([6b9a5c3](6b9a5c3))

### 🍕 Features

* post to linkedin projects ([#177](#177)) ([a20bff4](a20bff4))

### 🐛 Bug Fixes

* Made the "Tools:" conditional according to the current page ([#197](#197)) ([b08ad07](b08ad07)), closes [issue#112](https://github.com/open-sauced/issue/issues/112) [issue#112](https://github.com/open-sauced/issue/issues/112)
* separate vite and vitest configs ([#193](#193)) ([7a980c8](7a980c8))
@github-actions
Copy link

🎉 This PR is included in version 1.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

zer0and1 pushed a commit to zer0and1/open-sauced.ai that referenced this pull request Jul 26, 2023
## [1.8.1-beta.1](open-sauced/ai@v1.8.0...v1.8.1-beta.1) (2023-06-20)

### ✅ Tests

* Tests for colorPreference and getUserPRVelocity ([#190](open-sauced/ai#190)) ([6b9a5c3](open-sauced/ai@6b9a5c3))
zer0and1 pushed a commit to zer0and1/open-sauced.ai that referenced this pull request Jul 26, 2023
## [1.9.0](open-sauced/ai@v1.8.0...v1.9.0) (2023-06-29)

### ✅ Tests

* Tests for colorPreference and getUserPRVelocity ([#190](open-sauced/ai#190)) ([6b9a5c3](open-sauced/ai@6b9a5c3))

### 🍕 Features

* post to linkedin projects ([#177](open-sauced/ai#177)) ([a20bff4](open-sauced/ai@a20bff4))

### 🐛 Bug Fixes

* Made the "Tools:" conditional according to the current page ([#197](open-sauced/ai#197)) ([b08ad07](open-sauced/ai@b08ad07)), closes [issue#112](https://github.com/open-sauced/issue/issues/112) [issue#112](https://github.com/open-sauced/issue/issues/112)
* separate vite and vitest configs ([#193](open-sauced/ai#193)) ([7a980c8](open-sauced/ai@7a980c8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants