@@ -4,17 +4,27 @@ import {
4
4
synapseStop ,
5
5
type SynapseInstance ,
6
6
registerUser ,
7
+ getAccountData ,
7
8
updateAccountData ,
8
9
updateUser ,
9
10
} from '../docker/synapse' ;
10
11
import { smtpStart , smtpStop } from '../docker/smtp4dev' ;
11
- import { login , registerRealmUsers , setupUserSubscribed } from '../helpers' ;
12
- import { APP_BOXEL_REALMS_EVENT_TYPE } from '@cardstack/runtime-common/matrix-constants' ;
12
+ import {
13
+ login ,
14
+ logout ,
15
+ registerRealmUsers ,
16
+ setupUserSubscribed ,
17
+ } from '../helpers' ;
18
+
13
19
import {
14
20
appURL ,
15
21
startServer as startRealmServer ,
16
22
type IsolatedRealmServer ,
17
23
} from '../helpers/isolated-realm-server' ;
24
+ import {
25
+ APP_BOXEL_REALMS_EVENT_TYPE ,
26
+ LEGACY_APP_BOXEL_REALMS_EVENT_TYPE ,
27
+ } from '../helpers/matrix-constants' ;
18
28
19
29
test . describe ( 'Realm URLs in Matrix account data' , ( ) => {
20
30
let synapse : SynapseInstance ;
@@ -90,4 +100,38 @@ test.describe('Realm URLs in Matrix account data', () => {
90
100
) ,
91
101
) . toHaveText ( 'private' ) ;
92
102
} ) ;
103
+
104
+ test ( 'deprecated account data key is supported by auto-migrating user to new key' , async ( {
105
+ page,
106
+ } ) => {
107
+ await login ( page , 'user1' , 'pass' , { url : appURL } ) ;
108
+ await updateAccountData (
109
+ '@user1:localhost' ,
110
+ user . accessToken ,
111
+ LEGACY_APP_BOXEL_REALMS_EVENT_TYPE ,
112
+ JSON . stringify ( {
113
+ realms : [ 'http://localhost:4205/user1/personal/' ] ,
114
+ } ) ,
115
+ ) ;
116
+ await logout ( page ) ;
117
+ await login ( page , 'user1' , 'pass' , { url : appURL } ) ;
118
+
119
+ await page . locator ( '[data-test-workspace-chooser-toggle]' ) . click ( ) ;
120
+
121
+ await page
122
+ . locator ( '[data-test-workspace-chooser]' )
123
+ . waitFor ( { state : 'visible' } ) ;
124
+
125
+ expect (
126
+ page . locator ( '[data-test-workspace-list] [data-test-workspace]' ) ,
127
+ ) . toHaveCount ( 1 ) ;
128
+ let realms = await getAccountData < { realms : string [ ] } | undefined > (
129
+ '@user1:localhost' ,
130
+ user . accessToken ,
131
+ APP_BOXEL_REALMS_EVENT_TYPE ,
132
+ ) ;
133
+ expect ( realms ) . toEqual ( {
134
+ realms : [ 'http://localhost:4205/user1/personal/' ] ,
135
+ } ) ;
136
+ } ) ;
93
137
} ) ;
0 commit comments