@@ -6,11 +6,13 @@ import { isBootStrapingPhase, skipIfNotHardFork } from "@helpers/cardano";
66import ProposalDiscussionDetailsPage from "@pages/proposalDiscussionDetailsPage" ;
77import ProposalDiscussionPage from "@pages/proposalDiscussionPage" ;
88import { expect } from "@playwright/test" ;
9+ import { ProposalType } from "@types" ;
910
1011const mockProposal = require ( "../../lib/_mock/proposal.json" ) ;
1112const mockPoll = require ( "../../lib/_mock/proposalPoll.json" ) ;
1213const mockComments = require ( "../../lib/_mock/proposalComments.json" ) ;
1314const mockInfoProposedGA = require ( "../../lib/_mock/infoProposedGAs.json" ) ;
15+ const mockTreasuryProposal = require ( "../../lib/_mock/treasuryProposedGAs.json" ) ;
1416
1517const PROPOSAL_TYPE_FILTERS = [ "Info" , "Treasury" ] ;
1618const BOOTSTRAP_PROPOSAL_TYPE_FILTERS = [ "Info" ] ;
@@ -92,27 +94,51 @@ test("8C. Should search the list of proposed governance actions.", async ({
9294 }
9395} ) ;
9496
95- test ( "8D.Should show the view-all categorized proposed governance actions." , async ( {
96- page ,
97+ test ( "8D. Should show the view-all categorized proposed governance actions." , async ( {
98+ browser ,
9799} ) => {
98- await page . route ( "**/api/proposals?**" , async ( route ) => {
99- return route . fulfill ( {
100- body : JSON . stringify ( mockInfoProposedGA ) ,
101- } ) ;
102- } ) ;
103-
104- const proposalDiscussionPage = new ProposalDiscussionPage ( page ) ;
105- await proposalDiscussionPage . goto ( ) ;
106-
107- await proposalDiscussionPage . showAllBtn . click ( ) ;
108-
109- const proposalCards = await proposalDiscussionPage . getAllProposals ( ) ;
110-
111- for ( const proposalCard of proposalCards ) {
112- await expect (
113- proposalCard . getByTestId ( "governance-action-type" )
114- ) . toBeVisible ( ) ;
115- }
100+ await Promise . all (
101+ Object . entries ( {
102+ [ ProposalType . info ] : mockInfoProposedGA ,
103+ [ ProposalType . treasury ] : mockTreasuryProposal ,
104+ } ) . map ( async ( [ proposalType , mockData ] ) => {
105+ const govActionTypeId = proposalType === ProposalType . info ? 1 : 2 ;
106+ const requestUrl = `**/api/proposals?filters[$and][0][gov_action_type_id]=${ govActionTypeId } &**` ;
107+ let requestHandled = false ;
108+
109+ const context = await browser . newContext ( ) ;
110+ const page = await context . newPage ( ) ;
111+
112+ await page . route ( requestUrl , async ( route ) => {
113+ if ( ! requestHandled ) {
114+ requestHandled = true ;
115+ return route . fulfill ( {
116+ body : JSON . stringify ( mockData ) ,
117+ } ) ;
118+ }
119+ return route . continue ( ) ;
120+ } ) ;
121+
122+ const proposalDiscussionPage = new ProposalDiscussionPage ( page ) ;
123+ await proposalDiscussionPage . goto ( ) ;
124+
125+ const showAllButton = page . getByTestId ( "show-all-button" ) ;
126+
127+ if ( proposalType === ProposalType . treasury ) {
128+ await showAllButton . nth ( 1 ) . click ( ) ;
129+ } else {
130+ await showAllButton . first ( ) . click ( ) ;
131+ }
132+
133+ const proposalCards = await proposalDiscussionPage . getAllProposals ( ) ;
134+
135+ for ( const proposalCard of proposalCards ) {
136+ await expect (
137+ proposalCard . getByTestId ( "governance-action-type" )
138+ ) . toHaveText ( proposalType , { timeout : 20_000 } ) ;
139+ }
140+ } )
141+ ) ;
116142} ) ;
117143
118144test ( "8H. Should disable proposal interaction on a disconnected state." , async ( {
0 commit comments