11const { expect } = require ( '@wdio/globals' ) ;
22
3- const agreementsPage = require ( '../pageobjects/agreements.page' ) ;
43const agreementDetailsPage = require ( '../pageobjects/agreement-details.page' ) ;
4+ const agreementsPage = require ( '../pageobjects/agreements.page' ) ;
55const morePage = require ( '../pageobjects/more.page' ) ;
66const { ensureLoggedIn } = require ( '../pageobjects/utils/auth.helper' ) ;
7+ const { TIMEOUT , PAUSE , REGEX } = require ( '../pageobjects/utils/constants' ) ;
78const navigation = require ( '../pageobjects/utils/navigation.page' ) ;
89const { apiClient } = require ( '../utils/api-client' ) ;
9- const subscriptionDetailsPage = require ( '../pageobjects/subscription-details.page' ) ;
1010
1111// E2E tests for Agreement Details Page, modeled after user-details.e2e.js
1212
@@ -17,12 +17,12 @@ describe('Agreement Details Page', () => {
1717 let apiAgreementData = null ;
1818
1919 before ( async function ( ) {
20- this . timeout ( 150000 ) ;
20+ this . timeout ( TIMEOUT . TEST_SETUP_LONG ) ;
2121 await ensureLoggedIn ( ) ;
2222 await navigation . ensureHomePage ( { resetFilters : false } ) ;
2323 // Navigate to Agreements page via More menu
2424 await agreementsPage . footer . moreTab . click ( ) ;
25- await browser . pause ( 500 ) ;
25+ await browser . pause ( PAUSE . NAVIGATION ) ;
2626 await morePage . agreementsMenuItem . click ( ) ;
2727 await agreementsPage . waitForScreenReady ( ) ;
2828
@@ -37,15 +37,17 @@ describe('Agreement Details Page', () => {
3737 if ( apiAvailable && testAgreementId ) {
3838 try {
3939 apiAgreementData = await apiClient . getAgreementById ( testAgreementId ) ;
40- console . log ( JSON . stringify ( apiAgreementData , null , 2 ) ) ;
40+ console . info ( JSON . stringify ( apiAgreementData , null , 2 ) ) ;
4141 console . info ( `📊 Pre-fetched API data for agreement: ${ testAgreementId } ` ) ;
4242 } catch ( error ) {
4343 console . warn ( `⚠️ Failed to fetch API data: ${ error . message } ` ) ;
4444 }
4545 }
4646 }
4747
48- console . info ( `📊 Agreement Details test setup: hasAgreements=${ hasAgreementsData } , apiAvailable=${ apiAvailable } , testAgreementId=${ testAgreementId } ` ) ;
48+ console . info (
49+ `📊 Agreement Details test setup: hasAgreements=${ hasAgreementsData } , apiAvailable=${ apiAvailable } , testAgreementId=${ testAgreementId } ` ,
50+ ) ;
4951
5052 // Navigate to agreement details page once at the start
5153 if ( hasAgreementsData && testAgreementId ) {
@@ -74,7 +76,7 @@ describe('Agreement Details Page', () => {
7476 }
7577 await expect ( agreementDetailsPage . agreementIdText ) . toBeDisplayed ( ) ;
7678 const agreementId = await agreementDetailsPage . getItemId ( ) ;
77- expect ( agreementId ) . toMatch ( / ^ A G R - ( \d { 4 } - ) + \d { 4 } $ / ) ;
79+ expect ( agreementId ) . toMatch ( REGEX . AGREEMENT_ID_FLEX ) ;
7880 } ) ;
7981
8082 it ( 'should display the status field' , async function ( ) {
@@ -127,7 +129,10 @@ describe('Agreement Details Page', () => {
127129 this . skip ( ) ;
128130 return ;
129131 }
130- const billingCurrency = await agreementDetailsPage . getSimpleFieldValue ( 'Billing currency' , true ) ;
132+ const billingCurrency = await agreementDetailsPage . getSimpleFieldValue (
133+ 'Billing currency' ,
134+ true ,
135+ ) ;
131136 expect ( billingCurrency ) . toBeTruthy ( ) ;
132137 } ) ;
133138 } ) ;
@@ -204,7 +209,10 @@ describe('Agreement Details Page', () => {
204209 this . skip ( ) ;
205210 return ;
206211 }
207- const uiBillingCurrency = await agreementDetailsPage . getSimpleFieldValue ( 'Billing currency' , true ) ;
212+ const uiBillingCurrency = await agreementDetailsPage . getSimpleFieldValue (
213+ 'Billing currency' ,
214+ true ,
215+ ) ;
208216 const apiBillingCurrency = apiAgreementData . price ?. billingCurrency ;
209217 console . info ( `[Billing Currency] UI: ${ uiBillingCurrency } | API: ${ apiBillingCurrency } ` ) ;
210218 expect ( uiBillingCurrency ) . toBe ( apiBillingCurrency ) ;
@@ -221,11 +229,21 @@ describe('Agreement Details Page', () => {
221229 console . info ( '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━' ) ;
222230 console . info ( `Agreement ID: UI="${ uiDetails . agreementId } " | API="${ apiAgreementData . id } "` ) ;
223231 console . info ( `Status: UI="${ uiDetails . status } " | API="${ apiAgreementData . status } "` ) ;
224- console . info ( `Vendor: UI="${ uiDetails . vendor } " | API="${ apiAgreementData . vendor ?. name } "` ) ;
225- console . info ( `Product: UI="${ uiDetails . product } " | API="${ apiAgreementData . product ?. name } "` ) ;
226- console . info ( `Client: UI="${ uiDetails . client } " | API="${ apiAgreementData . client ?. name } "` ) ;
227- console . info ( `BaseCurrency: UI="${ uiDetails . baseCurrency } " | API="${ apiAgreementData . price ?. currency } "` ) ;
228- console . info ( `BillingCurr: UI="${ uiDetails . billingCurrency } " | API="${ apiAgreementData . price ?. billingCurrency } "` ) ;
232+ console . info (
233+ `Vendor: UI="${ uiDetails . vendor } " | API="${ apiAgreementData . vendor ?. name } "` ,
234+ ) ;
235+ console . info (
236+ `Product: UI="${ uiDetails . product } " | API="${ apiAgreementData . product ?. name } "` ,
237+ ) ;
238+ console . info (
239+ `Client: UI="${ uiDetails . client } " | API="${ apiAgreementData . client ?. name } "` ,
240+ ) ;
241+ console . info (
242+ `BaseCurrency: UI="${ uiDetails . baseCurrency } " | API="${ apiAgreementData . price ?. currency } "` ,
243+ ) ;
244+ console . info (
245+ `BillingCurr: UI="${ uiDetails . billingCurrency } " | API="${ apiAgreementData . price ?. billingCurrency } "` ,
246+ ) ;
229247 console . info ( '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━' ) ;
230248 expect ( uiDetails . agreementId ) . toBe ( apiAgreementData . id ) ;
231249 } ) ;
0 commit comments