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 snapshot with non-ascii character #10611

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

TrevinAvery
Copy link
Contributor

@TrevinAvery TrevinAvery commented Feb 25, 2023

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

When running the tests locally on my personal mac, one test would fail to match the snapshot because the snapshot contained invisible non-ASCII characters. Specifically, the issue was in a date string between the seconds and the meridian label.

Snapshot: "localeString": "9/25/2020, 1:08:33 PM"
Local output: "localeString": "9/25/2020, 1:08:33 PM"

You can see they appear the same, but using a character identifier will show that the gap in the local output is:

U+0020 SPACE character

Whereas the gap in the snapshot contains:

U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX character (â)
U+0080 <control> character (&#x0080;)
U+00AF MACRON character (&#x00AF;)

This is because Date.toLocaleString() is not guaranteed to return the same string value in every browser, which makes it unreliable for testing. For this reason, I updated the test to use hard coded values instead.

See this StackOverflow post for more details.

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2023

⚠️ No Changeset found

Latest commit: 18d776e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@alessbell alessbell 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 PR, @TrevinAvery! The snapshot and its space character were updated when the CI image used to run the tests was bumped from Node 18.12 to 19.4. Thanks for making this test more resilient 🎉

@alessbell alessbell merged commit afccbdb into apollographql:main Mar 8, 2023
gastonmorixe added a commit to rocketreferrals/apollo-client that referenced this pull request Mar 10, 2023
commit 72b222e
Merge: def116b afccbdb
Author: Gaston Morixe <gaston@gastonmorixe.com>
Date:   Fri Mar 10 18:23:57 2023 -0300

    Merge branch 'main' into gm/fix/merge-function-called-before-deepmerge-sep202022

commit afccbdb
Author: Trevin Avery <TrevinAvery@gmail.com>
Date:   Wed Mar 8 11:18:47 2023 -0800

    Fix snapshot with non-ascii character (apollographql#10611)

commit 02605bb
Author: Lenz Weber-Tronic <lorenz.weber-tronic@apollographql.com>
Date:   Wed Mar 8 10:18:29 2023 +0100

    `useQuery`: delay unsubscribe to fix race conditions (apollographql#10629)

    * add test for current behavior
    * add failing test for polling
    * slightly delay unsubscribe
    * adjust tests to new behavior

commit 355dce8
Author: Jeff Auriemma <bignimbus@users.noreply.github.com>
Date:   Tue Mar 7 11:47:45 2023 -0500

    Bump date in roadmap

commit 3b504f7
Author: Jeff Auriemma <bignimbus@users.noreply.github.com>
Date:   Tue Mar 7 11:41:42 2023 -0500

    Update dates and notes for upcoming releases

commit c4daaf6
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Mar 6 15:34:20 2023 -0500

    chore(deps): update dependency graphql-ws to v5.12.0 (apollographql#10625)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Alessia Bellisario <alessia@apollographql.com>

commit 88993a2
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Mar 6 14:02:53 2023 -0500

    chore(deps): update dependency @types/node to v18.14.6 (apollographql#10622)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit aa81522
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon Mar 6 14:01:45 2023 -0500

    chore(deps): update dependency rimraf to v4.3.0 (apollographql#10623)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit e4fb0ca
Author: Henry Q. Dineen <henryqdineen@users.noreply.github.com>
Date:   Fri Mar 3 12:14:58 2023 -0500

    remove obsolete @types/fast-json-stable-stringify dev dep (apollographql#10617)

commit 260914a
Author: Trevin Avery <TrevinAvery@gmail.com>
Date:   Fri Mar 3 08:43:01 2023 -0800

    Update batchLink tests to use fake timers (apollographql#10612)

    * Update batchLink tests to use fake timers

    * fix: refactor batch interval test to support fake timers

    ---------

    Co-authored-by: Alessia Bellisario <alessia@apollographql.com>

commit ebee40b
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Fri Mar 3 10:49:59 2023 -0500

    chore(deps): update dependency eslint to v8.35.0 (apollographql#10613)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 5161f09
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 17:41:57 2023 -0700

    chore(deps): update dependency @types/node to v18.14.4 (apollographql#10602)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 7823843
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 17:31:57 2023 -0700

    chore(deps): update cimg/node docker tag to v19.7.0 (apollographql#10605)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit f8fed6b
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 16:59:56 2023 -0700

    chore(deps): update dependency @babel/parser to v7.21.2 (apollographql#10606)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit e9f0dd5
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 16:45:50 2023 -0700

    chore(deps): update dependency @types/glob to v8.1.0 (apollographql#10607)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit bbb04b0
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 16:32:10 2023 -0700

    chore(deps): update dependency terser to v5.16.5 (apollographql#10603)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit f9868b8
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 16:03:25 2023 -0700

    chore(deps): update dependency @typescript-eslint/eslint-plugin to v5.54.0 (apollographql#10608)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit ef13979
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 15:43:19 2023 -0700

    chore(deps): update jaywcjlove/github-action-package action to v1.3.1 (apollographql#10604)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit e6d552f
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu Mar 2 15:33:26 2023 -0700

    chore(deps): update dependency @typescript-eslint/parser to v5.54.0 (apollographql#10609)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit def116b
Merge: a32e0d2 6bd651b
Author: Gaston Morixe <gaston@gastonmorixe.com>
Date:   Tue Sep 20 11:57:40 2022 -0500

    Merge tag 'v3.6.8' into gm/fix/merge-function-called-before-deepmerge-sep202022

commit a32e0d2
Author: Gaston Morixe <gaston@gastonmorixe.com>
Date:   Tue Mar 8 17:38:31 2022 -0300

    custom version

commit 42a20f8
Author: Gaston Morixe <gaston@gastonmorixe.com>
Date:   Tue Mar 8 17:07:12 2022 -0300

    increatese maxSize to 28.65

commit 045a9d5
Author: Gaston Morixe <gaston@gastonmorixe.com>
Date:   Mon Mar 7 18:35:02 2022 -0300

    Run Policies's merge before cache merge

    adds test

    fix formatting
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants