From 2f240b3bc62d43678439131d3b3b554b43112978 Mon Sep 17 00:00:00 2001 From: Baja-KS Date: Sat, 7 Sep 2024 23:56:32 +0200 Subject: [PATCH 01/35] add tags to merged pr --- .github/workflows/merge.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index d89b4ee3f..a21f26b48 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -162,3 +162,11 @@ jobs: docker load -i '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar' rm -rf '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar' docker push ${{ steps.image_lowercase.outputs.lowercase }}:${{ env.TAG }} + + - name: Add tag as a PR comment + uses: ubie-oss/comment-to-merged-pr-action@v0.3.3 + id: comment-to-merged-pr + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + message: |- + This PR is in the tag: ${{ env.TAG }} , for ${{ matrix.name }} service From c8af57432384e84edc8120832abea7949345689c Mon Sep 17 00:00:00 2001 From: Baja-KS Date: Sun, 8 Sep 2024 00:13:28 +0200 Subject: [PATCH 02/35] add tags to merged pr --- .github/workflows/merge.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index d89b4ee3f..a21f26b48 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -162,3 +162,11 @@ jobs: docker load -i '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar' rm -rf '/tmp/image-${{ matrix.name }}-${{ env.ENVIRONMENT }}.tar' docker push ${{ steps.image_lowercase.outputs.lowercase }}:${{ env.TAG }} + + - name: Add tag as a PR comment + uses: ubie-oss/comment-to-merged-pr-action@v0.3.3 + id: comment-to-merged-pr + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + message: |- + This PR is in the tag: ${{ env.TAG }} , for ${{ matrix.name }} service From 4050632f8397edaa21697e31cf4aa7d5ba26dfd3 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 10 Sep 2024 19:26:06 +0545 Subject: [PATCH 03/35] feat: add teardown to refund remaining balance to faucet --- .../playwright/lib/constants/environments.ts | 1 + .../playwright/playwright.config.ts | 5 +++ .../playwright/tests/faucet.teardown.ts | 34 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/govtool-frontend/playwright/tests/faucet.teardown.ts diff --git a/tests/govtool-frontend/playwright/lib/constants/environments.ts b/tests/govtool-frontend/playwright/lib/constants/environments.ts index ed801fc0a..d7c021ea8 100644 --- a/tests/govtool-frontend/playwright/lib/constants/environments.ts +++ b/tests/govtool-frontend/playwright/lib/constants/environments.ts @@ -17,6 +17,7 @@ const environments = { process.env.FAUCET_API_URL || "https://faucet.sanchonet.world.dev.cardano.org", apiKey: process.env.FAUCET_API_KEY || "", + address: process.env.FAUCET_ADDRESS || "addr_test1vz0ua2vyk7r4vufmpqh5v44awg8xff26hxlwyrt3uc67maqtql3kl", }, kuber: { apiUrl: process.env.KUBER_API_URL || "https://kuber-govtool.cardanoapi.io", diff --git a/tests/govtool-frontend/playwright/playwright.config.ts b/tests/govtool-frontend/playwright/playwright.config.ts index de0939e99..941cccab5 100644 --- a/tests/govtool-frontend/playwright/playwright.config.ts +++ b/tests/govtool-frontend/playwright/playwright.config.ts @@ -50,6 +50,7 @@ export default defineConfig({ { name: "faucet setup", testMatch: "**/faucet.setup.ts", + teardown: environments.ci && "cleanup faucet" }, { name: "dRep setup", @@ -128,5 +129,9 @@ export default defineConfig({ name: "cleanup delegation", testMatch: "delegation.teardown.ts", }, + { + name: "cleanup faucet", + testMatch: "faucet.teardown.ts", + }, ], }); diff --git a/tests/govtool-frontend/playwright/tests/faucet.teardown.ts b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts new file mode 100644 index 000000000..b32425873 --- /dev/null +++ b/tests/govtool-frontend/playwright/tests/faucet.teardown.ts @@ -0,0 +1,34 @@ +import environments from "@constants/environments"; +import { faucetWallet } from "@constants/staticWallets"; +import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { pollTransaction } from "@helpers/transaction"; +import { test as cleanup, expect } from "@playwright/test"; +import kuberService from "@services/kuberService"; + +cleanup.describe.configure({ timeout: environments.txTimeOut }); +cleanup.beforeEach(async () => { + await setAllureEpic("Setup"); + await setAllureStory("Cleanup"); +}); + +cleanup("Refund faucet", async () => { + try { + const faucetRemainingBalance = await kuberService.getBalance( + faucetWallet.address + ); + + const transferBalance = Math.floor(faucetRemainingBalance) - 3; + const { txId, lockInfo } = await kuberService.transferADA( + [environments.faucet.address], + transferBalance + ); + await pollTransaction(txId, lockInfo); + } catch (err) { + console.log(err); + if (err.status === 400) { + expect(true, "Failed to trasfer Ada").toBeTruthy(); + } else { + throw Error(err); + } + } +}); From b09b954177f5b567e51968fc40b22069800cbf75 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 10 Sep 2024 19:26:21 +0545 Subject: [PATCH 04/35] chore: add multiple dRepDeRegistration on kuber service --- .../playwright/lib/services/kuberService.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/govtool-frontend/playwright/lib/services/kuberService.ts b/tests/govtool-frontend/playwright/lib/services/kuberService.ts index 6ddc81a43..d88164466 100644 --- a/tests/govtool-frontend/playwright/lib/services/kuberService.ts +++ b/tests/govtool-frontend/playwright/lib/services/kuberService.ts @@ -248,6 +248,24 @@ const kuberService = { return kuber.signAndSubmitTx(req); }, + multipleDRepDeRegistration: (wallets: StaticWallet[]) => { + const kuber = new Kuber(faucetWallet.address, faucetWallet.payment.private); + const req = { + certificates: wallets.map((wallet) => + Kuber.generateCert("deregisterdrep", wallet.stake.pkh) + ), + selections: wallets.map((wallet) => { + return { + type: "PaymentSigningKeyShelley_ed25519", + description: "Stake Signing Key", + cborHex: `5820${wallet.stake.private}`, + }; + }), + inputs: faucetWallet.address, + }; + return kuber.signAndSubmitTx(req); + }, + stakeDelegation: ( addr: string, signingKey: string, From b50f5242dfc57c53d176097d306e7c166bcc2090 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 10 Sep 2024 19:27:06 +0545 Subject: [PATCH 05/35] feat: add dRep deRegestration teardown --- .../playwright/lib/walletManager.ts | 15 +++++++- .../playwright/playwright.config.ts | 5 +++ .../dRepRegistration.dRep.spec.ts | 2 + .../playwright/tests/dRep.setup.ts | 2 + .../playwright/tests/dRep.teardown.ts | 37 +++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/govtool-frontend/playwright/tests/dRep.teardown.ts diff --git a/tests/govtool-frontend/playwright/lib/walletManager.ts b/tests/govtool-frontend/playwright/lib/walletManager.ts index cd9183269..94020e063 100644 --- a/tests/govtool-frontend/playwright/lib/walletManager.ts +++ b/tests/govtool-frontend/playwright/lib/walletManager.ts @@ -5,7 +5,12 @@ const path = require("path"); const baseFilePath = path.resolve(__dirname, "./_mock"); -export type Purpose = "registerDRep" | "registeredDRep" | "proposalSubmission"; +export type Purpose = + | "registerDRep" + | "registeredDRep" + | "proposalSubmission" + | "registerDRepCopy" + | "registeredDRepCopy"; /** * WalletManager class is responsible for managing a list of temporary wallets. @@ -54,6 +59,14 @@ class WalletManager { return JSON.parse(data); } + async removeCopyWallet(walletToRemove: StaticWallet, purpose: Purpose) { + const currentWallets = await this.readWallets(purpose); + const updatedWallets = currentWallets.filter( + (wallet) => wallet.address !== walletToRemove.address + ); + await this.writeWallets(updatedWallets, purpose); + } + async popWallet(purpose: Purpose): Promise { const popCb = async () => { const wallets = await this.readWallets(purpose); diff --git a/tests/govtool-frontend/playwright/playwright.config.ts b/tests/govtool-frontend/playwright/playwright.config.ts index 941cccab5..5e5e0be4e 100644 --- a/tests/govtool-frontend/playwright/playwright.config.ts +++ b/tests/govtool-frontend/playwright/playwright.config.ts @@ -92,6 +92,7 @@ export default defineConfig({ use: { ...devices["Desktop Chrome"] }, testMatch: "**/*.dRep.spec.ts", dependencies: environments.ci ? ["auth setup", "dRep setup","wallet bootstrap"] : [], + teardown: environments.ci && "cleanup dRep" }, { name: "delegation", @@ -129,6 +130,10 @@ export default defineConfig({ name: "cleanup delegation", testMatch: "delegation.teardown.ts", }, + { + name: "cleanup dRep", + testMatch: "dRep.teardown.ts", + }, { name: "cleanup faucet", testMatch: "faucet.teardown.ts", diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts index 619befc5d..56cabc18b 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts @@ -144,6 +144,7 @@ test.describe("Temporary DReps", () => { test.slow(); // Due to queue in pop wallets const wallet = await walletManager.popWallet("registeredDRep"); + await walletManager.removeCopyWallet(wallet, "registeredDRepCopy"); const tempDRepAuth = await createTempDRepAuth(page, wallet); const dRepPage = await createNewPageWithWallet(browser, { @@ -168,6 +169,7 @@ test.describe("Temporary DReps", () => { test.setTimeout(testInfo.timeout + environments.txTimeOut); const wallet = await walletManager.popWallet("registeredDRep"); + await walletManager.removeCopyWallet(wallet, "registeredDRepCopy"); const dRepAuth = await createTempDRepAuth(page, wallet); const dRepPage = await createNewPageWithWallet(browser, { diff --git a/tests/govtool-frontend/playwright/tests/dRep.setup.ts b/tests/govtool-frontend/playwright/tests/dRep.setup.ts index bba1f7dcb..319f00ec7 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.setup.ts @@ -97,4 +97,6 @@ setup("Setup temporary DRep wallets", async () => { // save to file await walletManager.writeWallets(dRepWallets, "registeredDRep"); await walletManager.writeWallets(registerDRepWallets, "registerDRep"); + await walletManager.writeWallets(dRepWallets, "registeredDRepCopy"); + await walletManager.writeWallets(registerDRepWallets, "registerDRepCopy"); }); diff --git a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts new file mode 100644 index 000000000..407b74767 --- /dev/null +++ b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts @@ -0,0 +1,37 @@ +import environments from "@constants/environments"; +import { dRepWallets } from "@constants/staticWallets"; +import { setAllureEpic, setAllureStory } from "@helpers/allure"; +import { pollTransaction } from "@helpers/transaction"; +import { test as cleanup, expect } from "@playwright/test"; +import kuberService from "@services/kuberService"; +import { StaticWallet } from "@types"; + +cleanup.describe.configure({ timeout: environments.txTimeOut }); +cleanup.beforeEach(async () => { + await setAllureEpic("Setup"); + await setAllureStory("Cleanup"); +}); + +const registerDRep: StaticWallet[] = require("../lib/_mock/registerDRepCopyWallets.json"); +const registeredDRep: StaticWallet[] = require("../lib/_mock/registeredDRepCopyWallets.json"); + +cleanup("DRep de-registration", async () => { + const registeredDRepWallets = [ + ...dRepWallets, + ...registerDRep, + ...registeredDRep, + ]; + try { + const { txId, lockInfo } = await kuberService.multipleDRepDeRegistration( + registeredDRepWallets + ); + await pollTransaction(txId, lockInfo); + } catch (err) { + console.log(err); + if (err.status === 400) { + expect(true, "DRep not registered").toBeTruthy(); + } else { + throw Error(err); + } + } +}); From 821f20a0b5969178a4dcb1a23f19576ff0cc4954 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 16 Sep 2024 21:05:07 +0545 Subject: [PATCH 06/35] chore: remove copy register drep wallet used for direct voter --- .../2-delegation/delegationFunctionality.delegation.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts index 4090e3894..ed98314d0 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegationFunctionality.delegation.spec.ts @@ -140,6 +140,7 @@ test.describe("Register DRep state", () => { test.beforeEach(async ({ page, browser }) => { wallet = await walletManager.popWallet("registerDRep"); + await walletManager.removeCopyWallet(wallet, "registerDRepCopy"); const dRepAuth = await createTempDRepAuth(page, wallet); dRepPage = await createNewPageWithWallet(browser, { From 8ab38c015451d53bf10a98476ddb7e4954c39024 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 17 Sep 2024 08:02:28 +0545 Subject: [PATCH 07/35] chore: remove copy registered DRep wallet for dRep retirement --- .../5-proposal-functionality/proposalFunctionality.dRep.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts index 7c7282427..2383fbc61 100644 --- a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts @@ -225,6 +225,7 @@ test.describe("Check voting power", () => { test.setTimeout(testInfo.timeout + environments.txTimeOut); const wallet = await walletManager.popWallet("registeredDRep"); + await walletManager.removeCopyWallet(wallet,"registeredDRepCopy"); const tempDRepAuth = await createTempDRepAuth(page, wallet); From 00a176fb5848d44ccc7618a9611bd9ee0a708e16 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 17 Sep 2024 09:38:42 +0545 Subject: [PATCH 08/35] chore: replace file path with read wallets for registerDRep and registeredDRep copy file --- tests/govtool-frontend/playwright/lib/walletManager.ts | 2 +- tests/govtool-frontend/playwright/tests/dRep.teardown.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/walletManager.ts b/tests/govtool-frontend/playwright/lib/walletManager.ts index 94020e063..f9558e9e3 100644 --- a/tests/govtool-frontend/playwright/lib/walletManager.ts +++ b/tests/govtool-frontend/playwright/lib/walletManager.ts @@ -42,7 +42,7 @@ class WalletManager { ); } - private async readWallets(purpose: Purpose): Promise { + async readWallets(purpose: Purpose): Promise { const data: string = await new Promise((resolve, reject) => fs.readFile( `${baseFilePath}/${purpose}Wallets.json`, diff --git a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts index 407b74767..402d9a48b 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.teardown.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.teardown.ts @@ -5,6 +5,7 @@ import { pollTransaction } from "@helpers/transaction"; import { test as cleanup, expect } from "@playwright/test"; import kuberService from "@services/kuberService"; import { StaticWallet } from "@types"; +import walletManager from "lib/walletManager"; cleanup.describe.configure({ timeout: environments.txTimeOut }); cleanup.beforeEach(async () => { @@ -12,10 +13,12 @@ cleanup.beforeEach(async () => { await setAllureStory("Cleanup"); }); -const registerDRep: StaticWallet[] = require("../lib/_mock/registerDRepCopyWallets.json"); -const registeredDRep: StaticWallet[] = require("../lib/_mock/registeredDRepCopyWallets.json"); - cleanup("DRep de-registration", async () => { + const registerDRep: StaticWallet[] = + await walletManager.readWallets("registerDRepCopy"); + const registeredDRep: StaticWallet[] = + await walletManager.readWallets("registeredDRepCopy"); + const registeredDRepWallets = [ ...dRepWallets, ...registerDRep, From 2039f8e1837e193cded555cb642d7cf90154392e Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Mon, 23 Sep 2024 19:50:01 +0200 Subject: [PATCH 09/35] [#1856] add off chain data error to listDreps response --- govtool/backend/sql/list-dreps.sql | 3 +++ govtool/backend/src/VVA/API.hs | 1 + govtool/backend/src/VVA/API/Types.hs | 1 + govtool/backend/src/VVA/DRep.hs | 3 ++- govtool/backend/src/VVA/Types.hs | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/govtool/backend/sql/list-dreps.sql b/govtool/backend/sql/list-dreps.sql index 917f0641f..2ae88d72b 100644 --- a/govtool/backend/sql/list-dreps.sql +++ b/govtool/backend/sql/list-dreps.sql @@ -30,6 +30,7 @@ SELECT newestRegister.time AS last_register_time, COALESCE(latestDeposit.deposit, 0), non_deregister_voting_anchor.url IS NOT NULL AS has_non_deregister_voting_anchor, + off_chain_vote_fetch_error.fetch_error, off_chain_vote_drep_data.payment_address, off_chain_vote_drep_data.given_name, off_chain_vote_drep_data.objectives, @@ -96,6 +97,7 @@ FROM AND DRepDistr.rn = 1 LEFT JOIN voting_anchor va ON va.id = dr_voting_anchor.voting_anchor_id LEFT JOIN voting_anchor non_deregister_voting_anchor on non_deregister_voting_anchor.id = dr_non_deregister_voting_anchor.voting_anchor_id + LEFT JOIN off_chain_vote_fetch_error ON off_chain_vote_fetch_error.voting_anchor_id = va.id LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = va.id LEFT JOIN off_chain_vote_drep_data on off_chain_vote_drep_data.off_chain_vote_data_id = off_chain_vote_data.id CROSS JOIN DRepActivity @@ -138,6 +140,7 @@ GROUP BY newestRegister.time, latestDeposit.deposit, non_deregister_voting_anchor.url, + off_chain_vote_fetch_error.fetch_error, off_chain_vote_drep_data.payment_address, off_chain_vote_drep_data.given_name, off_chain_vote_drep_data.objectives, diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index 067ac632c..36c6551bc 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -116,6 +116,7 @@ drepRegistrationToDrep Types.DRepRegistration {..} = dRepType = mapDRepType dRepRegistrationType, dRepLatestTxHash = HexText <$> dRepRegistrationLatestTxHash, dRepLatestRegistrationDate = dRepRegistrationLatestRegistrationDate, + dRepMetadataError = dRepRegistrationMetadataError, dRepPaymentAddress = dRepRegistrationPaymentAddress, dRepGivenName = dRepRegistrationGivenName, dRepObjectives = dRepRegistrationObjectives, diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 0017a15dc..68b23fc94 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -768,6 +768,7 @@ data DRep , dRepType :: DRepType , dRepLatestTxHash :: Maybe HexText , dRepLatestRegistrationDate :: UTCTime + , dRepMetadataError :: Maybe Text , dRepPaymentAddress :: Maybe Text , dRepGivenName :: Maybe Text , dRepObjectives :: Maybe Text diff --git a/govtool/backend/src/VVA/DRep.hs b/govtool/backend/src/VVA/DRep.hs index fd262bc94..315e9b50a 100644 --- a/govtool/backend/src/VVA/DRep.hs +++ b/govtool/backend/src/VVA/DRep.hs @@ -61,7 +61,7 @@ listDReps = withPool $ \conn -> do results <- liftIO $ SQL.query_ conn listDRepsSql timeZone <- liftIO getCurrentTimeZone return - [ DRepRegistration drepHash drepView url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) paymentAddress givenName objectives motivations qualifications imageUrl imageHash + [ DRepRegistration drepHash drepView url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) metadataError paymentAddress givenName objectives motivations qualifications imageUrl imageHash | ( drepHash , drepView , url @@ -73,6 +73,7 @@ listDReps = withPool $ \conn -> do , date , latestDeposit , latestNonDeregisterVotingAnchorWasNotNull + , metadataError , paymentAddress , givenName , objectives diff --git a/govtool/backend/src/VVA/Types.hs b/govtool/backend/src/VVA/Types.hs index d3965ff34..669102b84 100644 --- a/govtool/backend/src/VVA/Types.hs +++ b/govtool/backend/src/VVA/Types.hs @@ -109,6 +109,7 @@ data DRepRegistration , dRepRegistrationType :: DRepType , dRepRegistrationLatestTxHash :: Maybe Text , dRepRegistrationLatestRegistrationDate :: UTCTime + , dRepRegistrationMetadataError :: Maybe Text , dRepRegistrationPaymentAddress :: Maybe Text , dRepRegistrationGivenName :: Maybe Text , dRepRegistrationObjectives :: Maybe Text From d74fbe2604ed590d09d1ac51d65daa3c5d6ad737 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 24 Sep 2024 10:42:13 +0545 Subject: [PATCH 10/35] chore: update temporary proposal wallets message --- .../playwright/tests/governance-action.setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/governance-action.setup.ts b/tests/govtool-frontend/playwright/tests/governance-action.setup.ts index 3a8aed8f4..634372c5c 100644 --- a/tests/govtool-frontend/playwright/tests/governance-action.setup.ts +++ b/tests/govtool-frontend/playwright/tests/governance-action.setup.ts @@ -36,7 +36,7 @@ setup("Setup temporary proposal wallets", async () => { ]); await pollTransaction(initializeRes.txId, initializeRes.lockInfo); - // transfer 51_000 ADA for dRep registration + // transfer 51_000 ADA for proposal submission const amountOutputs = proposalSubmissionsWallets.map((wallet) => { return { address: wallet.address, value: `${51_000}A` }; }); From 899516ef2d01399f1a5d65eee930e0149590be3b Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 24 Sep 2024 12:04:34 +0545 Subject: [PATCH 11/35] chore: update delegation doc url --- tests/govtool-frontend/playwright/lib/constants/docsUrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts b/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts index e466a446a..b71d3b382 100644 --- a/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts +++ b/tests/govtool-frontend/playwright/lib/constants/docsUrl.ts @@ -1,6 +1,6 @@ import environments from "./environments"; -export const DELEGATION_DOC_URL = `${environments.docsUrl}/using-govtool/govtool-functions/delegating`; +export const DELEGATION_DOC_URL = `${environments.docsUrl}/about/what-is-cardano-govtool/govtool-functions/delegating`; export const REGISTER_DREP_DOC_URL = `${environments.docsUrl}/using-govtool/govtool-functions/dreps/register-as-a-drep`; export const DIRECT_VOTER_DOC_URL = `${environments.docsUrl}/using-govtool/govtool-functions/direct-voting`; export const GOVERNANCE_ACTION_DOC_URL = `${environments.docsUrl}/using-govtool/govtool-functions/governance-actions/view-governance-actions`; From 841dacdc0e7cd8386d201657728bd954979c3f9d Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 24 Sep 2024 12:25:36 +0545 Subject: [PATCH 12/35] chore: add assertion to wait for governance actions loaded --- .../tests/3-drep-registration/dRepRegistration.dRep.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts index 619befc5d..b34a7a647 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts @@ -23,7 +23,7 @@ test.beforeEach(async () => { test.describe("Logged in DReps", () => { test.use({ storageState: ".auth/dRep01.json", wallet: dRep01Wallet }); - test("3A. Should show dRepId on dashboard after connecting registered dRep Wallet", async ({ + test("3A. Should show dRepId on dashboard and enable voting on governance actions after connecting registered dRep Wallet", async ({ page, }) => { await page.goto("/"); @@ -37,6 +37,9 @@ test.describe("Logged in DReps", () => { const governanceActionsPage = new GovernanceActionsPage(page); await governanceActionsPage.goto(); + + await expect(page.getByText(/info action/i).first()).toBeVisible(); + const governanceActionDetailsPage = await governanceActionsPage.viewFirstProposalByGovernanceAction( GrovernanceActionType.InfoAction From 288446cd915b74d90af2d1687ed5093039efac44 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Tue, 24 Sep 2024 09:42:29 +0200 Subject: [PATCH 13/35] [#1875] add missing testIds for submitted votes --- CHANGELOG.md | 2 +- .../components/molecules/VotesSubmitted.tsx | 165 +++++++++--------- 2 files changed, 86 insertions(+), 81 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff7f94c70..fc59866f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ changes. ### Fixed -- +- Add missing testIds for submitted votes [Issue 1875](https://github.com/IntersectMBO/govtool/issues/1875) ### Changed diff --git a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx index 8edd31219..e78d8de34 100644 --- a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx +++ b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx @@ -1,7 +1,7 @@ -import { Box, Typography } from "@mui/material"; +import { Box } from "@mui/material"; import { IMAGES } from "@consts"; -import { VotePill } from "@atoms"; +import { Typography, VotePill } from "@atoms"; import { useTranslation } from "@hooks"; import { correctAdaFormat } from "@utils"; import { SubmittedVotesData } from "@models"; @@ -10,27 +10,6 @@ type Props = { votes: SubmittedVotesData; }; -const Vote = ({ - vote, - value, -}: { - vote: "yes" | "no" | "abstain"; - value: string | number; -}) => ( - - - - {value} - - -); - export const VotesSubmitted = ({ votes: { dRepYesVotes, @@ -83,67 +62,93 @@ export const VotesSubmitted = ({ sx={{ display: "flex", flexDirection: "column", - gap: "12px", + gap: 4.5, }} > - - {t("govActions.dReps")} - - - + + - - - - {t("govActions.sPos")} - - - - - - - {t("govActions.ccCommittee")} - - - - - - ); }; + +type VotesGroupProps = { + type: "ccCommittee" | "dReps" | "sPos"; + yesVotes: number; + noVotes: number; + abstainVotes: number; +}; + +const VotesGroup = ({ + type, + yesVotes, + noVotes, + abstainVotes, +}: VotesGroupProps) => { + const { t } = useTranslation(); + return ( + + + {t(`govActions.${type}`)} + + + + + + ); +}; + +type VoteProps = { + type: "ccCommittee" | "dReps" | "sPos"; + vote: "yes" | "no" | "abstain"; + value: number; +}; +const Vote = ({ type, vote, value }: VoteProps) => ( + + + + {type === "dReps" ? `₳ ${correctAdaFormat(value)}` : value} + + +); From 4cf5953fcf93c085b12d93500f04bf81aadbf624 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Wed, 25 Sep 2024 11:11:31 +0200 Subject: [PATCH 14/35] [#2062] change CC vote totals labels --- CHANGELOG.md | 2 +- govtool/frontend/junit-report.xml | 384 ++++++++++-------- .../src/components/atoms/VotePill.test.tsx | 6 +- .../src/components/atoms/VotePill.tsx | 18 +- .../components/molecules/VoteActionForm.tsx | 6 +- .../components/molecules/VotesSubmitted.tsx | 10 +- govtool/frontend/src/i18n/locales/en.ts | 10 +- .../GovernanceActionDetailsCard.stories.ts | 6 +- .../frontend/src/stories/VotePill.stories.ts | 6 +- 9 files changed, 259 insertions(+), 189 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc59866f1..b1384c5b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ changes. ### Changed -- +- Change constitutional committee vote totals to be constitutional for yes and unconstitutional for no [Issue 2062](https://github.com/IntersectMBO/govtool/issues/2062) ### Removed diff --git a/govtool/frontend/junit-report.xml b/govtool/frontend/junit-report.xml index 2f3434f92..1396b87e1 100644 --- a/govtool/frontend/junit-report.xml +++ b/govtool/frontend/junit-report.xml @@ -1,230 +1,256 @@ - - - + + + - - - + - + - + + + - + - + - + - + - - + + - + - + - - - + + + - + + + - + - + - + - - - + - - + + - + - + - + - - + + - + - + - - + + - + + + - + - + - + - + - + - + - + - + + + - + - + - + + + - + - + + + - + - - - - + + - + - - + + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - + + + - + - - + + - + - + - + + + - - + + - + - + - + - + - - + + - + + + - - + + - + + + - + - + - - + + - + - + + + + +Error: Failed to get PubDRepKey + at [90m/Users/asiadyczka/Desktop/govtool/govtool/frontend/[39msrc/utils/tests/getDRepID.test.ts:46:40 + at [90mfile:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:135:14 + at [90mfile:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:60:26 + at runTest [90m(file:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:781:17[90m)[39m +[90m at processTicksAndRejections (node:internal/process/task_queues:95:5)[39m + at runSuite [90m(file:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:909:15[90m)[39m + at runSuite [90m(file:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:909:15[90m)[39m + at runFiles [90m(file:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:958:5[90m)[39m + at startTests [90m(file:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4m@vitest[24m/runner/dist/index.js:967:3[90m)[39m + at [90mfile:///Users/asiadyczka/Desktop/govtool/govtool/frontend/[39mnode_modules/[4mvitest[24m/dist/chunks/runtime-runBaseTests.oAvMKtQC.js:116:7 + + - - + + - + - + - - - + - + - + + + - + - - - + + + - - + + - + - - - + - + - + @@ -234,88 +260,112 @@ - - + + - + - - - + - + - - + + - + - - - + - + - + - - - + - + - + - + - - - + - + + + + + + + + + + + - - + + - + - + + + + + - - + + - + - + - + + + + + - - + + - + - + - + + + - + + + + + - - + + - + - + - + - + + + + + + + + + diff --git a/govtool/frontend/src/components/atoms/VotePill.test.tsx b/govtool/frontend/src/components/atoms/VotePill.test.tsx index 24f09a4d0..69bae3985 100644 --- a/govtool/frontend/src/components/atoms/VotePill.test.tsx +++ b/govtool/frontend/src/components/atoms/VotePill.test.tsx @@ -5,7 +5,7 @@ import { VotePill } from "@atoms"; describe("VotePill", () => { it('renders the VotePill component with "yes" vote correctly', () => { const { getByText } = render(); - const voteText = getByText("yes"); + const voteText = getByText("Yes"); expect(voteText).toBeInTheDocument(); expect(voteText.parentNode).toHaveStyle({ borderColor: "#C0E4BA", @@ -15,7 +15,7 @@ describe("VotePill", () => { it('renders the VotePill component with "no" vote correctly', () => { const { getByText } = render(); - const voteText = getByText("no"); + const voteText = getByText("No"); expect(voteText).toBeInTheDocument(); expect(voteText.parentNode).toHaveStyle({ borderColor: "#EDACAC", @@ -25,7 +25,7 @@ describe("VotePill", () => { it('renders the VotePill component with "abstain" vote correctly', () => { const { getByText } = render(); - const voteText = getByText("abstain"); + const voteText = getByText("Abstain"); expect(voteText).toBeInTheDocument(); expect(voteText.parentNode).toHaveStyle({ borderColor: "#99ADDE", diff --git a/govtool/frontend/src/components/atoms/VotePill.tsx b/govtool/frontend/src/components/atoms/VotePill.tsx index de29ac900..53ad58ece 100644 --- a/govtool/frontend/src/components/atoms/VotePill.tsx +++ b/govtool/frontend/src/components/atoms/VotePill.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from "react-i18next"; import { Box, Typography } from "@mui/material"; import { Vote } from "@models"; @@ -6,12 +7,15 @@ export const VotePill = ({ vote, width, maxWidth, + isCC, }: { vote: Vote; width?: number; maxWidth?: number; + isCC?: boolean; }) => { - const VOTE = vote.toLowerCase(); + const { t } = useTranslation(); + const VOTE = vote.toLowerCase() as "yes" | "no" | "abstain"; return ( - {vote} + {t( + `votes.${ + isCC + ? VOTE === "yes" + ? "constitutional" + : vote === "no" + ? "unconstitutional" + : VOTE + : VOTE + }`, + )} ); diff --git a/govtool/frontend/src/components/molecules/VoteActionForm.tsx b/govtool/frontend/src/components/molecules/VoteActionForm.tsx index 79e13120b..e7fd496f0 100644 --- a/govtool/frontend/src/components/molecules/VoteActionForm.tsx +++ b/govtool/frontend/src/components/molecules/VoteActionForm.tsx @@ -170,7 +170,7 @@ export const VoteActionForm = ({ name="vote" register={registerInput} setValue={setValue} - title={t("yes")} + title={t("votes.yes")} value="yes" disabled={isInProgress} /> @@ -180,7 +180,7 @@ export const VoteActionForm = ({ name="vote" register={registerInput} setValue={setValue} - title={t("no")} + title={t("votes.no")} value="no" disabled={isInProgress} /> @@ -190,7 +190,7 @@ export const VoteActionForm = ({ name="vote" register={registerInput} setValue={setValue} - title={t("abstain")} + title={t("votes.abstain")} value="abstain" disabled={isInProgress} /> diff --git a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx index e78d8de34..14aa7d0c0 100644 --- a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx +++ b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx @@ -88,8 +88,10 @@ export const VotesSubmitted = ({ ); }; +type VoterType = "ccCommittee" | "dReps" | "sPos"; + type VotesGroupProps = { - type: "ccCommittee" | "dReps" | "sPos"; + type: VoterType; yesVotes: number; noVotes: number; abstainVotes: number; @@ -127,8 +129,8 @@ const VotesGroup = ({ }; type VoteProps = { - type: "ccCommittee" | "dReps" | "sPos"; - vote: "yes" | "no" | "abstain"; + type: VoterType; + vote: VoteType; value: number; }; const Vote = ({ type, vote, value }: VoteProps) => ( @@ -140,7 +142,7 @@ const Vote = ({ type, vote, value }: VoteProps) => ( columnGap: 1.5, }} > - + { const canvas = within(canvasElement); - await expect(canvas.getByText(/yes/i)).toBeInTheDocument(); + await expect(canvas.getByText(/Yes/i)).toBeInTheDocument(); }, }; @@ -35,7 +35,7 @@ export const VotePillNo: Story = { }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); - await expect(canvas.getByText(/no/i)).toBeInTheDocument(); + await expect(canvas.getByText(/No/i)).toBeInTheDocument(); }, }; @@ -45,6 +45,6 @@ export const VotePillAbstain: Story = { }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); - await expect(canvas.getByText(/abstain/i)).toBeInTheDocument(); + await expect(canvas.getByText(/Abstain/i)).toBeInTheDocument(); }, }; From d5706ccd63aa878db2b4510e83f61d36b4f0aa26 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 24 Sep 2024 10:57:37 +0545 Subject: [PATCH 15/35] chore: intercept epoch/params instead of using local storage to update protocol parameter version --- .../proposalFunctionality.dRep.spec.ts | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts index 2383fbc61..8106495c2 100644 --- a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts @@ -255,6 +255,20 @@ test.describe("Bootstrap phase", () => { page, context, }) => { + await page.route("**/epoch/params", async (route) => { + // Fetch the original response from the server + const response = await route.fetch(); + const json = await response.json(); + + // update protocol major version + json["protocol_major"] = 9; + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify(json), + }); + }); + const voteBlacklistOptions = Object.keys(GrovernanceActionType).filter( (option) => option !== BootstrapGovernanceActionType.InfoAction ); @@ -262,21 +276,6 @@ test.describe("Bootstrap phase", () => { const govActionsPage = new GovernanceActionsPage(page); await govActionsPage.goto(); - const protocolParameter = await page.evaluate(() => { - return localStorage.getItem("protocol_params"); - }); - const parsedProtocolParameter = JSON.parse(protocolParameter); - // update protocol_major version - parsedProtocolParameter["protocol_major"] = 9; - - const updatedProtocolParameterString = JSON.stringify( - parsedProtocolParameter - ); - // add updated protocol parameter - await context.addInitScript(` - localStorage.setItem('protocol_params', '${updatedProtocolParameterString}'); - `); - for (const voteBlacklistOption of voteBlacklistOptions) { const governanceActionDetailsPage = await govActionsPage.viewFirstProposalByGovernanceAction( From 9edb93a435548dc6983a6eb9fc39e266cb8f4c3d Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 26 Sep 2024 16:53:15 +0545 Subject: [PATCH 16/35] chore: add test ids for dRep, spos and ccCommittee votes --- .../lib/pages/governanceActionDetailsPage.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/govtool-frontend/playwright/lib/pages/governanceActionDetailsPage.ts b/tests/govtool-frontend/playwright/lib/pages/governanceActionDetailsPage.ts index bce6ece44..78c52a11f 100644 --- a/tests/govtool-frontend/playwright/lib/pages/governanceActionDetailsPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/governanceActionDetailsPage.ts @@ -33,6 +33,28 @@ export default class GovernanceActionDetailsPage { readonly contextInput = this.page.getByTestId("provide-context-input"); readonly cancelModalBtn = this.page.getByTestId("cancel-modal-button"); + readonly dRepYesVotes = this.page.getByTestId("submitted-votes-dReps-yes"); + readonly dRepNoVotes = this.page.getByTestId("submitted-votes-dReps-no"); + readonly dRepAbstainVotes = this.page.getByTestId( + "submitted-votes-dReps-abstain" + ); + + readonly sPosYesVotes = this.page.getByTestId("submitted-votes-sPos-yes"); + readonly sPosNoVotes = this.page.getByTestId("submitted-votes-sPos-no"); + readonly sPosAbstainVotes = this.page.getByTestId( + "submitted-votes-sPos-abstain" + ); + + readonly ccCommitteeYesVotes = this.page.getByTestId( + "submitted-votes-sPos-no" + ); + readonly ccCommitteeNoVotes = this.page.getByTestId( + "submitted-votes-ccCommittee-no" + ); + readonly ccCommitteeAbstainVotes = this.page.getByTestId( + "submitted-votes-ccCommittee-abstain" + ); + constructor(private readonly page: Page) {} get currentPage(): Page { From 4879c8940da14a94e1d124c2d32e99fd3b0dbe8f Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 26 Sep 2024 16:55:09 +0545 Subject: [PATCH 17/35] chore: add assertion for dRep, spos and ccCommittes votes visiblity --- .../proposalFunctionality.dRep.spec.ts | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts index 8106495c2..bafa8cfc1 100644 --- a/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/5-proposal-functionality/proposalFunctionality.dRep.spec.ts @@ -225,7 +225,7 @@ test.describe("Check voting power", () => { test.setTimeout(testInfo.timeout + environments.txTimeOut); const wallet = await walletManager.popWallet("registeredDRep"); - await walletManager.removeCopyWallet(wallet,"registeredDRepCopy"); + await walletManager.removeCopyWallet(wallet, "registeredDRepCopy"); const tempDRepAuth = await createTempDRepAuth(page, wallet); @@ -276,6 +276,11 @@ test.describe("Bootstrap phase", () => { const govActionsPage = new GovernanceActionsPage(page); await govActionsPage.goto(); + // wait until the loading button is hidden + await expect( + page.getByRole("progressbar").getByRole("img") + ).not.toBeVisible({ timeout: 10_000 }); + for (const voteBlacklistOption of voteBlacklistOptions) { const governanceActionDetailsPage = await govActionsPage.viewFirstProposalByGovernanceAction( @@ -283,9 +288,30 @@ test.describe("Bootstrap phase", () => { ); if (governanceActionDetailsPage !== null) { - await expect(page.getByText("yes₳").first()).toBeVisible(); - await expect(page.getByText("abstain₳").first()).toBeVisible(); - await expect(page.getByText("no₳").first()).toBeVisible(); + // dRep vote + await expect(governanceActionDetailsPage.dRepYesVotes).toBeVisible(); + await expect( + governanceActionDetailsPage.dRepAbstainVotes + ).toBeVisible(); + await expect(governanceActionDetailsPage.dRepNoVotes).toBeVisible(); + + // sPos vote + await expect(governanceActionDetailsPage.sPosYesVotes).toBeVisible(); + await expect( + governanceActionDetailsPage.sPosAbstainVotes + ).toBeVisible(); + await expect(governanceActionDetailsPage.sPosNoVotes).toBeVisible(); + + // ccCommittee vote + await expect( + governanceActionDetailsPage.ccCommitteeYesVotes + ).toBeVisible(); + await expect( + governanceActionDetailsPage.ccCommitteeAbstainVotes + ).toBeVisible(); + await expect( + governanceActionDetailsPage.ccCommitteeNoVotes + ).toBeVisible(); await expect( governanceActionDetailsPage.yesVoteRadio From 56b996584de5c195750e74cea679c06218968a8e Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 12:04:00 +0545 Subject: [PATCH 18/35] fix: test 4G by update test ids and its assertion --- .../proposalVisibility.dRep.spec.ts | 92 ++++++++----------- 1 file changed, 37 insertions(+), 55 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts index f897af4e7..210e5de18 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.dRep.spec.ts @@ -12,7 +12,11 @@ import { import { createNewPageWithWallet } from "@helpers/page"; import GovernanceActionsPage from "@pages/governanceActionsPage"; import { Page, expect } from "@playwright/test"; -import { BootstrapGovernanceActionType, GrovernanceActionType, IProposal } from "@types"; +import { + BootstrapGovernanceActionType, + GrovernanceActionType, + IProposal, +} from "@types"; import walletManager from "lib/walletManager"; test.beforeEach(async () => { @@ -108,60 +112,38 @@ test.describe("Check vote count", () => { await governanceActionsPage.viewProposal(proposalToCheck); await govActionDetailsPage.showVotesBtn.click(); - await expect( - page - .getByText("yes₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("yes₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("yes₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccNoVotes)}`) - ).toBeVisible(); + // check dRep votes + await expect(govActionDetailsPage.dRepYesVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}` + ); + await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}` + ); + await expect(govActionDetailsPage.dRepNoVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}` + ); + + // check sPos votes + await expect(govActionDetailsPage.sPosYesVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}` + ); + await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}` + ); + await expect(govActionDetailsPage.sPosNoVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}` + ); + + // check ccCommittee votes + await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText( + `${proposalToCheck.ccYesVotes}` + ); + await expect(govActionDetailsPage.ccCommitteeAbstainVotes).toHaveText( + `${proposalToCheck.ccAbstainVotes}` + ); + await expect(govActionDetailsPage.ccCommitteeNoVotes).toHaveText( + `${proposalToCheck.ccNoVotes}` + ); }); }); From c5c366f19da84947737639b4f2e05b1530f01e99 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 12:04:23 +0545 Subject: [PATCH 19/35] fix: test 4K by update test ids and its assertion --- .../proposalVisibility.spec.ts | 89 +++++++------------ 1 file changed, 34 insertions(+), 55 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts index bf8697df7..632760655 100644 --- a/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts +++ b/tests/govtool-frontend/playwright/tests/4-proposal-visibility/proposalVisibility.spec.ts @@ -52,60 +52,39 @@ test("4K. Should display correct vote counts on governance details page for disc expect(proposals.length, "No proposals found!").toBeGreaterThan(0); const proposalToCheck = proposals[0]; - await governanceActionsPage.viewProposal(proposalToCheck); + const govActionDetailsPage = + await governanceActionsPage.viewProposal(proposalToCheck); - await expect( - page - .getByText("yes₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .first() - .getByText(`₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("yes₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .nth(1) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("yes₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccYesVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("abstain₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccAbstainVotes)}`) - ).toBeVisible(); - await expect( - page - .getByText("no₳") - .nth(2) - .getByText(`₳ ${lovelaceToAda(proposalToCheck.ccNoVotes)}`) - ).toBeVisible(); + // check dRep votes + await expect(govActionDetailsPage.dRepYesVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepYesVotes)}` + ); + await expect(govActionDetailsPage.dRepAbstainVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepAbstainVotes)}` + ); + await expect(govActionDetailsPage.dRepNoVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.dRepNoVotes)}` + ); + + // check sPos votes + await expect(govActionDetailsPage.sPosYesVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolYesVotes)}` + ); + await expect(govActionDetailsPage.sPosAbstainVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolAbstainVotes)}` + ); + await expect(govActionDetailsPage.sPosNoVotes).toHaveText( + `₳ ${lovelaceToAda(proposalToCheck.poolNoVotes)}` + ); + + // check ccCommittee votes + await expect(govActionDetailsPage.ccCommitteeYesVotes).toHaveText( + `${proposalToCheck.ccYesVotes}` + ); + await expect(govActionDetailsPage.ccCommitteeAbstainVotes).toHaveText( + `${proposalToCheck.ccAbstainVotes}` + ); + await expect(govActionDetailsPage.ccCommitteeNoVotes).toHaveText( + `${proposalToCheck.ccNoVotes}` + ); }); From 24e23d6f046a83dfa610197b64ebf3946f13f9e8 Mon Sep 17 00:00:00 2001 From: Sudip Bhattarai Date: Wed, 18 Sep 2024 16:15:09 +0545 Subject: [PATCH 20/35] chore/test: Remove auto system prune on build --- .github/workflows/build-and-deploy-test-stack.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-deploy-test-stack.yml b/.github/workflows/build-and-deploy-test-stack.yml index a4d3c07a2..f1ef78b51 100644 --- a/.github/workflows/build-and-deploy-test-stack.yml +++ b/.github/workflows/build-and-deploy-test-stack.yml @@ -59,9 +59,8 @@ jobs: # Execute the build-and-deploy.sh script cd $DEST_DIR/tests/test-infrastructure ./build-and-deploy.sh update-images - docker system prune - (docker image ls -q | xargs docker image rm --force ) || echo "Images cleaned-up" - envs: GOVTOOL_TAG, GRAFANA_ADMIN_PASSWORD, GRAFANA_SLACK_RECIPIENT, GRAFANA_SLACK_OAUTH_TOKEN, SENTRY_DSN_BACKEND, GTM_ID, NPMRC_TOKEN, SENTRY_DSN_FRONTEND, PIPELINE_URL, USERSNAP_SPACE_API_KEY, APP_ENV, PDF_API_URL + yes | docker system prune -f + envs: GOVTOOL_TAG, GRAFANA_ADMIN_PASSWORD, GRAFANA_SLACK_RECIPIENT, GRAFANA_SLACK_OAUTH_TOKEN, SENTRY_DSN_BACKEND, GTM_ID, NPMRC_TOKEN, SENTRY_DSN_FRONTEND, PIPELINE_URL, USERSNAP_SPACE_API_KEY, APP_ENV, PDF_API_URL, KUBER_API_KEY env: GOVTOOL_TAG: ${{ github.sha }} GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} @@ -75,4 +74,4 @@ jobs: USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} APP_ENV: test PDF_API_URL: ${{ secrets.PDF_API_URL }} - KUBER_API_KEY: ${{secrets.KUBER_API_KEY}} + KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }} From 72aa9c1e785817408621e0107b4020762bc2f70f Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 13:00:09 +0545 Subject: [PATCH 21/35] fix: test 2k_2 due to status --- .../tests/2-delegation/delegation.spec.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts index e69693882..549c2f0df 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -2,22 +2,29 @@ import { setAllureEpic } from "@helpers/allure"; import { skipIfNotHardFork } from "@helpers/cardano"; import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { expect, test } from "@playwright/test"; -import { DRepStatus } from "@types"; +import { DRepStatus, IDRep } from "@types"; test.beforeEach(async () => { await setAllureEpic("2. Delegation"); await skipIfNotHardFork(); }); +enum SortOption { + Random = "Random", + RegistrationDate = "RegistrationDate", + VotingPower = "VotingPower", + Status = "Status", +} + +const statusRank: Record = { + Active: 1, + Inactive: 2, + Retired: 3, +}; + test("2K_2. Should sort DReps", async ({ page }) => { test.slow(); - enum SortOption { - RegistrationDate = "RegistrationDate", - VotingPower = "VotingPower", - Status = "Status", - } - const dRepDirectory = new DRepDirectoryPage(page); await dRepDirectory.goto(); @@ -33,10 +40,9 @@ test("2K_2. Should sort DReps", async ({ page }) => { (d1, d2) => d1.votingPower >= d2.votingPower ); - await dRepDirectory.sortAndValidate( - SortOption.Status, - (d1, d2) => d1.status >= d2.status - ); + await dRepDirectory.sortAndValidate(SortOption.Status, (d1, d2) => { + return statusRank[d1.status] <= statusRank[d2.status]; + }); }); test("2O. Should load more DReps on show more", async ({ page }) => { From 13825901eb5f7a9ab5ccd58811ba3f1cb932e85d Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 13:02:10 +0545 Subject: [PATCH 22/35] test: add test 2k_3 to check random dRep sorting behaviour --- .../playwright/lib/pages/dRepDirectoryPage.ts | 14 ++++++--- .../tests/2-delegation/delegation.spec.ts | 31 +++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts index 36e5cd9cd..9c4ccceb3 100644 --- a/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/dRepDirectoryPage.ts @@ -103,10 +103,7 @@ export default class DRepDirectoryPage { async sortDRep(option: string) {} - async sortAndValidate( - option: string, - validationFn: (p1: IDRep, p2: IDRep) => boolean - ) { + async getDRepsResponseFromApi(option: string): Promise { const responsePromise = this.page.waitForResponse((response) => response.url().includes(`&sort=${option}`) ); @@ -114,7 +111,14 @@ export default class DRepDirectoryPage { await this.page.getByTestId(`${option}-radio`).click(); const response = await responsePromise; - const dRepList: IDRep[] = (await response.json()).elements; + return (await response.json()).elements; + } + + async sortAndValidate( + option: string, + validationFn: (p1: IDRep, p2: IDRep) => boolean + ) { + const dRepList = await this.getDRepsResponseFromApi(option); // API validation for (let i = 0; i <= dRepList.length - 2; i++) { diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts index 549c2f0df..232b13d6b 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -45,6 +45,37 @@ test("2K_2. Should sort DReps", async ({ page }) => { }); }); +test("2K_3. Should sort DReps randomly", async ({ page }) => { + const dRepDirectory = new DRepDirectoryPage(page); + await dRepDirectory.goto(); + + await dRepDirectory.sortBtn.click(); + + await page.getByTestId(`${SortOption.RegistrationDate}-radio`).click(); + + const dRepList1: IDRep[] = await dRepDirectory.getDRepsResponseFromApi( + SortOption.Random + ); + + await page.getByTestId(`${SortOption.RegistrationDate}-radio`).click(); + + const dRepList2: IDRep[] = await dRepDirectory.getDRepsResponseFromApi( + SortOption.Random + ); + + // Extract dRepIds from both lists + const dRepIdsList1 = dRepList1.map((dRep) => dRep.drepId); + const dRepIdsList2 = dRepList2.map((dRep) => dRep.drepId); + + expect(dRepList1.length).toEqual(dRepList2.length); + + const isOrderDifferent = dRepIdsList1.some( + (id, index) => id !== dRepIdsList2[index] + ); + + expect(isOrderDifferent).toBe(true); +}); + test("2O. Should load more DReps on show more", async ({ page }) => { const dRepDirectory = new DRepDirectoryPage(page); await dRepDirectory.goto(); From ff2d8ba52538f5edc35873204ef7e768ffcb5eb8 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 13:10:57 +0545 Subject: [PATCH 23/35] refactor: arrow functions of status sort and validate to remove redundant return statements --- .../playwright/tests/2-delegation/delegation.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts index 232b13d6b..980081980 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.spec.ts @@ -40,9 +40,10 @@ test("2K_2. Should sort DReps", async ({ page }) => { (d1, d2) => d1.votingPower >= d2.votingPower ); - await dRepDirectory.sortAndValidate(SortOption.Status, (d1, d2) => { - return statusRank[d1.status] <= statusRank[d2.status]; - }); + await dRepDirectory.sortAndValidate( + SortOption.Status, + (d1, d2) => statusRank[d1.status] <= statusRank[d2.status] + ); }); test("2K_3. Should sort DReps randomly", async ({ page }) => { From dde4fd1cd6a095e0de59cee95565887502d3a58d Mon Sep 17 00:00:00 2001 From: Sudip Bhattarai Date: Fri, 27 Sep 2024 13:37:52 +0545 Subject: [PATCH 24/35] Fail build when any of the service update fail --- .github/workflows/build-and-deploy-test-stack.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-test-stack.yml b/.github/workflows/build-and-deploy-test-stack.yml index f1ef78b51..01802be3c 100644 --- a/.github/workflows/build-and-deploy-test-stack.yml +++ b/.github/workflows/build-and-deploy-test-stack.yml @@ -29,6 +29,7 @@ jobs: key: ${{ secrets.TEST_STACK_SSH_KEY }} command_timeout: 100m ## Haskell container build takes a lot of time. script: | + set -euo pipefail REPO_URL="https://github.com/${{ github.repository }}" DEST_DIR="$HOME/Documents/govtool" @@ -59,7 +60,7 @@ jobs: # Execute the build-and-deploy.sh script cd $DEST_DIR/tests/test-infrastructure ./build-and-deploy.sh update-images - yes | docker system prune -f + yes | docker system prune -f || echo "Ignoring system prune eror" envs: GOVTOOL_TAG, GRAFANA_ADMIN_PASSWORD, GRAFANA_SLACK_RECIPIENT, GRAFANA_SLACK_OAUTH_TOKEN, SENTRY_DSN_BACKEND, GTM_ID, NPMRC_TOKEN, SENTRY_DSN_FRONTEND, PIPELINE_URL, USERSNAP_SPACE_API_KEY, APP_ENV, PDF_API_URL, KUBER_API_KEY env: GOVTOOL_TAG: ${{ github.sha }} From 913f69282ff4f8d568b719461747e07dc54c566f Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 27 Sep 2024 14:02:07 +0545 Subject: [PATCH 25/35] fix: update network name assertion in test 6T to improve accuracy --- .../playwright/tests/6-miscellaneous/miscellaneous.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts index b0f5ae8a0..d34383f9f 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts @@ -284,5 +284,7 @@ test("6T. Should display proper network name", async ({ page }) => { const response = await responsePromise; const responseBody = await response.json(); - await expect((await page.getByTestId("system-network-name").innerText()).toLowerCase()).toBe(responseBody["networkName"].toLowerCase()) + await expect(page.getByTestId("system-network-name")).toHaveText( + new RegExp(responseBody["networkName"], "i") + ); }); From abaa9fa46f8ce0e342b7f096c585751716ba420a Mon Sep 17 00:00:00 2001 From: Sudip Bhattarai Date: Fri, 27 Sep 2024 14:08:18 +0545 Subject: [PATCH 26/35] chore: gov-action-loader minor ui fixes --- .../frontend/src/views/SpecificLoad.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gov-action-loader/frontend/src/views/SpecificLoad.vue b/gov-action-loader/frontend/src/views/SpecificLoad.vue index 05fd0507f..b9cc8744a 100644 --- a/gov-action-loader/frontend/src/views/SpecificLoad.vue +++ b/gov-action-loader/frontend/src/views/SpecificLoad.vue @@ -72,15 +72,17 @@ import config from '../config' - +
+ + +
+ -
- + -
+ @@ -915,6 +917,12 @@ export default { ...(this.DRepDeposit != null ? { DRepDeposit: parseInt(this.DRepDeposit) } : {}), ...(this.DRepActivity != null ? { DRepActivity: parseInt(this.DRepActivity) } : {}), } + proposal_data['script'] = + { + type: "PlutusScriptV3", + description: "", + cborHex: this.guardrailScript + } break } From e9a0bea07f9830c4fe8acb6efd35e527812e4cca Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Fri, 27 Sep 2024 11:34:15 +0200 Subject: [PATCH 27/35] [#1856] fix bugs that occur when parsing nested metadata --- govtool/frontend/src/consts/dRepActions/jsonContext.ts | 1 + govtool/metadata-validation/src/app.service.ts | 2 +- govtool/metadata-validation/src/utils/getFieldValue.ts | 9 +++++---- govtool/metadata-validation/src/utils/parseMetadata.ts | 7 ++++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/govtool/frontend/src/consts/dRepActions/jsonContext.ts b/govtool/frontend/src/consts/dRepActions/jsonContext.ts index 5b7886211..a077f153e 100644 --- a/govtool/frontend/src/consts/dRepActions/jsonContext.ts +++ b/govtool/frontend/src/consts/dRepActions/jsonContext.ts @@ -2,6 +2,7 @@ export const CIP_119 = "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0119/README.md#"; export const DREP_CONTEXT = { + "@language": "en-us", CIP100: "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#", CIP119: CIP_119, diff --git a/govtool/metadata-validation/src/app.service.ts b/govtool/metadata-validation/src/app.service.ts index 86c66e13e..7698a3c46 100644 --- a/govtool/metadata-validation/src/app.service.ts +++ b/govtool/metadata-validation/src/app.service.ts @@ -61,7 +61,7 @@ export class AppService { if (hashedMetadata !== hash) { // Optionally validate on a parsed metadata const hashedParsedMetadata = blake.blake2bHex( - JSON.stringify(parsedData), + JSON.stringify(parsedData, null, 2), undefined, 32, ); diff --git a/govtool/metadata-validation/src/utils/getFieldValue.ts b/govtool/metadata-validation/src/utils/getFieldValue.ts index cbcae0f28..60e537199 100644 --- a/govtool/metadata-validation/src/utils/getFieldValue.ts +++ b/govtool/metadata-validation/src/utils/getFieldValue.ts @@ -9,12 +9,13 @@ export const getFieldValue = ( body: Record, field: string, ): unknown => { - if (body[field] && body[field]['@value']) { - return body[field]['@value']; + const fieldValue = body[field]; + if (fieldValue.hasOwnProperty('@value')) { + return fieldValue['@value']; } - if (body[field]) { - return body[field]; + if (fieldValue) { + return fieldValue; } return undefined; diff --git a/govtool/metadata-validation/src/utils/parseMetadata.ts b/govtool/metadata-validation/src/utils/parseMetadata.ts index 4eca43514..9f3f13510 100644 --- a/govtool/metadata-validation/src/utils/parseMetadata.ts +++ b/govtool/metadata-validation/src/utils/parseMetadata.ts @@ -10,7 +10,12 @@ export const parseMetadata = (body: Record) => { const metadata = {}; Object.keys(body).forEach((key) => { - metadata[key] = getFieldValue(body, key); + if (key === 'references') { + const parsedReferences = (body[key] as Record[]).map((reference) => parseMetadata(reference)); + metadata[key] = parsedReferences; + } else { + metadata[key] = getFieldValue(body, key); + } }); return metadata; }; From 85be60382bfdd1db9eb1ffb6ccefb326ee8754d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 30 Sep 2024 14:03:47 +0200 Subject: [PATCH 28/35] fix(#1989): workaround for downloading metadata on iOS Safari --- CHANGELOG.md | 1 + govtool/frontend/src/utils/jsonUtils.ts | 35 +++++++++++++++---- .../src/utils/tests/jsonUtils.test.ts | 32 +++++++++++------ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1384c5b4..df11b06eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes. ### Fixed - Add missing testIds for submitted votes [Issue 1875](https://github.com/IntersectMBO/govtool/issues/1875) +- Provide workaround for iOS for downloading metadata on iOS [Issue 1989](https://github.com/IntersectMBO/govtool/issues/1989) ### Changed diff --git a/govtool/frontend/src/utils/jsonUtils.ts b/govtool/frontend/src/utils/jsonUtils.ts index 6b22a9c7c..04f499ed9 100644 --- a/govtool/frontend/src/utils/jsonUtils.ts +++ b/govtool/frontend/src/utils/jsonUtils.ts @@ -7,14 +7,26 @@ import { NodeObject } from "jsonld"; * If not provided, the default name will be "data.jsonld". */ export const downloadJson = (json: NodeObject, fileName?: string) => { - const jsonString = `data:text/jsonld;charset=utf-8,${encodeURIComponent( - JSON.stringify(json, null, 2), - )}`; + const blob = new Blob([JSON.stringify(json, null, 2)], { + type: "application/json", + }); + const url = URL.createObjectURL(blob); const link = document.createElement("a"); - link.href = jsonString; + link.href = url; link.download = `${fileName || "data"}.jsonld`; - link.click(); + // Fallback: If iOS/Safari doesn't support `download`, open the data in a new tab + if ( + navigator.userAgent.includes("Safari") && + !navigator.userAgent.includes("Chrome") + ) { + window.open(url, "_blank"); + } else { + link.click(); + } + + document.body.removeChild(link); + URL.revokeObjectURL(url); }; /** @@ -30,5 +42,16 @@ export const downloadTextFile = (text: string, fileName?: string) => { link.href = url; link.download = `${fileName || "data"}.txt`; - link.click(); + // Fallback: If iOS/Safari doesn't support `download`, open the data in a new tab + if ( + navigator.userAgent.includes("Safari") && + !navigator.userAgent.includes("Chrome") + ) { + window.open(url, "_blank"); + } else { + link.click(); + } + + document.body.removeChild(link); + URL.revokeObjectURL(url); }; diff --git a/govtool/frontend/src/utils/tests/jsonUtils.test.ts b/govtool/frontend/src/utils/tests/jsonUtils.test.ts index f609c4f57..792bd37e5 100644 --- a/govtool/frontend/src/utils/tests/jsonUtils.test.ts +++ b/govtool/frontend/src/utils/tests/jsonUtils.test.ts @@ -2,6 +2,24 @@ import { vi } from "vitest"; import { downloadJson } from ".."; describe("downloadJson", () => { + beforeEach(() => { + global.URL.createObjectURL = vi.fn(() => "mocked-url"); + global.URL.revokeObjectURL = vi.fn(); + + // We should pass Node as an argument based on typing. + // But we are not testing this against Nodes. + /* eslint-disable @typescript-eslint/ban-ts-comment */ + // @ts-expect-error + vi.spyOn(document.body, "appendChild").mockImplementation(() => undefined); + // @ts-expect-error + vi.spyOn(document.body, "removeChild").mockImplementation(() => undefined); + }); + + afterEach(() => { + // Restore the mocks after each test + vi.restoreAllMocks(); + }); + it("downloads JSON with default file name", () => { const json = { name: "John Doe", age: 30 }; const linkMock = document.createElement("a"); @@ -12,13 +30,11 @@ describe("downloadJson", () => { downloadJson(json); - expect(linkMock.href).toBe( - "data:text/jsonld;charset=utf-8,%7B%0A%20%20%22name%22%3A%20%22John%20Doe%22%2C%0A%20%20%22age%22%3A%2030%0A%7D", - ); + expect(linkMock.href).toBe("http://localhost:3000/mocked-url"); + expect(linkMock.download).toBe("data.jsonld"); + expect(global.URL.createObjectURL).toHaveBeenCalled(); expect(clickMock).toHaveBeenCalled(); - - vi.restoreAllMocks(); }); it("downloads JSON with custom file name", () => { @@ -31,12 +47,8 @@ describe("downloadJson", () => { downloadJson(json, "custom"); - expect(linkMock.href).toBe( - "data:text/jsonld;charset=utf-8,%7B%0A%20%20%22name%22%3A%20%22John%20Doe%22%2C%0A%20%20%22age%22%3A%2030%0A%7D", - ); + expect(linkMock.href).toBe("http://localhost:3000/mocked-url"); expect(linkMock.download).toBe("custom.jsonld"); expect(clickMock).toHaveBeenCalled(); - - vi.restoreAllMocks(); }); }); From 540799f4526c72b04e204b1a0e0bd183236aa34c Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 1 Oct 2024 16:13:17 +0545 Subject: [PATCH 29/35] fix: update testid of terms of use --- .../playwright/tests/6-miscellaneous/miscellaneous.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts index d34383f9f..1389def75 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts @@ -92,7 +92,7 @@ test("6M. Should navigate between footer links", async ({ page, context }) => { const [termsAndConditions] = await Promise.all([ context.waitForEvent("page"), - page.getByTestId("terms-and-conditions-footer-link").click(), + page.getByTestId("terms-of-use-footer-link").click(), ]); await expect(termsAndConditions).toHaveURL(TERMS_AND_CONDITIONS); From 7826b55bd786c5d0596dd9288936ccd3beca850d Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Wed, 2 Oct 2024 09:37:16 +0200 Subject: [PATCH 30/35] [#2090] fix infinite loading in DRep Directory --- CHANGELOG.md | 1 + .../frontend/src/hooks/queries/useGetDRepListQuery.ts | 10 +++++----- govtool/frontend/src/pages/DRepDirectoryContent.tsx | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df11b06eb..5b2fbdb22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ changes. - Add missing testIds for submitted votes [Issue 1875](https://github.com/IntersectMBO/govtool/issues/1875) - Provide workaround for iOS for downloading metadata on iOS [Issue 1989](https://github.com/IntersectMBO/govtool/issues/1989) +- Fix infinite loading in DRep Directory [Issue 2090](https://github.com/IntersectMBO/govtool/issues/2090) ### Changed diff --git a/govtool/frontend/src/hooks/queries/useGetDRepListQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepListQuery.ts index 3eb2a956f..562eb4930 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepListQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepListQuery.ts @@ -33,11 +33,11 @@ export const useGetDRepListInfiniteQuery = ( pendingTransaction.registerAsDrep || pendingTransaction.retireAsDirectVoter || pendingTransaction.retireAsDrep - )?.transactionHash, - filters, - searchPhrase, - sorting, - status, + )?.transactionHash ?? 'noPendingTransaction', + filters.length ? filters : "", + searchPhrase ?? "", + sorting ?? "", + status?.length ? status : "", ], async ({ pageParam = 0 }) => getDRepList({ diff --git a/govtool/frontend/src/pages/DRepDirectoryContent.tsx b/govtool/frontend/src/pages/DRepDirectoryContent.tsx index 3ac416951..c86b90744 100644 --- a/govtool/frontend/src/pages/DRepDirectoryContent.tsx +++ b/govtool/frontend/src/pages/DRepDirectoryContent.tsx @@ -48,8 +48,8 @@ export const DRepDirectoryContent: FC = ({ dataActionsBarProps; useEffect(() => { - setChosenSorting(DRepListSort.Random); - }, [setChosenSorting]); + if (!chosenSorting) setChosenSorting(DRepListSort.Random); + }, [chosenSorting, setChosenSorting]); const { delegate, isDelegating } = useDelegateTodRep(); From 882bfe8ce4cb3d793e927f9604b913038e19a0a3 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Wed, 2 Oct 2024 12:26:24 +0200 Subject: [PATCH 31/35] [#1995] add useful external links to home page and dashboard --- CHANGELOG.md | 2 +- govtool/frontend/src/App.tsx | 4 +- .../components/organisms/DashboardCards.tsx | 76 ++++++++-------- .../src/components/organisms/HomeCards.tsx | 20 +--- .../src/components/organisms/UsefulLinks.tsx | 91 +++++++++++++++++++ govtool/frontend/src/i18n/locales/en.ts | 13 +++ govtool/frontend/src/pages/DashboardHome.tsx | 25 +++++ govtool/frontend/src/pages/Home.tsx | 17 +++- 8 files changed, 186 insertions(+), 62 deletions(-) create mode 100644 govtool/frontend/src/components/organisms/UsefulLinks.tsx create mode 100644 govtool/frontend/src/pages/DashboardHome.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index df11b06eb..f54642659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ changes. ### Added -- +- Add useful external links to home page and dashboard [Issue 1995](https://github.com/IntersectMBO/govtool/issues/1995) ### Fixed diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx index 9b667cb04..553d5295f 100644 --- a/govtool/frontend/src/App.tsx +++ b/govtool/frontend/src/App.tsx @@ -6,7 +6,6 @@ import { PATHS, PDF_PATHS } from "@consts"; import { useCardano, useFeatureFlag, useModal } from "@context"; import { useWalletConnectionListener } from "@hooks"; import { - DashboardCards, DashboardGovernanceActions, DashboardGovernanceActionDetails, } from "@organisms"; @@ -39,6 +38,7 @@ import { } from "@utils"; import { PublicRoute } from "./pages/PublicRoute"; import { TopBanners } from "./components/organisms/TopBanners"; +import { DashboardHome } from "./pages/DashboardHome"; export default () => { const { isProposalDiscussionForumEnabled } = useFeatureFlag(); @@ -104,7 +104,7 @@ export default () => { /> )} }> - } /> + } /> {isProposalDiscussionForumEnabled && ( { alignItems: "center", display: "flex", flex: 1, - height: "100vh", + minHeight: "calc(100vh - 175px)", justifyContent: "center", }} > @@ -42,49 +42,45 @@ export const DashboardCards = () => { } return ( - - = 1728 - ? "repeat(3, minmax(300px, 570px))" - : "repeat(2, minmax(300px, 530px))", - justifyContent: screenWidth < 1024 ? "center" : "flex-start", - px: screenWidth < 640 ? 2 : 5, - py: 3, - rowGap: 3, - }} - > - + = 1728 + ? "repeat(3, minmax(300px, 570px))" + : "repeat(2, minmax(300px, 530px))", + justifyContent: screenWidth < 1024 ? "center" : "flex-start", + rowGap: 3, + }} + > + - + - + - + - - + ); }; diff --git a/govtool/frontend/src/components/organisms/HomeCards.tsx b/govtool/frontend/src/components/organisms/HomeCards.tsx index 76dd9167f..59c97b252 100644 --- a/govtool/frontend/src/components/organisms/HomeCards.tsx +++ b/govtool/frontend/src/components/organisms/HomeCards.tsx @@ -5,14 +5,13 @@ import { Box } from "@mui/material"; import { IMAGES, PATHS, PDF_PATHS } from "@consts"; import { useFeatureFlag, useModal } from "@context"; import { ActionCard } from "@molecules"; -import { useScreenDimension, useTranslation } from "@hooks"; +import { useTranslation } from "@hooks"; import { openInNewTab } from "@utils"; export const HomeCards = () => { const { isProposalDiscussionForumEnabled } = useFeatureFlag(); const navigate = useNavigate(); const { openModal } = useModal(); - const { screenWidth } = useScreenDimension(); const { t } = useTranslation(); const openWalletModal = useCallback( @@ -66,23 +65,8 @@ export const HomeCards = () => { {/* DELEGATE CARD */} diff --git a/govtool/frontend/src/components/organisms/UsefulLinks.tsx b/govtool/frontend/src/components/organisms/UsefulLinks.tsx new file mode 100644 index 000000000..90bc1a740 --- /dev/null +++ b/govtool/frontend/src/components/organisms/UsefulLinks.tsx @@ -0,0 +1,91 @@ +import { Box, Link } from "@mui/material"; + +import { useTranslation } from "@hooks"; +import { Typography } from "../atoms"; +import { ICONS } from "@/consts"; +import { Card } from "../molecules"; + +const LINKS = { + ccPortal: { + url: "https://constitution.gov.tools", + }, + intersectWebsite: { + url: "https://www.intersectmbo.org/", + }, +} as const; + +type Props = { + align?: "left" | "center"; +}; + +export const UsefulLinks = ({ align = "left" }: Props) => { + const { t } = useTranslation(); + + return ( +
+ + {t("usefulLinks.title")} + + + {Object.entries(LINKS).map(([key, { url }]) => ( + + + {t(`usefulLinks.${key as keyof typeof LINKS}.title`)} + + + {t(`usefulLinks.${key as keyof typeof LINKS}.description`)} + + + + {t(`usefulLinks.${key as keyof typeof LINKS}.link`)} + + link + + + ))} + +
+ ); +}; diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 650b96437..ad5aa48a5 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -830,6 +830,19 @@ export const en = { unconstitutional: "Unconstitutional", yes: "Yes", }, + usefulLinks: { + title: "Useful links", + ccPortal: { + title: "Check the Constitutional Committee Portal", + description: "See Interim Cardano Constitution and Constitutional committee votes rationales", + link: "CC Portal", + }, + intersectWebsite: { + title: "Intersect website", + description: "Intersect is a member-based organization for the Cardano ecosystem — putting the community at the center of Cardano’s development", + link: "Intersect website", + }, + }, about: "About", addLink: "+ Add link", back: "Back", diff --git a/govtool/frontend/src/pages/DashboardHome.tsx b/govtool/frontend/src/pages/DashboardHome.tsx new file mode 100644 index 000000000..c2ef40f71 --- /dev/null +++ b/govtool/frontend/src/pages/DashboardHome.tsx @@ -0,0 +1,25 @@ +import { Box } from "@mui/material"; + +import { DashboardCards } from "@organisms"; +import { UsefulLinks } from "@/components/organisms/UsefulLinks"; +import { useScreenDimension } from "@/hooks"; + +export const DashboardHome = () => { + const { screenWidth } = useScreenDimension(); + + return ( + + + + + ); +}; diff --git a/govtool/frontend/src/pages/Home.tsx b/govtool/frontend/src/pages/Home.tsx index b78921194..8af4eefdf 100644 --- a/govtool/frontend/src/pages/Home.tsx +++ b/govtool/frontend/src/pages/Home.tsx @@ -7,10 +7,13 @@ import { PATHS } from "@consts"; import { useCardano } from "@context"; import { TopNav, Hero, Footer, HomeCards } from "@organisms"; import { WALLET_LS_KEY, getItemFromLocalStorage } from "@utils"; +import { UsefulLinks } from "@/components/organisms/UsefulLinks"; +import { useScreenDimension } from "@/hooks"; export const Home = () => { const { isEnabled } = useCardano(); const navigate = useNavigate(); + const { screenWidth } = useScreenDimension(); useEffect(() => { if (isEnabled && getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`)) { @@ -23,7 +26,19 @@ export const Home = () => { - + + + + {/* FIXME: Footer should be on top of the layout. Should not be rerendered across the pages */}