@@ -4,7 +4,7 @@ import { faker } from "@faker-js/faker";
44import { isBootStrapingPhase } from "@helpers/cardano" ;
55import { ShelleyWallet } from "@helpers/crypto" ;
66import { expectWithInfo } from "@helpers/exceptionHandler" ;
7- import { downloadMetadata } from "@helpers/metadata" ;
7+ import { calculateHash , downloadMetadata } from "@helpers/metadata" ;
88import { extractProposalIdFromUrl } from "@helpers/string" ;
99import { invalid } from "@mock/index" ;
1010import { Download , Locator , Page , expect } from "@playwright/test" ;
@@ -23,6 +23,8 @@ const formErrors = {
2323 rationale : "rationale-helper-error" ,
2424 receivingAddress : "receiving-address-0-text-error" ,
2525 amount : "amount-0-text-error" ,
26+ constitutionalUrl : "prop=constitution-url-text-error" , // BUG wrong test id
27+ guardrailsScriptUrl : "prop-guardrails-script-url-input-error" ,
2628 link : "link-0-url-input-error" ,
2729} ;
2830
@@ -47,8 +49,11 @@ export default class ProposalSubmissionPage {
4749 readonly addWithdrawalAddressBtn = this . page . getByTestId (
4850 "add-withdrawal-link-button"
4951 ) ;
50- readonly infoBtn = this . page . getByTestId ( "info-button" ) ;
51- readonly treasuryBtn = this . page . getByTestId ( "treasury-button" ) ;
52+ readonly infoBtn = this . page . getByTestId ( "info action-button" ) ;
53+ readonly treasuryBtn = this . page . getByTestId ( "treasury requests-button" ) ;
54+ readonly updateTheConstitutionBtn = this . page . getByTestId (
55+ "updates to the constitution-button"
56+ ) ;
5257 readonly editSubmissionButton = this . page . getByTestId (
5358 "edit-submission-button"
5459 ) ;
@@ -61,6 +66,9 @@ export default class ProposalSubmissionPage {
6166 readonly createNewProposalBtn = this . page . getByTestId (
6267 "create-new-proposal-button"
6368 ) ;
69+ readonly guardrailsScriptCheckbox = this . page . getByLabel (
70+ "Do you want to provide new"
71+ ) ; // BUG missing test id
6472
6573 // input fields
6674 readonly titleInput = this . page . getByTestId ( "title-input" ) ;
@@ -72,6 +80,15 @@ export default class ProposalSubmissionPage {
7280 "receiving-address-0-text-input"
7381 ) ;
7482 readonly amountInput = this . page . getByTestId ( "amount-0-text-input" ) ;
83+ readonly constitutionUrlInput = this . page . getByTestId (
84+ "prop_constitution_url"
85+ ) ;
86+ readonly guardrailsScriptUrlInput = this . page . getByTestId (
87+ "prop-guardrails-script-url-input"
88+ ) ;
89+ readonly guardrailsScriptHashInput = this . page . getByTestId (
90+ "prop-guardrails-script-hash-input"
91+ ) ;
7592 readonly closeDraftSuccessModalBtn = this . page . getByTestId ( "close-button" ) ;
7693 readonly linkTextInput = this . page . getByTestId ( "link-0-text-input" ) ;
7794 readonly linkUrlInput = this . page . getByTestId ( "link-0-url-input" ) ;
@@ -88,6 +105,15 @@ export default class ProposalSubmissionPage {
88105 "receiving-address-0-content"
89106 ) ;
90107 readonly amountContent = this . page . getByTestId ( "amount-0-content" ) ;
108+ readonly constitutionUrlContent = this . page . getByTestId (
109+ "new-constitution-url-content"
110+ ) ;
111+ readonly guardrailsScriptUrlContent = this . page . getByTestId (
112+ "guardrails-script-url-content"
113+ ) ;
114+ readonly guardrailsScriptHashContent = this . page . getByTestId (
115+ "guardrails-script-hash-content"
116+ ) ;
91117 readonly linkTextContent = this . page . getByTestId ( "link-0-text-content" ) ;
92118 readonly linkUrlContent = this . page . getByTestId ( "link-0-url-content" ) ;
93119
@@ -128,6 +154,10 @@ export default class ProposalSubmissionPage {
128154 await this . fillTreasuryFields ( governanceProposal ) ;
129155 }
130156
157+ if ( governanceProposal . gov_action_type_id === 2 ) {
158+ await this . fillUpdateTheConstitutionFields ( governanceProposal ) ;
159+ }
160+
131161 if ( governanceProposal . proposal_links != null ) {
132162 await this . fillProposalLinks ( governanceProposal . proposal_links ) ;
133163 }
@@ -138,9 +168,13 @@ export default class ProposalSubmissionPage {
138168
139169 if ( governanceProposal . gov_action_type_id === 0 ) {
140170 await this . infoBtn . click ( ) ;
141- } else {
171+ } else if ( governanceProposal . gov_action_type_id === 1 ) {
142172 await this . treasuryBtn . click ( ) ;
173+ } else {
174+ await this . updateTheConstitutionBtn . click ( ) ;
175+ await this . guardrailsScriptCheckbox . click ( ) ;
143176 }
177+
144178 await this . fillupFormWithTypeSelected ( governanceProposal ) ;
145179 }
146180
@@ -158,6 +192,21 @@ export default class ProposalSubmissionPage {
158192 await this . amountInput . fill ( governanceProposal . prop_amount ) ;
159193 }
160194
195+ async fillUpdateTheConstitutionFields (
196+ governanceProposal : ProposalCreateRequest
197+ ) {
198+ await this . constitutionUrlInput . fill (
199+ governanceProposal . prop_constitution_url
200+ ) ;
201+
202+ await this . guardrailsScriptUrlInput . fill (
203+ governanceProposal . prop_guardrails_script_url
204+ ) ;
205+ await this . guardrailsScriptHashInput . fill (
206+ governanceProposal . prop_guardrails_script_hash
207+ ) ;
208+ }
209+
161210 async fillProposalLinks ( proposal_links : Array < ProposalLink > ) {
162211 for ( let i = 0 ; i < proposal_links . length ; i ++ ) {
163212 if ( i > 0 ) {
@@ -232,6 +281,16 @@ export default class ProposalSubmissionPage {
232281 }
233282 }
234283
284+ if ( governanceProposal . gov_action_type_id === 2 ) {
285+ await expect (
286+ this . page . getByTestId ( formErrors . constitutionalUrl )
287+ ) . toBeHidden ( ) ;
288+
289+ await expect (
290+ this . page . getByTestId ( formErrors . guardrailsScriptUrl )
291+ ) . toBeHidden ( ) ;
292+ }
293+
235294 await expect ( this . page . getByTestId ( formErrors . link ) ) . toBeHidden ( ) ;
236295
237296 await expect ( this . continueBtn ) . toBeEnabled ( ) ;
@@ -286,6 +345,16 @@ export default class ProposalSubmissionPage {
286345 await expect ( this . page . getByTestId ( formErrors . amount ) ) . toBeVisible ( ) ;
287346 }
288347
348+ if ( governanceProposal . gov_action_type_id === 2 ) {
349+ await expect (
350+ this . page . getByTestId ( formErrors . constitutionalUrl )
351+ ) . toBeVisible ( ) ;
352+
353+ await expect (
354+ this . page . getByTestId ( formErrors . guardrailsScriptUrl )
355+ ) . toBeVisible ( ) ;
356+ }
357+
289358 await expect ( this . continueBtn ) . toBeDisabled ( ) ;
290359 }
291360
@@ -306,7 +375,7 @@ export default class ProposalSubmissionPage {
306375 prop_link_text : faker . internet . domainWord ( ) ,
307376 } ,
308377 ] ,
309- gov_action_type_id : proposalType === ProposalType . info ? 0 : 1 ,
378+ gov_action_type_id : Object . values ( ProposalType ) . indexOf ( proposalType ) ,
310379 is_draft : ! ! is_draft ,
311380 } ;
312381
@@ -316,6 +385,13 @@ export default class ProposalSubmissionPage {
316385 . int ( { min : 100 , max : 1000 } )
317386 . toString ( ) ) ;
318387 }
388+ if ( proposalType === ProposalType . updatesToTheConstitution ) {
389+ proposal . prop_constitution_url = faker . internet . url ( ) ;
390+ proposal . prop_guardrails_script_url = faker . internet . url ( ) ;
391+ proposal . prop_guardrails_script_hash = calculateHash (
392+ faker . lorem . paragraph ( )
393+ ) ;
394+ }
319395 return proposal ;
320396 }
321397
@@ -332,20 +408,28 @@ export default class ProposalSubmissionPage {
332408 prop_link_text : invalid . name ( ) ,
333409 } ,
334410 ] ,
335- gov_action_type_id : proposalType === ProposalType . info ? 0 : 1 ,
411+ gov_action_type_id : Object . values ( ProposalType ) . indexOf ( proposalType ) ,
336412 is_draft : false ,
337413 } ;
338414
339415 if ( proposalType === ProposalType . treasury ) {
340416 ( proposal . prop_receiving_address = faker . location . streetAddress ( ) ) ,
341417 ( proposal . prop_amount = invalid . amount ( ) ) ;
342418 }
419+
420+ if ( proposalType === ProposalType . updatesToTheConstitution ) {
421+ proposal . prop_constitution_url = invalid . constitutionUrl ( ) ;
422+ proposal . prop_guardrails_script_url = invalid . url ( ) ;
423+ proposal . prop_guardrails_script_hash = faker . string . alphanumeric ( 64 ) ;
424+ }
343425 return proposal ;
344426 }
345427
346428 async createProposal (
347429 wallet : StaticWallet ,
348- proposalType : ProposalType = ProposalType . treasury
430+ proposalType : ProposalType = Object . values ( ProposalType ) [
431+ Math . floor ( Math . random ( ) * Object . values ( ProposalType ) . length )
432+ ]
349433 ) : Promise < number > {
350434 await this . addLinkBtn . click ( ) ;
351435 const receivingAddr = ShelleyWallet . fromJson ( wallet ) . rewardAddressBech32 (
0 commit comments