@@ -92,6 +92,7 @@ export function mockTransport() {
9292 /** @type {Map<SubscriptionNames, any[]> } */
9393 const rmfSubscriptions = new Map ( ) ;
9494 const freemiumPIRBannerSubscriptions = new Map ( ) ;
95+ const nextStepsSubscriptions = new Map ( ) ;
9596
9697 function clearRmf ( ) {
9798 const listeners = rmfSubscriptions . get ( 'rmf_onDataUpdate' ) || [ ] ;
@@ -102,6 +103,16 @@ export function mockTransport() {
102103 }
103104 }
104105
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+
105116 const transports = {
106117 customizer : customizerMockTransport ( ) ,
107118 activity : activityMockTransport ( ) ,
@@ -137,6 +148,7 @@ export function mockTransport() {
137148 }
138149 case 'rmf_dismiss' : {
139150 console . log ( 'ignoring rmf_dismiss' , msg . params ) ;
151+ clearRmf ( ) ;
140152 return ;
141153 }
142154 case 'freemiumPIRBanner_action' : {
@@ -177,6 +189,15 @@ export function mockTransport() {
177189 console . log ( 'mock: ignoring favorites_add' ) ;
178190 return ;
179191 }
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+ }
180201 default : {
181202 console . warn ( 'unhandled notification' , msg ) ;
182203 }
@@ -231,6 +252,19 @@ export function mockTransport() {
231252 }
232253 return ( ) => { } ;
233254 }
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+ }
234268 case 'rmf_onDataUpdate' : {
235269 // store the callback for later (eg: dismiss)
236270 const prev = rmfSubscriptions . get ( 'rmf_onDataUpdate' ) || [ ] ;
@@ -387,6 +421,7 @@ export function mockTransport() {
387421 return { id : /** @type {any } */ ( id ) } ;
388422 } ) ,
389423 } ;
424+ write ( 'nextSteps_data' , data ) ;
390425 }
391426 return Promise . resolve ( data ) ;
392427 }
0 commit comments