@@ -92,6 +92,7 @@ export function mockTransport() {
92
92
/** @type {Map<SubscriptionNames, any[]> } */
93
93
const rmfSubscriptions = new Map ( ) ;
94
94
const freemiumPIRBannerSubscriptions = new Map ( ) ;
95
+ const nextStepsSubscriptions = new Map ( ) ;
95
96
96
97
function clearRmf ( ) {
97
98
const listeners = rmfSubscriptions . get ( 'rmf_onDataUpdate' ) || [ ] ;
@@ -102,6 +103,16 @@ export function mockTransport() {
102
103
}
103
104
}
104
105
106
+ function clearNextStepsCard ( cardId , data ) {
107
+ const listeners = nextStepsSubscriptions . get ( 'nextSteps_onDataUpdate' ) || [ ] ;
108
+ const newContent = data . content . filter ( ( card ) => card . id !== cardId ) ;
109
+ const message = { content : newContent } ;
110
+ for ( const listener of listeners ) {
111
+ listener ( message ) ;
112
+ write ( 'nextSteps_data' , message ) ;
113
+ }
114
+ }
115
+
105
116
const transports = {
106
117
customizer : customizerMockTransport ( ) ,
107
118
activity : activityMockTransport ( ) ,
@@ -137,6 +148,7 @@ export function mockTransport() {
137
148
}
138
149
case 'rmf_dismiss' : {
139
150
console . log ( 'ignoring rmf_dismiss' , msg . params ) ;
151
+ clearRmf ( ) ;
140
152
return ;
141
153
}
142
154
case 'freemiumPIRBanner_action' : {
@@ -177,6 +189,15 @@ export function mockTransport() {
177
189
console . log ( 'mock: ignoring favorites_add' ) ;
178
190
return ;
179
191
}
192
+ case 'nextSteps_dismiss' : {
193
+ if ( msg . params . id ) {
194
+ const data = read ( 'nextSteps_data' ) ;
195
+ clearNextStepsCard ( msg . params . id , data ) ;
196
+ return ;
197
+ }
198
+ console . log ( 'ignoring nextSteps_dismiss' ) ;
199
+ return ;
200
+ }
180
201
default : {
181
202
console . warn ( 'unhandled notification' , msg ) ;
182
203
}
@@ -231,6 +252,19 @@ export function mockTransport() {
231
252
}
232
253
return ( ) => { } ;
233
254
}
255
+ case 'nextSteps_onDataUpdate' : {
256
+ const prev = nextStepsSubscriptions . get ( 'nextSteps_onDataUpdate' ) || [ ] ;
257
+ const next = [ ...prev ] ;
258
+ next . push ( cb ) ;
259
+ nextStepsSubscriptions . set ( 'nextSteps_onDataUpdate' , next ) ;
260
+ const params = url . searchParams . get ( 'next-steps' ) ;
261
+ if ( params && params in nextSteps ) {
262
+ const data = read ( 'nextSteps_data' ) ;
263
+ cb ( data ) ;
264
+ }
265
+
266
+ return ( ) => { } ;
267
+ }
234
268
case 'rmf_onDataUpdate' : {
235
269
// store the callback for later (eg: dismiss)
236
270
const prev = rmfSubscriptions . get ( 'rmf_onDataUpdate' ) || [ ] ;
@@ -387,6 +421,7 @@ export function mockTransport() {
387
421
return { id : /** @type {any } */ ( id ) } ;
388
422
} ) ,
389
423
} ;
424
+ write ( 'nextSteps_data' , data ) ;
390
425
}
391
426
return Promise . resolve ( data ) ;
392
427
}
0 commit comments