@@ -16,6 +16,10 @@ describe('AdminSubscriptionForm', () => {
16
16
before ( ( ) => ( window . ResizeObserver = undefined ) ) ;
17
17
after ( ( ) => ( window . ResizeObserver = OriginalResizeObserver ) ) ;
18
18
19
+ it ( 'imports and defines foxy-internal-post-action-control' , ( ) => {
20
+ expect ( customElements . get ( 'foxy-internal-post-action-control' ) ) . to . exist ;
21
+ } ) ;
22
+
19
23
it ( 'imports and defines foxy-internal-async-list-control' , ( ) => {
20
24
expect ( customElements . get ( 'foxy-internal-async-list-control' ) ) . to . exist ;
21
25
} ) ;
@@ -238,6 +242,35 @@ describe('AdminSubscriptionForm', () => {
238
242
expect ( control ?. localName ) . to . equal ( 'foxy-internal-summary-control' ) ;
239
243
} ) ;
240
244
245
+ it ( 'renders post action control for charging past due amount when appropriate' , async ( ) => {
246
+ const router = createRouter ( ) ;
247
+ const form = await fixture < Form > ( html `
248
+ < foxy-admin-subscription-form
249
+ href ="https://demo.api/hapi/subscriptions/0?zoom=transaction_template "
250
+ @fetch =${ ( evt : FetchEvent ) => router . handleEvent ( evt ) }
251
+ >
252
+ </ foxy-admin-subscription-form >
253
+ ` ) ;
254
+
255
+ const testData = await getTestData < Data > ( './hapi/subscriptions/0?zoom=transaction_template' ) ;
256
+ // @ts -expect-error - SDK doesn't know yet about the `fx:charge_past_due` link.
257
+ testData . _links [ 'fx:charge_past_due' ] = { href : 'https://demo.api/virtual/empty' } ;
258
+ testData . past_due_amount = 10 ;
259
+ testData . _embedded [ 'fx:transaction_template' ] . currency_code = 'AUD' ;
260
+ form . data = testData ;
261
+
262
+ await waitUntil ( ( ) => ! ! form . data , '' , { timeout : 5000 } ) ;
263
+ await form . requestUpdate ( ) ;
264
+ const summary = form . renderRoot . querySelector ( '[infer="overdue"]' ) ;
265
+ const control = summary ?. querySelector ( '[infer="charge-past-due"]' ) ;
266
+
267
+ expect ( control ?. localName ) . to . equal ( 'foxy-internal-post-action-control' ) ;
268
+ expect ( control ) . to . have . attribute ( 'theme' , 'tertiary-inline' ) ;
269
+ expect ( control ) . to . have . attribute ( 'message-options' , JSON . stringify ( { amount : '10 AUD' } ) ) ;
270
+ expect ( control ) . to . have . attribute ( 'href' , 'https://demo.api/virtual/empty' ) ;
271
+ expect ( control ) . to . have . attribute ( 'href' , 'https://demo.api/virtual/empty' ) ;
272
+ } ) ;
273
+
241
274
it ( 'renders number control for past due amount inside of the overdue summary control' , async ( ) => {
242
275
const router = createRouter ( ) ;
243
276
const form = await fixture < Form > ( html `
0 commit comments