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

feat: display date as time has passed #3840

Merged
merged 3 commits into from
Sep 6, 2024
Merged

Conversation

onim-at
Copy link
Contributor

@onim-at onim-at commented Sep 3, 2024

PR Checklist

PR Type

What kind of change does this PR introduce?

  • Bugfix (fixes an issue)
  • Feature (adds functionality)
  • Code style update
  • Refactoring (no functional changes)
  • Build related changes
  • CI related changes
  • Documentation changes
  • Other... Please describe:

What is the current behavior?

Dates are shown as timestamp

What is the new behavior?

Dates are shown as "time has passed"

To-Do

  • Create component in the library to cover this
  • At least one example in the end-to-end tests of the 'just now' render of the component displayed.
  • Fix ResearchArticle.test.tsx

List everywhere it should go:

  • Comments and nested comments across all modules where there are comments
  • Research module listing
  • Single research and research updates
  • Questions module listing
  • Single question
  • Single How-To

Does this PR introduce a breaking change?

  • Yes
  • No

Git Issues

Closes #3653

What happens next?

Thanks for the contribution! We try to make sure all PRs are reviewed ahead of our monthly maintainers call (first Monday of the month)

If the PR is working as intended it'll be merged and included in the next platform release, if not changes will be requested and re-reviewed once updated.

If you need more immediate feedback you can try reaching out on Discord in the Community Platform development channel.

@benfurber
Copy link
Member

Nice one so far @onim-at - looks like exactly the right direction. 🥳

@onim-at onim-at force-pushed the 3653-date branch 4 times, most recently from 13c0831 to 008f1ed Compare September 5, 2024 08:28
Copy link

cypress bot commented Sep 5, 2024

onearmy-community-platform    Run #6226

Run Properties:  status check passed Passed #6226  •  git commit 25af3a3861: test: add unit test to DisplayDate component
Project onearmy-community-platform
Branch Review pull/3840
Run status status check passed Passed #6226
Run duration 04m 34s
Commit git commit 25af3a3861: test: add unit test to DisplayDate component
Committer cosimochetta
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 60
View all changes introduced in this branch ↗︎

@onim-at onim-at marked this pull request as ready for review September 5, 2024 18:54
@onim-at onim-at requested a review from a team as a code owner September 5, 2024 18:54
@onim-at
Copy link
Contributor Author

onim-at commented Sep 5, 2024

Hello @benfurber! I've added a check on the date in the question cypress test, is this what you intended?
Also I don't know where to ask so I'll try here, is it possible to join the discord developer chat?

@benfurber benfurber added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label Sep 6, 2024
@benfurber
Copy link
Member

benfurber commented Sep 6, 2024

@onim-at Nice one, thank you. I'll have a look today. You should be able to join discord with this link.

Copy link
Contributor

github-actions bot commented Sep 6, 2024

Visit the preview URL for this PR (updated for commit 25af3a3):

https://onearmy-next--pr3840-3653-date-kffnhths.web.app

(expires Sun, 06 Oct 2024 15:30:48 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d65e4f8fee2f6ab2da0c1c3b85b8797d66afa59

Copy link
Member

@benfurber benfurber left a comment

Choose a reason for hiding this comment

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

Just the one thing that's an absolute must change with the console log but there's a couple of bits I'd appreciate.

If you have a look at DiscussionTitle you'll see a style of stories/tests I think would be good.

The stories file has a separate function for each display expected (roughly) and then a test checks that each function has the expected output. So in this instance roughly somthing like:

stories:

export const TwoMonthsAGo: StoryFn<typeof DisplayDate> = () => {
  const twoMonthsAGo = subMonths(new Date(), 2)
  return (
      <DisplayDate date={twoMonthsAGo}></DisplayDate>
)}

test:

describe('DisplayDate', () => {
...
  it('renders correctly when two months ago', () => {
    const { getByText } = render(
      <TwoMonthsAGo {...(TwoMonthsAGo.args as IProps)} />,
    )

    expect(getByText("2 months ago")).toBeInTheDocument()
  })

Then it's a quick test of our implementation of the package (not the package itself) and more importantly, prevents a regression.

packages/components/src/DisplayDate/DisplayDate.tsx Outdated Show resolved Hide resolved
@benfurber benfurber merged commit f34497f into ONEARMY:master Sep 6, 2024
21 checks passed
@onim-at onim-at deleted the 3653-date branch September 6, 2024 15:17
@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 1.216.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@dalibormrska
Copy link
Collaborator

Looks absolutely awesome! I'm really happy to see it implemented! Great job @onim-at and @benfurber! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Research 🔬 released Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[feature request] Improving the display of the date
4 participants