11import { BasePage } from '@/helpers/pages' ;
22import { Locator , Page } from '@playwright/test' ;
33
4+ type PaidSignupCadence = 'monthly' | 'yearly' ;
5+
46export class PortalSection extends BasePage {
57 readonly section : Locator ;
68 readonly customizeButton : Locator ;
79 readonly portalModal : Locator ;
810 readonly linksTab : Locator ;
11+ readonly linksTierSelectControl : Locator ;
912 readonly freeTierToggleLabel : Locator ;
1013
1114 constructor ( page : Page ) {
@@ -15,6 +18,7 @@ export class PortalSection extends BasePage {
1518 this . customizeButton = this . section . getByRole ( 'button' , { name : 'Customize' } ) ;
1619 this . portalModal = page . getByTestId ( 'portal-modal' ) ;
1720 this . linksTab = this . portalModal . getByRole ( 'tab' , { name : 'Links' } ) ;
21+ this . linksTierSelectControl = this . portalModal . locator ( 'span:has-text("Tier:") + div' ) . first ( ) ;
1822 this . freeTierToggleLabel = this . portalModal . locator ( 'label' ) . filter ( { hasText : 'Free' } ) . first ( ) ;
1923 }
2024
@@ -31,6 +35,38 @@ export class PortalSection extends BasePage {
3135 await this . linksTab . click ( ) ;
3236 }
3337
38+ async selectLinksTier ( name : string ) : Promise < void > {
39+ await this . openLinksTab ( ) ;
40+ await this . linksTierSelectControl . scrollIntoViewIfNeeded ( ) ;
41+ await this . linksTierSelectControl . click ( ) ;
42+ await this . page . getByRole ( 'option' , { name, exact : true } ) . click ( ) ;
43+ }
44+
45+ async getPaidSignupLinkForTier ( name : string , tierId : string , cadence : PaidSignupCadence ) : Promise < string > {
46+ await this . selectLinksTier ( name ) ;
47+
48+ const label = cadence === 'monthly' ? 'Signup / Monthly' : 'Signup / Yearly' ;
49+ const linkInput = this . portalModal . getByLabel ( label ) ;
50+ await linkInput . waitFor ( { state : 'visible' } ) ;
51+ const inputId = await linkInput . getAttribute ( 'id' ) ;
52+
53+ if ( ! inputId ) {
54+ throw new Error ( `Portal ${ cadence } signup link input was not found` ) ;
55+ }
56+
57+ await this . page . waitForFunction ( ( { expectedTierId, targetInputId} : { expectedTierId : string ; targetInputId : string } ) => {
58+ const element = document . getElementById ( targetInputId ) ;
59+ return element instanceof HTMLInputElement && element . value . includes ( expectedTierId ) ;
60+ } , {
61+ expectedTierId : tierId ,
62+ targetInputId : inputId
63+ } , {
64+ timeout : 5000
65+ } ) ;
66+
67+ return await linkInput . inputValue ( ) ;
68+ }
69+
3470 async getLinkValue ( label : string ) : Promise < string > {
3571 await this . openLinksTab ( ) ;
3672 const linkInput = this . portalModal . getByLabel ( label ) ;
0 commit comments