-
Notifications
You must be signed in to change notification settings - Fork 2k
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 broken webapp unit tests #4951
base: main
Are you sure you want to change the base?
Fix broken webapp unit tests #4951
Conversation
Hello @Dripcoding, Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When was this broken ?
This comment was marked as resolved.
This comment was marked as resolved.
I opened an issue because I saw failing tests when I checked out the main branch. |
|
||
const card1 = TestBlockFactory.createCard(board) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function relies on Date.now() to populate the createAt
and updatedAt
fields when a block is not provided. I created a new function createCardWithBlock
and passed it a block stub to make it clearer how card fields are populated for this test suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, as at some point in time we might test cases for checking createAt, updateAt and other stuff.
Even though we can directly assign it to the card object, the function makes more sense to avoid duplicity. It is also better to have a concrete time rather than depending on the Date.now because some test cases can fail based on the time and regions.
Oh yeah sorry i mis saw this being opened in the monorepo |
@M-ZubairAhmed I figured out why the tests were failing in the pipeline. Turns out I had a different version of node running locally :] Pushed the fixes and saw the tests passing when I re-triggered the actions in my forked repo. |
@@ -30,6 +30,7 @@ jobs: | |||
uses: actions/checkout@v3 | |||
with: | |||
path: "focalboard" | |||
ref: ${{ env.BRANCH_NAME }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ensures that the feature branch is checked out when the workflows run
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
@Dripcoding please note that this entire project seems quite abandoned, I found this fork following this discussion that could be a replacement for a community-driven product |
@@ -121,6 +121,15 @@ class TestBlockFactory { | |||
return card | |||
} | |||
|
|||
static createCardWithBlock(board?: Board, block?: Block): Card { | |||
const card = createCard(block) | |||
card.boardId = board ? board.id : 'board' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the same code is repeated here as well,
better to reuse it rather than duplicating it.
@@ -153,7 +153,8 @@ describe('utils', () => { | |||
it('should show month, day and time for current year', () => { | |||
const currentYear = new Date().getFullYear() | |||
const date = new Date(currentYear, 6, 9, 15, 20) | |||
expect(Utils.displayDateTime(date, intl)).toBe('July 09, 3:20 PM') | |||
const actual = Utils.displayDateTime(date, intl) | |||
expect(actual).toBe('July 09, 3:20 PM') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is failing
Expected is: July 09 at 3:20 PM
, Please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we are bumping up the node version to v20.11.1 so please make sure you use it for testing.
Summary
Fix broken jest unit tests for the web app. Run 'npm run test' to run all tests.
Ticket Link
N/A
Fixes #4944