From 22087f0b6502a5ea5b1b27f343bf436d8040fef6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 1 Jan 2025 14:14:27 +0200 Subject: [PATCH] Treasury creation: add cancel button (#191) --- .../create-treasury/SummaryStep.jsx | 8 +++-- .../widget/pages/treasury/Create.jsx | 7 ++-- .../tests/page.treasury-factory.near.spec.js | 34 +++++++++++++++++++ playwright-tests/util/test.js | 1 + 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 playwright-tests/tests/page.treasury-factory.near.spec.js diff --git a/instances/treasury-factory.near/widget/components/create-treasury/SummaryStep.jsx b/instances/treasury-factory.near/widget/components/create-treasury/SummaryStep.jsx index a6c584ad..99c5a847 100644 --- a/instances/treasury-factory.near/widget/components/create-treasury/SummaryStep.jsx +++ b/instances/treasury-factory.near/widget/components/create-treasury/SummaryStep.jsx @@ -82,12 +82,11 @@ const PERMISSIONS = { vote: "Vote", }; -const storageAccountName = Storage.privateGet("accountName"); +const storageAccountName = useMemo(() => Storage.privateGet("accountName")); useEffect(() => { if (storageAccountName) { setShowCongratsModal(true); - Storage.privateSet("accountName", null); } }, [storageAccountName]); @@ -362,7 +361,10 @@ return ( ), - onClose: () => setShowCongratsModal(false), + onClose: () => { + setShowCongratsModal(false); + Storage.privateSet("accountName", null); + }, }} /> )} diff --git a/instances/treasury-factory.near/widget/pages/treasury/Create.jsx b/instances/treasury-factory.near/widget/pages/treasury/Create.jsx index 40010686..c47d2c2a 100644 --- a/instances/treasury-factory.near/widget/pages/treasury/Create.jsx +++ b/instances/treasury-factory.near/widget/pages/treasury/Create.jsx @@ -74,9 +74,12 @@ const Wrapper = ({ title, children }) => (
- +
{ + console.log(`Finished ${testInfo.title} with status ${testInfo.status}`); + await page.unrouteAll({ behavior: "ignoreErrors" }); +}); + +test.describe("admin connected", function () { + test.use({ + contextOptions: { + permissions: ["clipboard-read", "clipboard-write"], + }, + storageState: "playwright-tests/storage-states/wallet-connected-admin.json", + }); + + test("should go to treasury self creation page", async ({ + page, + factoryAccount, + }) => { + await page.goto(`/${factoryAccount}/widget/app?page`); + + await expect( + await page.locator("h3").filter({ hasText: "Treasury Creation" }) + ).toBeVisible(); + + await expect(await page.getByText("Treasury Creation")).toBeVisible(); + + await page + .locator("a") + .filter({ hasText: "Yes, use this wallet and continue" }) + .click(); + }); +}); diff --git a/playwright-tests/util/test.js b/playwright-tests/util/test.js index 27b0ac7c..4baf73a1 100644 --- a/playwright-tests/util/test.js +++ b/playwright-tests/util/test.js @@ -4,4 +4,5 @@ export const test = base.extend({ instanceAccount: ["treasury-devdao.near", { option: true }], daoAccount: ["devdao.sputnik-dao.near", { option: true }], lockupContract: ["devdao.lockup.near", { option: true }], + factoryAccount: ["treasury-factory.near", { option: true }], });