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

refactor: replace momentjs in desktop #8959

Conversation

gvdp
Copy link
Contributor

@gvdp gvdp commented Oct 23, 2020

User facing changelog

Replaced momentjs dependency in desktop application

Additional details

Used dayjs to replace the few momentjs functions used in the desktop app. Tried date-fns first but dayjs much more closely follows the momentjs api. Also the locale options for date-fns regarding formatting durations differed a bit. Some of the dates were formatted by a function imported from the server package, I left that intact and just created a similar function using dayjs in this package.
Also added an extra test for the getFormattedTimeFromNow method, I started by adding more test cases (e.g. 44 seconds, 45 seconds, ...) but then it just felt like I was testing the dayjs functionality so I only kept 1 case.

How has the user experience changed?

N/A

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2020

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Oct 23, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

Thanks for the work! This is really helpful towards replacing moment.js overall. 💯

cy.get('@firstRunRow').contains('24:47')
cy.get('.runs-container li').eq(3).contains('45:47')
cy.get('@firstRunRow').contains('12:24:47')
cy.get('@fourthRunRow').contains('12:45:47')
Copy link
Member

Choose a reason for hiding this comment

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

This is what the full value always was - before the changes in this branch.

packages/desktop-gui/cypress/integration/utils_spec.js Outdated Show resolved Hide resolved
@@ -1,6 +1,31 @@
import _ from 'lodash'
import gravatar from 'gravatar'
import duration from '../../../server/lib/util/duration'
Copy link
Member

Choose a reason for hiding this comment

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

yah, it would be nice to sync this back with the server after it's updated to remove moment.js also

@jennifer-shehane jennifer-shehane merged commit bbc1368 into cypress-io:develop Oct 26, 2020
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.

3 participants