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 broken webapp unit tests #4951

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Dripcoding
Copy link

@Dripcoding Dripcoding commented Dec 8, 2023

Summary

Fix broken jest unit tests for the web app. Run 'npm run test' to run all tests.

Ticket Link

N/A

Fixes #4944

@mattermost-build
Copy link
Contributor

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.

@marianunez marianunez requested review from M-ZubairAhmed, larkox and sbishel and removed request for larkox and M-ZubairAhmed December 8, 2023 21:33
Copy link

@M-ZubairAhmed M-ZubairAhmed left a 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 ?

webapp/package.json Outdated Show resolved Hide resolved
@M-ZubairAhmed

This comment was marked as resolved.

@Dripcoding
Copy link
Author

Ticket mentions changes to be done in focalboard though not in this

I opened an issue because I saw failing tests when I checked out the main branch.


const card1 = TestBlockFactory.createCard(board)
Copy link
Author

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.

Copy link
Contributor

@Rajat-Dabade Rajat-Dabade May 29, 2024

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.

@M-ZubairAhmed
Copy link

Ticket mentions changes to be done in focalboard though not in this

I opened an issue because I saw failing tests when I checked out the main branch.

Oh yeah sorry i mis saw this being opened in the monorepo

@Dripcoding
Copy link
Author

@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.
https://github.com/Dripcoding/focalboard/actions/runs/7235020646/job/19711988610?pr=2

@@ -30,6 +30,7 @@ jobs:
uses: actions/checkout@v3
with:
path: "focalboard"
ref: ${{ env.BRANCH_NAME }}
Copy link
Author

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

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@giuseongit
Copy link

@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

@marianunez marianunez requested review from Rajat-Dabade and removed request for sbishel May 29, 2024 13:51
@@ -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'
Copy link
Contributor

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,

https://github.com/Dripcoding/focalboard/blob/3501411a61f498cb715da5a4e87f696d630eb045/webapp/src/test/testBlockFactory.ts#L117

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')
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 failing

Expected is: July 09 at 3:20 PM, Please check.

Copy link
Contributor

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.

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.

Bug: Broken Jest unit tests
5 participants