From fd76a9be6ea85ad517c44804a3bec5ce81651d4f Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 11:55:55 +0545 Subject: [PATCH 01/22] chore: update integration workflow to include new network options and adjust API key handling --- .../workflows/test_integration_playwright.yml | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index e478aec0d..766d16a13 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -9,13 +9,22 @@ on: deployment: required: true type: choice - default: "govtool.cardanoapi.io" + default: "preview.gov.tools" options: - "sanchogov.tools" - "staging.govtool.byron.network" - "govtool.cardanoapi.io" - "preview.gov.tools" - "gov.tools" + network: + required: true + type: choice + default: "preview" + options: + - "sanchonet" + - "preview" + - "mainnet" + - "preprod" workflow_run: workflows: ["Build and deploy GovTool to TEST server"] @@ -56,23 +65,19 @@ jobs: chmod +w ./lib/_mock npm run generate-wallets - # Set network variables based on deployment input and environment - if [[ "${{inputs.deployment}}" == "gov.tools" ]]; then - export NETWORK='mainnet' - else - export NETWORK="${{ vars.NETWORK }}" - fi - # Set API keys based on the network - if [[ "${{ vars.NETWORK }}" == "preprod" ]]; then + if [[ "${{ env.NETWORK }}" == "preprod" ]]; then export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREPROD }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}" - elif [[ "${{ vars.NETWORK }}" == "sanchonet" ]]; then + elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_SANCHONET }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}" - else + elif [[ "${{ env.NETWORK }}" == "preview" ]]; then export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}" export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}" + else + export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}" + export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_MAINNET }}" fi npm test @@ -96,6 +101,7 @@ jobs: API_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}/api DOCS_URL: ${{ vars.DOCS_URL }} KUBER_API_KEY: ${{secrets.KUBER_API_KEY}} + NETWORK: ${{ inputs.deployment || vars.NETWORK }} TEST_WORKERS: ${{vars.TEST_WORKERS}} CI: ${{vars.CI}} FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}} From bccd47e54850a0f04ebc236a1f912b9789ef7a2f Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 12:25:53 +0545 Subject: [PATCH 02/22] chore: update backend test workflow to include new preview/mainnet deployment options and network selection --- .github/workflows/test_backend.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 963405dfc..84ea5484d 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -9,11 +9,22 @@ on: deployment: required: true type: choice - default: "govtool.cardanoapi.io/api" + default: "https://z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" options: - "sanchogov.tools/api" - "staging.govtool.byron.network/api" - "govtool.cardanoapi.io/api" + - "https://z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" + - "https://be.gov.tools" + network: + required: true + type: choice + default: "preview" + options: + - "sanchonet" + - "preview" + - "mainnet" + - "preprod" jobs: backend-tests: @@ -42,16 +53,9 @@ jobs: fi python ./setup.py python -m pytest --alluredir allure-results - if [[ "${{ env.NETWORK }}" == "preprod" ]]; then - echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREPROD }}" >> $GITHUB_ENV - elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then - echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_SANCHONET }}" >> $GITHUB_ENV - else - echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREVIEW }}" >> $GITHUB_ENV - fi env: BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }} - NETWORK: ${{ vars.NETWORK }} + NETWORK: ${{ inputs.network || vars.NETWORK }} KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }} - name: Upload report From 96881276b41b5a5c59bded4590f411fb331364c1 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 12:42:37 +0545 Subject: [PATCH 03/22] chore: remove unecessary https on deployment options --- .github/workflows/test_backend.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 84ea5484d..caa34e79f 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -9,13 +9,13 @@ on: deployment: required: true type: choice - default: "https://z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" + default: "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" options: - "sanchogov.tools/api" - "staging.govtool.byron.network/api" - "govtool.cardanoapi.io/api" - - "https://z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" - - "https://be.gov.tools" + - "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" + - "be.gov.tools" network: required: true type: choice From db27e12877319c6452003f25288cbed91385c1d6 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 13:32:17 +0545 Subject: [PATCH 04/22] chore: add dev api options on backend test deployment --- .github/workflows/test_backend.yml | 1 + tests/govtool-backend/config.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index caa34e79f..bc5bec70a 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -15,6 +15,7 @@ on: - "staging.govtool.byron.network/api" - "govtool.cardanoapi.io/api" - "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" + - "dev-sanchonet.govtool.byron.network/api" - "be.gov.tools" network: required: true diff --git a/tests/govtool-backend/config.py b/tests/govtool-backend/config.py index e40af8b6d..1499fbf42 100644 --- a/tests/govtool-backend/config.py +++ b/tests/govtool-backend/config.py @@ -13,5 +13,5 @@ METRICS_API_SECRET = os.getenv("METRICS_API_SECRET") KUBER_API_URL = f'https://{os.getenv("NETWORK","preview")}.kuber.cardanoapi.io' KUBER_API_KEY = os.getenv("KUBER_API_KEY") -FAUCET_API_URL = f'https://faucet.${os.getenv("NETWORK","preview")}.world.dev.cardano.org' +FAUCET_API_URL = f'https://faucet.{os.getenv("NETWORK","preview")}.world.dev.cardano.org' FACUET_API_KEY = os.getenv("FAUCET_API_KEY") From 49a0a2bdfa545361ed37d7ad79d0c0e2ca899259 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 13:43:38 +0545 Subject: [PATCH 05/22] chore: update network input handling in integration test workflow --- .github/workflows/test_integration_playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 766d16a13..4c99c6bf2 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -101,7 +101,7 @@ jobs: API_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}/api DOCS_URL: ${{ vars.DOCS_URL }} KUBER_API_KEY: ${{secrets.KUBER_API_KEY}} - NETWORK: ${{ inputs.deployment || vars.NETWORK }} + NETWORK: ${{ inputs.network || vars.NETWORK }} TEST_WORKERS: ${{vars.TEST_WORKERS}} CI: ${{vars.CI}} FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}} From 6eb6a272fc59ab391a09df3d17ba5bed97e1a7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Wed, 29 Jan 2025 21:29:42 +0100 Subject: [PATCH 06/22] fix: displaying DReps whose doNotList is of type string --- CHANGELOG.md | 2 +- .../src/pages/DRepDirectoryContent.tsx | 10 +++- govtool/frontend/src/utils/index.ts | 1 + govtool/frontend/src/utils/parseBoolean.ts | 13 +++++ .../src/utils/tests/parseBoolean.test.ts | 31 +++++++++++ govtool/frontend/yarn.lock | 55 +++++++++---------- 6 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 govtool/frontend/src/utils/parseBoolean.ts create mode 100644 govtool/frontend/src/utils/tests/parseBoolean.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 768eaff48..cfc882128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ changes. ### Fixed -- +- Fix displaying DRep with doNotList property as string ### Changed diff --git a/govtool/frontend/src/pages/DRepDirectoryContent.tsx b/govtool/frontend/src/pages/DRepDirectoryContent.tsx index 441f3fbc2..432438347 100644 --- a/govtool/frontend/src/pages/DRepDirectoryContent.tsx +++ b/govtool/frontend/src/pages/DRepDirectoryContent.tsx @@ -14,7 +14,7 @@ import { } from "@hooks"; import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules"; import { AutomatedVotingOptions, DRepCard } from "@organisms"; -import { correctAdaFormat, isSameDRep, uniqBy } from "@utils"; +import { correctAdaFormat, isSameDRep, uniqBy, parseBoolean } from "@utils"; import { DRepData, DRepListSort, DRepStatus } from "@models"; import { AutomatedVotingOptionCurrentDelegation, @@ -107,9 +107,15 @@ export const DRepDirectoryContent: FC = ({ const ada = correctAdaFormat(votingPower); const listedDRepsWithoutYourself = uniqBy( - dRepList?.filter((dRep) => !dRep.doNotList && !isSameDRep(dRep, myDRepId)), + dRepList?.filter( + (dRep) => + (typeof dRep.doNotList === "string" + ? !parseBoolean(dRep.doNotList) + : !dRep.doNotList) && !isSameDRep(dRep, myDRepId), + ), "view", ); + const dRepListToDisplay = yourselfDRep && showYourselfDRep ? [yourselfDRep, ...listedDRepsWithoutYourself] diff --git a/govtool/frontend/src/utils/index.ts b/govtool/frontend/src/utils/index.ts index 2e3adf5fa..dfeaca81f 100644 --- a/govtool/frontend/src/utils/index.ts +++ b/govtool/frontend/src/utils/index.ts @@ -37,3 +37,4 @@ export * from "./testIdFromLabel"; export * from "./uniqBy"; export * from "./wait"; export * from "./getBase64ImageDetails"; +export * from "./parseBoolean"; diff --git a/govtool/frontend/src/utils/parseBoolean.ts b/govtool/frontend/src/utils/parseBoolean.ts new file mode 100644 index 000000000..8a8340e99 --- /dev/null +++ b/govtool/frontend/src/utils/parseBoolean.ts @@ -0,0 +1,13 @@ +/** + * Parses a string value and returns its boolean equivalent. + * + * @param value - The string value to be parsed. + * @returns `true` if the value is "true" (case insensitive), + * `false` if the value is "false" (case insensitive), + * or `null` if the value is neither. + */ +export const parseBoolean = (value: string): boolean | null => + ({ + true: true, + false: false, + }[String(value).toLowerCase()] ?? null); diff --git a/govtool/frontend/src/utils/tests/parseBoolean.test.ts b/govtool/frontend/src/utils/tests/parseBoolean.test.ts new file mode 100644 index 000000000..c93c74d1a --- /dev/null +++ b/govtool/frontend/src/utils/tests/parseBoolean.test.ts @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { parseBoolean } from "../parseBoolean"; + +describe("parseBoolean", () => { + it("should return true for 'true' (case insensitive)", () => { + expect(parseBoolean("true")).toBe(true); + expect(parseBoolean("TRUE")).toBe(true); + expect(parseBoolean("TrUe")).toBe(true); + }); + + it("should return false for 'false' (case insensitive)", () => { + expect(parseBoolean("false")).toBe(false); + expect(parseBoolean("FALSE")).toBe(false); + expect(parseBoolean("FaLsE")).toBe(false); + }); + + it("should return null for any other string", () => { + expect(parseBoolean("yes")).toBeNull(); + expect(parseBoolean("no")).toBeNull(); + expect(parseBoolean("1")).toBeNull(); + expect(parseBoolean("0")).toBeNull(); + expect(parseBoolean("")).toBeNull(); + }); + + it("should return null for non-string values", () => { + expect(parseBoolean(null as any)).toBeNull(); + expect(parseBoolean(undefined as any)).toBeNull(); + expect(parseBoolean(123 as any)).toBeNull(); + expect(parseBoolean({} as any)).toBeNull(); + }); +}); diff --git a/govtool/frontend/yarn.lock b/govtool/frontend/yarn.lock index f24f8e693..e0f4aac63 100644 --- a/govtool/frontend/yarn.lock +++ b/govtool/frontend/yarn.lock @@ -1367,15 +1367,15 @@ resolved "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-asmjs/-/cardano-serialization-lib-asmjs-12.1.1.tgz" integrity sha512-K3f28QUfLDJ7seO6MtKfMYtRm5ccf36TQ5yxyTmZqX1TA85MkriEdxqpgV9KLiLEA95emwnlvU2/WmlHMRPg1A== -"@esbuild/linux-x64@0.21.5": +"@esbuild/darwin-arm64@0.21.5": version "0.21.5" - resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz" - integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== + resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz" + integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== -"@esbuild/linux-x64@0.24.2": +"@esbuild/darwin-arm64@0.24.2": version "0.24.2" - resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.2.tgz" - integrity sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q== + resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.2.tgz" + integrity sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA== "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.1" @@ -2162,15 +2162,10 @@ resolved "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz" integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg== -"@parcel/watcher-linux-x64-glibc@2.5.0": +"@parcel/watcher-darwin-arm64@2.5.0": version "2.5.0" - resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz" - integrity sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw== - -"@parcel/watcher-linux-x64-musl@2.5.0": - version "2.5.0" - resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz" - integrity sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA== + resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz" + integrity sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw== "@parcel/watcher@^2.4.1": version "2.5.0" @@ -2283,15 +2278,10 @@ estree-walker "^2.0.2" picomatch "^4.0.2" -"@rollup/rollup-linux-x64-gnu@4.27.4": +"@rollup/rollup-darwin-arm64@4.27.4": version "4.27.4" - resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.4.tgz" - integrity sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q== - -"@rollup/rollup-linux-x64-musl@4.27.4": - version "4.27.4" - resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.27.4.tgz" - integrity sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw== + resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.27.4.tgz" + integrity sha512-PlNiRQapift4LNS8DPUHuDX/IdXiLjf8mc5vdEmUR0fF/pyy2qWwzdLjB+iZquGr8LuN4LnUoSEvKRwjSVYz3Q== "@rtsao/scc@^1.1.0": version "1.1.0" @@ -2870,15 +2860,10 @@ "@svgr/plugin-svgo" "^5.5.0" loader-utils "^2.0.0" -"@swc/core-linux-x64-gnu@1.9.3": +"@swc/core-darwin-arm64@1.9.3": version "1.9.3" - resolved "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.9.3.tgz" - integrity sha512-ivXXBRDXDc9k4cdv10R21ccBmGebVOwKXT/UdH1PhxUn9m/h8erAWjz5pcELwjiMf27WokqPgaWVfaclDbgE+w== - -"@swc/core-linux-x64-musl@1.9.3": - version "1.9.3" - resolved "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.9.3.tgz" - integrity sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg== + resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.9.3.tgz" + integrity sha512-hGfl/KTic/QY4tB9DkTbNuxy5cV4IeejpPD4zo+Lzt4iLlDWIeANL4Fkg67FiVceNJboqg48CUX+APhDHO5G1w== "@swc/core@*", "@swc/core@^1.5.22", "@swc/core@^1.7.26": version "1.9.3" @@ -7184,6 +7169,16 @@ fs@^0.0.1-security: resolved "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz" integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w== +fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3: + version "2.3.3" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" From 090081ac8775d042a61fa841984023804e9b7011 Mon Sep 17 00:00:00 2001 From: Niraj Date: Wed, 29 Jan 2025 18:22:09 +0545 Subject: [PATCH 07/22] chore: update workflow triggers for backend and integration tests to depend on the test stack --- .github/workflows/test_backend.yml | 6 +++--- .github/workflows/test_integration_playwright.yml | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index bc5bec70a..f5563c9c9 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -1,9 +1,6 @@ name: Backend Test on: - push: - branches: - - test workflow_dispatch: inputs: deployment: @@ -26,6 +23,9 @@ on: - "preview" - "mainnet" - "preprod" + workflow_run: + workflows: ["Build and deploy GovTool test stack"] + types: [completed] jobs: backend-tests: diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 4c99c6bf2..0ddb9105e 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -1,9 +1,6 @@ name: Integration Test [Playwright] on: - push: - branches: - - test workflow_dispatch: inputs: deployment: @@ -27,7 +24,7 @@ on: - "preprod" workflow_run: - workflows: ["Build and deploy GovTool to TEST server"] + workflows: ["Build and deploy GovTool test stack"] types: [completed] jobs: From 4c15cd31d775ef410ecbc7918061d1e956553ad0 Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 30 Jan 2025 10:17:54 +0545 Subject: [PATCH 08/22] chore: make default test runner env to govtool.cardanoapi.io --- .github/workflows/test_backend.yml | 2 +- .github/workflows/test_integration_playwright.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index f5563c9c9..1adf68508 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -6,7 +6,7 @@ on: deployment: required: true type: choice - default: "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr" + default: "govtool.cardanoapi.io/api" options: - "sanchogov.tools/api" - "staging.govtool.byron.network/api" diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 0ddb9105e..197ab9942 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -6,7 +6,7 @@ on: deployment: required: true type: choice - default: "preview.gov.tools" + default: "govtool.cardanoapi.io" options: - "sanchogov.tools" - "staging.govtool.byron.network" From 4258e92033aac66a512ceb03619d7927fe666c81 Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 30 Jan 2025 10:52:43 +0545 Subject: [PATCH 09/22] chore: update test workflow to run only on deployment success --- .github/workflows/test_backend.yml | 3 ++- .github/workflows/test_integration_playwright.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 1adf68508..22ccffaa0 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -30,6 +30,7 @@ on: jobs: backend-tests: runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -68,7 +69,7 @@ jobs: publish-report: runs-on: ubuntu-latest - if: always() + if: always() && needs.backend-tests.result != 'skipped' needs: backend-tests steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 197ab9942..b00cee48f 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -30,6 +30,7 @@ on: jobs: integration-tests: runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} defaults: run: working-directory: tests/govtool-frontend/playwright @@ -108,7 +109,7 @@ jobs: publish-report: runs-on: ubuntu-latest - if: always() + if: always() && needs.integration-tests.result != 'skipped' needs: integration-tests steps: - uses: actions/checkout@v4 From 8dd29fcc5d7e0db03a52df9a003fe6c76da9dc16 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 14:33:03 +0545 Subject: [PATCH 10/22] fix: update fetch first dRep filtering logic to exclude script-based elements --- tests/govtool-frontend/playwright/lib/helpers/dRep.ts | 3 ++- tests/govtool-frontend/playwright/lib/types.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts index 2304c5188..353709344 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts @@ -1,5 +1,6 @@ import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { Page } from "@playwright/test"; +import { IDRep } from "@types"; import { bech32 } from "bech32"; export async function fetchFirstActiveDRepDetails(page: Page) { @@ -12,7 +13,7 @@ export async function fetchFirstActiveDRepDetails(page: Page) { const response = await route.fetch(); const json = await response.json(); const elements = json["elements"].filter( - (element) => element["givenName"] != null + (element: IDRep) => element.givenName != null && !element.isScriptBased ); dRepGivenName = elements[Math.floor(Math.random() * elements.length)]["givenName"]; diff --git a/tests/govtool-frontend/playwright/lib/types.ts b/tests/govtool-frontend/playwright/lib/types.ts index 434971811..338c54d1d 100644 --- a/tests/govtool-frontend/playwright/lib/types.ts +++ b/tests/govtool-frontend/playwright/lib/types.ts @@ -110,6 +110,7 @@ export type IDRep = { status: DRepStatus; type: string; latestTxHash: string; + givenName: string | null; latestRegistrationDate: string; }; From 7816855992ed79f1b75174681df44137ea67221e Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 14:39:50 +0545 Subject: [PATCH 11/22] fix test-2F,2E and 2S fix: update delegation tests to include CIP-105 prefix and increase direct voter visibility timeout --- .../delegationFunctionality.delegation.spec.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 41731b291..3da9f8ddc 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 @@ -102,7 +102,7 @@ test.describe("Change delegation", () => { page .getByTestId(`${dRepIdFirst}-delegated-card`) .getByTestId(`${dRepIdFirst}-copy-id-button`) - ).toHaveText(dRepIdFirst, { timeout: 20_000 }); + ).toHaveText(`(CIP-105) ${dRepIdFirst}`, { timeout: 20_000 }); // verify delegation await dRepDirectoryPage.delegateToDRep(dRepIdSecond); @@ -113,7 +113,7 @@ test.describe("Change delegation", () => { page .getByTestId(`${dRepIdSecond}-delegated-card`) .getByTestId(`${dRepIdSecond}-copy-id-button`) - ).toHaveText(dRepIdSecond, { timeout: 20_000 }); + ).toHaveText(`(CIP-105) ${dRepIdSecond}`, { timeout: 20_000 }); }); }); @@ -149,7 +149,9 @@ test.describe("Register DRep state", () => { await waitForTxConfirmation(dRepPage); // Checks in dashboard - await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible(); + await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({ + timeout: 20_000, + }); await expect( dRepPage.getByTestId("register-as-sole-voter-button") ).not.toBeVisible(); @@ -168,7 +170,9 @@ test.describe("Register DRep state", () => { ).toBeVisible({ timeout: 15_000 }); await dRepPage.getByTestId("confirm-modal-button").click(); await waitForTxConfirmation(dRepPage); - await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible(); + await expect(dRepPage.getByText("You are a Direct Voter")).toBeVisible({ + timeout: 20_000, + }); const dRepDirectoryPage = new DRepDirectoryPage(dRepPage); await dRepDirectoryPage.goto(); From b4e2baefb3dc6945249ec8a0431da6171c230b84 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 14:50:16 +0545 Subject: [PATCH 12/22] fix: update payment address generation update payment address generation to use environment network id and use wallet address instead of stake address on payment address --- .../playwright/lib/helpers/metadata.ts | 5 ++++- .../tests/2-delegation/delegation.drep.spec.ts | 4 +++- .../dRepRegistration.dRep.spec.ts | 4 +++- .../dRepRegistration.loggedin.spec.ts | 5 ++++- .../tests/3-drep-registration/editDRep.dRep.spec.ts | 4 +++- .../proposalSubmission.loggedin.spec.ts | 13 ++++++++----- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/helpers/metadata.ts b/tests/govtool-frontend/playwright/lib/helpers/metadata.ts index 08eb1ee7d..f89b4f9aa 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/metadata.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/metadata.ts @@ -8,6 +8,7 @@ import * as fs from "fs"; import { ShelleyWallet } from "./crypto"; import { calculateImageSHA256 } from "./dRep"; import { imageObject } from "@types"; +import environments from "@constants/environments"; export async function downloadMetadata(download: Download): Promise<{ name: string; @@ -22,7 +23,9 @@ export async function downloadMetadata(download: Download): Promise<{ async function calculateMetadataHash() { try { - const paymentAddress = (await ShelleyWallet.generate()).addressBech32(0); + const paymentAddress = (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ); const imageUrl = faker.image.avatarGitHub(); const imageSHA256 = (await calculateImageSHA256(imageUrl)) || ""; const imageObject: imageObject = { diff --git a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts index 4534f6d4d..104ad40fa 100644 --- a/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/2-delegation/delegation.drep.spec.ts @@ -39,7 +39,9 @@ test("2N. Should show DRep information on details page", async ({ const objectives = faker.lorem.paragraph(2); const motivations = faker.lorem.paragraph(2); const qualifications = faker.lorem.paragraph(2); - const paymentAddress = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const paymentAddress = ShelleyWallet.fromJson(wallet).addressBech32( + environments.networkId + ); const linksReferenceLinks: LinkType[] = [ { url: faker.internet.url(), 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 e049300e7..ba4af51eb 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 @@ -70,7 +70,9 @@ test.describe("Logged in DReps", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts index 729b87568..b49ed3a25 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.loggedin.spec.ts @@ -7,6 +7,7 @@ import { invalid as mockInvalid, valid as mockValid } from "@mock/index"; import { skipIfNotHardFork } from "@helpers/cardano"; import DRepRegistrationPage from "@pages/dRepRegistrationPage"; import { expect } from "@playwright/test"; +import environments from "@constants/environments"; test.use({ storageState: ".auth/user01.json", @@ -64,7 +65,9 @@ test.describe("Validation of dRep Registration Form", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts index 27abd1a31..8461dc838 100644 --- a/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts +++ b/tests/govtool-frontend/playwright/tests/3-drep-registration/editDRep.dRep.spec.ts @@ -33,7 +33,9 @@ test.describe("Validation of edit dRep Form", () => { objectives: faker.lorem.paragraph(2), motivations: faker.lorem.paragraph(2), qualifications: faker.lorem.paragraph(2), - paymentAddress: (await ShelleyWallet.generate()).addressBech32(0), + paymentAddress: (await ShelleyWallet.generate()).addressBech32( + environments.networkId + ), linksReferenceLinks: [ { url: faker.internet.url(), diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index 0a9697715..004fb3d67 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -1,3 +1,4 @@ +import environments from "@constants/environments"; import { proposal01Wallet, proposal03Wallet, @@ -56,7 +57,7 @@ test.describe("Proposal created logged state", () => { for (let i = 0; i < 50; i++) { const rewardAddressBech32 = ( await ShelleyWallet.generate() - ).rewardAddressBech32(0); + ).rewardAddressBech32(environments.networkId); const formFields: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, @@ -127,8 +128,9 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = - ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const walletAddressBech32 = ShelleyWallet.fromJson( + wallet + ).addressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, @@ -180,8 +182,9 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = - ShelleyWallet.fromJson(proposal01Wallet).rewardAddressBech32(0); + const walletAddressBech32 = ShelleyWallet.fromJson( + proposal01Wallet + ).addressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, From 7d72f4de8ad3c87321b0a4b0fbd84c52efb5512a Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 15:24:52 +0545 Subject: [PATCH 13/22] fix: increase timeout for visibility checks in governance actions and proposal submission tests --- .../playwright/lib/pages/governanceActionsPage.ts | 2 +- .../tests/3-drep-registration/dRepRegistration.dRep.spec.ts | 4 +++- .../7-proposal-submission/proposalSubmission.loggedin.spec.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts index 6df0d4ef9..4e3a89a97 100644 --- a/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts @@ -159,7 +159,7 @@ export default class GovernanceActionsPage { await expect( this.page.getByRole("progressbar").getByRole("img") - ).toBeHidden({ timeout: 10_000 }); + ).toBeHidden({ timeout: 20_000 }); // Frontend validation for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) { 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 ba4af51eb..102fde3d9 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 @@ -201,7 +201,9 @@ test.describe("Temporary DReps", () => { await waitForTxConfirmation(dRepPage); - await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible(); + await expect(dRepPage.getByTestId("voting-power-chips")).not.toBeVisible({ + timeout: 20_000, + }); await expect(dRepPage.getByTestId("dRep-id-display")).not.toBeVisible(); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index 004fb3d67..bc7342b97 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -354,7 +354,8 @@ test.describe("Info Proposal Draft", () => { .click(); await expect(proposalSubmissionPage.governanceActionType).toHaveText( - createProposalType + createProposalType, + { timeout: 20_000 } ); await expect(proposalSubmissionPage.titleInput).toHaveValue( proposalFormValue.prop_name From 7bc01c5e6c6a09410bf832c6f946f1f59ee06f57 Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 15:26:04 +0545 Subject: [PATCH 14/22] fix: update proposal discussion link --- .../7-proposal-submission/proposalSubmission.loggedin.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index bc7342b97..e239c222a 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -32,7 +32,7 @@ test.describe("Proposal created logged state", () => { test.use({ storageState: ".auth/proposal01.json", wallet: proposal01Wallet }); test("7B. Should access proposal creation page", async ({ page }) => { await page.goto("/"); - await page.getByTestId("propose-governance-actions-button").click(); + await page.getByTestId("proposal-discussion-link").click(); await expect(page.getByText(/proposals/i)).toHaveCount(2); }); From 9884661b7583bed0a4345a28e5f7fc37c600c74e Mon Sep 17 00:00:00 2001 From: Niraj Date: Mon, 27 Jan 2025 15:29:08 +0545 Subject: [PATCH 15/22] fix: update Usersnap API response status to 403 for testing purposes --- .../playwright/tests/6-miscellaneous/miscellaneous.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 1389def75..77316a04f 100644 --- a/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts +++ b/tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts @@ -178,7 +178,8 @@ test.describe("User Snap", () => { // Intercept Usersnap submit API await page.route(feedbackApiUrl, async (route) => route.fulfill({ - status: 200, + status: 403, + body: JSON.stringify({ error: "Blocked by test" }), }) ); @@ -202,7 +203,8 @@ test.describe("User Snap", () => { // Intercept Usersnap submit API await page.route(feedbackApiUrl, async (route) => route.fulfill({ - status: 200, + status: 403, + body: JSON.stringify({ error: "Blocked by test" }), }) ); From 084f34763510a9b0ceda55f3ef828f63bb00a750 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 12:52:59 +0545 Subject: [PATCH 16/22] fix: increase timeout for visibility checks in DRep registration and proposal functionality tests --- .../3-drep-registration/dRepRegistration.dRep.spec.ts | 8 +++++--- .../proposalVisibility.dRep.spec.ts | 5 +++-- .../proposalFunctionality.dRep.spec.ts | 10 ++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) 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 102fde3d9..4df7611b2 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 @@ -29,11 +29,13 @@ test.describe("Logged in DReps", () => { }) => { await page.goto("/"); - await expect(page.getByTestId("voting-power-chips")).toBeVisible(); + await expect(page.getByTestId("voting-power-chips")).toBeVisible({ + timeout: 20_000, + }); await expect( page.getByTestId("dRep-id-display-card-dashboard") - ).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 }); + ).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 }); const governanceActionsPage = new GovernanceActionsPage(page); @@ -57,7 +59,7 @@ test.describe("Logged in DReps", () => { // Add an assertion to prevent clicking on "View Your dRep Details". await expect( page.getByTestId("dRep-id-display-card-dashboard") - ).toContainText(dRep01Wallet.dRepId, { timeout: 10_000 }); + ).toContainText(dRep01Wallet.dRepId, { timeout: 20_000 }); await page.getByTestId("view-drep-details-button").click(); await page.getByTestId("edit-drep-data-button").click(); 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 c49773786..e168afd2a 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 @@ -44,7 +44,8 @@ test.describe("Logged in DRep", () => { const votingPower = await res.json(); await expect(page.getByTestId("voting-power-chips-value")).toHaveText( - `₳ ${lovelaceToAda(votingPower)}` + `₳ ${lovelaceToAda(votingPower)}`, + { timeout: 20_000 } ); }); @@ -56,7 +57,7 @@ test.describe("Logged in DRep", () => { // assert to wait until the loading button is hidden await expect(page.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); govActionDetailsPage = (await isBootStrapingPhase()) 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 d13c0b012..ac81002bf 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 @@ -37,7 +37,7 @@ test.describe("Proposal checks", () => { // assert to wait until the loading button is hidden await expect(page.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); currentPage = page; @@ -150,7 +150,7 @@ test.describe("Perform voting", () => { // assert to wait until the loading button is hidden await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); govActionDetailsPage = (await isBootStrapingPhase()) @@ -277,10 +277,12 @@ test.describe("Bootstrap phase", () => { await governanceActionsPage.goto(); // assert to wait until proposal cards are visible - await expect(dRepPage.getByTestId("voting-power-chips")).toBeVisible(); + await expect(dRepPage.getByTestId("voting-power-chips")).toBeVisible({ + timeout: 20_000, + }); // wait until the loading button is hidden await expect(dRepPage.getByTestId("to-vote-tab")).toBeVisible({ - timeout: 15_000, + timeout: 20_000, }); const governanceActionDetailsPage = From a7781d940949412c178ff2195aa3d442ba561cb7 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 15:06:47 +0545 Subject: [PATCH 17/22] fix: update reward address retrieval in proposal submission tests --- .../playwright/lib/pages/proposalSubmissionPage.ts | 8 ++++++-- .../proposalSubmission.loggedin.spec.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts index de947584c..e60a76a9b 100644 --- a/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts +++ b/tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts @@ -348,7 +348,9 @@ export default class ProposalSubmissionPage { proposalType: ProposalType = ProposalType.treasury ): Promise { await this.addLinkBtn.click(); - const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32(0); + const receivingAddr = ShelleyWallet.fromJson(wallet).rewardAddressBech32( + environments.networkId + ); const proposalRequest: ProposalCreateRequest = this.generateValidProposalFormFields( @@ -374,7 +376,9 @@ export default class ProposalSubmissionPage { const proposalFormValue = this.generateValidProposalFormFields( proposalType, true, - ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32(0) + ShelleyWallet.fromJson(proposal04Wallet).rewardAddressBech32( + environments.networkId + ) ); await this.fillupForm(proposalFormValue); diff --git a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts index e239c222a..908b3ba0b 100644 --- a/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts +++ b/tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.loggedin.spec.ts @@ -128,14 +128,14 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = ShelleyWallet.fromJson( + const stakeAddressBech32 = ShelleyWallet.fromJson( wallet - ).addressBech32(environments.networkId); + ).rewardAddressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, false, - walletAddressBech32 + stakeAddressBech32 ); await proposalSubmissionPage.fillupForm(proposal); @@ -182,14 +182,14 @@ test.describe("Proposal created logged state", () => { await proposalSubmissionPage.addLinkBtn.click(); - const walletAddressBech32 = ShelleyWallet.fromJson( + const rewardAddressBech32 = ShelleyWallet.fromJson( proposal01Wallet - ).addressBech32(environments.networkId); + ).rewardAddressBech32(environments.networkId); const proposal: ProposalCreateRequest = proposalSubmissionPage.generateValidProposalFormFields( type, false, - walletAddressBech32 + rewardAddressBech32 ); await proposalSubmissionPage.fillupForm(proposal); From 7635f81468b10fb20e5c81bd8fa8ed5386c55e7b Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 15:08:48 +0545 Subject: [PATCH 18/22] fix: update wallet address generation according to network --- tests/govtool-frontend/playwright/generate_wallets.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/generate_wallets.ts b/tests/govtool-frontend/playwright/generate_wallets.ts index e13de4499..7e62ec2aa 100644 --- a/tests/govtool-frontend/playwright/generate_wallets.ts +++ b/tests/govtool-frontend/playwright/generate_wallets.ts @@ -15,10 +15,11 @@ function saveWallets(wallets: ShelleyWallet[]): void { const jsonWallets = []; for (let i = 0; i < wallets.length; i++) { const dRepId = extractDRepFromWallet(wallets[i]); + const networkId = process.env.NETWORK === "mainnet" ? 1 : 0; jsonWallets.push({ ...wallets[i].json(), - address: wallets[i].addressBech32(0), // testnet + address: wallets[i].addressBech32(networkId), dRepId, }); } From 20ac5d0a1cfe7c51d8f272f6ca8332eea378e414 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 28 Jan 2025 15:41:08 +0545 Subject: [PATCH 19/22] fix: crypto not found issue --- tests/govtool-frontend/playwright/lib/helpers/dRep.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts index 353709344..4dac42a7c 100644 --- a/tests/govtool-frontend/playwright/lib/helpers/dRep.ts +++ b/tests/govtool-frontend/playwright/lib/helpers/dRep.ts @@ -2,6 +2,7 @@ import DRepDirectoryPage from "@pages/dRepDirectoryPage"; import { Page } from "@playwright/test"; import { IDRep } from "@types"; import { bech32 } from "bech32"; +import * as crypto from "crypto"; export async function fetchFirstActiveDRepDetails(page: Page) { let dRepGivenName: string; From 50d16a98f1cf86cbe936e9f3a5a10fe092556987 Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 30 Jan 2025 12:19:39 +0545 Subject: [PATCH 20/22] fix: increase timeout for delegated voting power visibility assertion --- .../delegationFunctionality.delegation.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 3da9f8ddc..aad0a6350 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 @@ -264,9 +264,9 @@ test.describe("Abstain delegation", () => { const balance = await kuberService.getBalance(adaHolder03Wallet.address); - await expect( - page.getByText(`You have delegated ₳${balance}`) - ).toBeVisible(); + await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({ + timeout: 20_000, + }); }); }); @@ -291,9 +291,9 @@ test.describe("No confidence delegation", () => { await waitForTxConfirmation(page); const balance = await kuberService.getBalance(adaHolder04Wallet.address); - await expect( - page.getByText(`You have delegated ₳${balance}`) - ).toBeVisible(); + await expect(page.getByText(`You have delegated ₳${balance}`)).toBeVisible({ + timeout: 20_000, + }); }); }); @@ -318,13 +318,13 @@ test.describe("Delegated ADA visibility", () => { ); await expect( page.getByText(`You have delegated ₳ ${adaHolderVotingPower}`) - ).toBeVisible(); + ).toBeVisible({ timeout: 20_000 }); await page.goto("/"); await expect( page.getByText( `Your Voting Power of ₳${adaHolderVotingPower} is Delegated to` ) - ).toBeVisible(); + ).toBeVisible({ timeout: 20_000 }); }); }); From 3393376b3267a9e5002176da488b4248481a51c0 Mon Sep 17 00:00:00 2001 From: Niraj Date: Thu, 30 Jan 2025 12:32:18 +0545 Subject: [PATCH 21/22] fix: update assertion order in test 3I for consistency --- .../3-drep-registration/dRepRegistration.dRep.spec.ts | 10 +++++++++- 1 file changed, 9 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 4df7611b2..98d262df5 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 @@ -233,7 +233,9 @@ test.describe("Temporary DReps", () => { const dRepRegistrationPage = new DRepRegistrationPage(dRepPage); await dRepRegistrationPage.goto(); - await dRepRegistrationPage.register({ name: faker.person.firstName() }); + await dRepRegistrationPage.registerWithoutTxConfirmation({ + name: faker.person.firstName(), + }); await dRepRegistrationPage.registrationSuccessModal .getByTestId("confirm-modal-button") .click(); @@ -242,5 +244,11 @@ test.describe("Temporary DReps", () => { /in progress/i, { timeout: 20_000 } ); + + await waitForTxConfirmation(dRepPage); + + await expect(dRepPage.getByTestId("d-rep-in-progress")).not.toBeVisible({ + timeout: 20_000, + }); }); }); From 5ca5bbde186c611c73351b9cc5fb8172756ee93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Thu, 30 Jan 2025 10:42:19 +0100 Subject: [PATCH 22/22] fix(#1841): fix unhandled missing index exception --- CHANGELOG.md | 1 + govtool/backend/src/VVA/API/Types.hs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc882128..848e5b4fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes. ### Fixed - Fix displaying DRep with doNotList property as string +- Handle exception when no index is provided to /proposal/get endpoint [Issue 1841](https://github.com/IntersectMBO/govtool/issues/1841) ### Changed diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 3341f4860..2181bd676 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -139,11 +139,14 @@ instance ToJSON GovActionId where instance FromHttpApiData GovActionId where parseUrlPiece t = case Text.splitOn "#" t of [hash, rest] -> do - index <- case readMaybe $ Text.unpack rest of - Just x -> pure x - _ -> Left (Text.tail rest <> " is not a number") - hexHash <- parseUrlPiece hash - Right $ GovActionId hexHash index + if Text.null rest + then Left "Missing index in hash#index format" + else do + index <- case readMaybe $ Text.unpack rest of + Just x -> pure x + _ -> Left (rest <> " is not a number") + hexHash <- parseUrlPiece hash + Right $ GovActionId hexHash index _ -> Left "Not a valid hash#index value" exampleGovActionId :: Text