File tree 5 files changed +37
-12
lines changed
5 files changed +37
-12
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ plugins:
30
30
- import
31
31
- react-hooks
32
32
- jest
33
- - no-storage
34
33
- unicorn
35
34
root : true
36
35
rules :
98
97
message :
99
98
" Use path imports to avoid pulling in unused modules. See:
100
99
https://material-ui.com/guides/minimizing-bundle-size/"
101
- no-storage/no-browser-storage : error
102
100
no-unused-vars : " off"
103
101
" object-curly-spacing " : " off"
104
102
react-hooks/exhaustive-deps : warn
Original file line number Diff line number Diff line change 113
113
"eslint-plugin-import" : " 2.26.0" ,
114
114
"eslint-plugin-jest" : " 27.0.1" ,
115
115
"eslint-plugin-jsx-a11y" : " 6.6.1" ,
116
- "eslint-plugin-no-storage" : " 1.0.2" ,
117
116
"eslint-plugin-react" : " 7.31.1" ,
118
117
"eslint-plugin-react-hooks" : " 4.6.0" ,
119
118
"eslint-plugin-unicorn" : " 44.0.0" ,
Original file line number Diff line number Diff line change
1
+ import { fireEvent , screen } from "@testing-library/react"
2
+ import { renderWithAuth } from "testHelpers/renderHelpers"
3
+ import { AccountPage } from "pages/UserSettingsPage/AccountPage/AccountPage"
4
+ import i18next from "i18next"
5
+
6
+ const { t } = i18next
7
+
8
+ describe ( "AuthAndFrame" , ( ) => {
9
+ it ( "sets localStorage key-value when dismissed" , async ( ) => {
10
+ const localStorageMock = {
11
+ ...global . localStorage ,
12
+ getItem : jest . fn ( ) ,
13
+ }
14
+ global . localStorage = localStorageMock
15
+
16
+ // rendering a random page that is wrapped in AuthAndFrame
17
+ return renderWithAuth ( < AccountPage /> )
18
+ fireEvent . click (
19
+ screen . getByRole ( "button" , {
20
+ name : t ( "ctas.dismissCta" , { ns : "common" } ) ,
21
+ } ) ,
22
+ )
23
+ expect ( localStorageMock . getItem ) . toHaveBeenCalledWith ( "dismissedVersion" )
24
+ } )
25
+ } )
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ export const updateCheckMachine = createMachine(
117
117
dismissOrClear : {
118
118
on : {
119
119
DISMISS : {
120
- actions : [ "assignHide" ] ,
120
+ actions : [ "assignHide" , "setDismissedVersion" ] ,
121
121
target : "dismissed" ,
122
122
} ,
123
123
CLEAR : {
@@ -141,9 +141,11 @@ export const updateCheckMachine = createMachine(
141
141
assignPermissions : assign ( {
142
142
permissions : ( _ , event ) => event . data as Permissions ,
143
143
} ) ,
144
- assignShow : assign ( {
145
- show : true ,
146
- } ) ,
144
+ assignShow : assign ( ( context ) => ( {
145
+ show :
146
+ localStorage . getItem ( "dismissedVersion" ) !==
147
+ context . updateCheck ?. version ,
148
+ } ) ) ,
147
149
assignHide : assign ( {
148
150
show : false ,
149
151
} ) ,
@@ -161,6 +163,12 @@ export const updateCheckMachine = createMachine(
161
163
...context ,
162
164
error : undefined ,
163
165
} ) ) ,
166
+ setDismissedVersion : ( context ) => {
167
+ if ( context . updateCheck ?. version ) {
168
+ // We use localStorage to ensure users who have dismissed the UpdateCheckBanner are not plagued by its reappearance on page reload
169
+ localStorage . setItem ( "dismissedVersion" , context . updateCheck . version )
170
+ }
171
+ } ,
164
172
} ,
165
173
guards : {
166
174
canViewUpdateCheck : ( context ) =>
Original file line number Diff line number Diff line change @@ -6557,11 +6557,6 @@ eslint-plugin-jsx-a11y@6.6.1:
6557
6557
minimatch "^3.1.2"
6558
6558
semver "^6.3.0"
6559
6559
6560
- eslint-plugin-no-storage@1.0.2:
6561
- version "1.0.2"
6562
- resolved "https://registry.yarnpkg.com/eslint-plugin-no-storage/-/eslint-plugin-no-storage-1.0.2.tgz#b32b2f00c4084f8e70c6c4ea79704ffe28b6caad"
6563
- integrity sha512-INY2pA4ynTsPIb7wP6+j1QEzDx+zVZ1rZsQkC3up+TQLXsVGg3AnYSqDv/LlwR1QPfh4fDEgQ2Hg5Zxk2XxxEw==
6564
-
6565
6560
eslint-plugin-react-hooks@4.6.0:
6566
6561
version "4.6.0"
6567
6562
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
You can’t perform that action at this time.
0 commit comments