From 69626f72fb42f78b1f1d554759adcaefc77faf87 Mon Sep 17 00:00:00 2001 From: Larry Adames Date: Fri, 17 Nov 2023 10:33:48 -0500 Subject: [PATCH] PLT-8561 update escrow contract for test - updated second user flow --- e2e/src/features/apply-inputs.feature | 26 ++- e2e/src/step-definitions/form.ts | 20 ++ e2e/src/step-definitions/generate-contract.ts | 213 +++++++++++++----- 3 files changed, 197 insertions(+), 62 deletions(-) diff --git a/e2e/src/features/apply-inputs.feature b/e2e/src/features/apply-inputs.feature index c01827f2..834d9593 100644 --- a/e2e/src/features/apply-inputs.feature +++ b/e2e/src/features/apply-inputs.feature @@ -149,11 +149,31 @@ Feature: As a user, I would like to apply an input on a current contract And I should see "Successfully created and submitted the contract. Contract transaction awaits to be included in the blockchain." text When I click the first "button" with "Advance" text - Then I should see a "button" with "Advance contract" text + Then I should see a "button" with "Make deposit" text - When I fill in the "choice-input" input with "0" - When I click the "button" with "Advance contract" text And sign the transaction with nami wallet + When I click the "checkbox" with "Deposit 10 ₳" text + And I click the "button" with "Make deposit" text And sign the transaction with nami wallet Then I should see the first "button" showing "Syncing" text And I should see the first "button" showing "Advance" text And I should see "Successfully applied the inputs. Input application transaction awaits to be included in the blockchain." text + + When I click the first "button" with "Advance" text + Then I should see a "button" with "Advance contract" text + + When I select "Report problem" from the "form-select" dropdown + And I fill in the "choice-input" input with "1" + And I click the "button" with "Advance contract" text And sign the transaction with nami wallet + Then I should see the first "button" showing "Syncing" text + + Given I am on the "home" page + When I authorize my lace wallet + And I should see the first "button" showing "Advance" text + + When I click the first "button" with "Advance" text + Then I should see a "button" with "Advance contract" text + + When I select "Confirm problem" from the "form-select" dropdown + And I fill in the "choice-input" input with "1" + And I click the "button" with "Advance contract" text And sign the transaction with lace wallet + And I pause the page diff --git a/e2e/src/step-definitions/form.ts b/e2e/src/step-definitions/form.ts index b500b17d..c48e0dab 100644 --- a/e2e/src/step-definitions/form.ts +++ b/e2e/src/step-definitions/form.ts @@ -108,3 +108,23 @@ When('I enter the contents of {string} into the {string} field', } }); }); + +When('I select {string} from the {string} dropdown', + async function (this: ScenarioWorld, option: string, name: string) { + const { + screen: { page }, + globalConfig, + globalStateManager + } = this; + + await waitFor(async() => { + const locator = await page.locator(`select.${name}`); + const result = await locator.isVisible(); + + if (result) { + await locator.selectOption(option); + return result; + } + }); + } +) \ No newline at end of file diff --git a/e2e/src/step-definitions/generate-contract.ts b/e2e/src/step-definitions/generate-contract.ts index 67ea83a8..ec34a58d 100644 --- a/e2e/src/step-definitions/generate-contract.ts +++ b/e2e/src/step-definitions/generate-contract.ts @@ -8,7 +8,7 @@ import { MarloweJSON } from "@marlowe.io/adapter/codec"; type ContractName = "SimpleDeposit" | "SimpleChoice" | "TimedOutSimpleChoice" | "SimpleNotify" | "Escrow"; -const mkEscrow = (address1: string, address2: string): Contract => { +const mkEscrow = (buyerAddress: string, sellerAddress: string): Contract => { const twentyMinutesInMilliseconds = 20 * 60 * 1000; const inTwentyMinutes = datetoTimeout(new Date(Date.now() + twentyMinutesInMilliseconds)); @@ -17,71 +17,166 @@ const mkEscrow = (address1: string, address2: string): Contract => { timeout_continuation: "close", when: [ { - then: "close", - case: { - for_choice: { - choice_owner: { - address: address1 - }, - choice_name: "Everything is alright" - }, - choose_between: [ + then: { + when: [ { - to: 0n, - from: 0n - } - ] - } - }, - { - then: "close", - case: { - for_choice: { - choice_owner: { - address: address1 + then: "close", + case: { + for_choice: { + choice_owner: { + address: buyerAddress + }, + choice_name: "Everything is alright" + }, + choose_between: [ + { + to: 0n, + from: 0n + } + ] + } }, - choice_name: "Report problem" - }, - choose_between: [ { - to: 1n, - from: 1n + then: { + token: { + token_name: "", + currency_symbol: "" + }, + to: { + account: { + address: buyerAddress + } + }, + then: { + when: [ + { + then: "close", + case: { + for_choice: { + choice_owner: { + address: sellerAddress + }, + choice_name: "Confirm problem" + }, + choose_between: [ + { + to: 1n, + from: 1n + } + ] + } + }, + { + then: { + when: [ + { + then: { + token: { + token_name: "", + currency_symbol: "" + }, + to: { + party: { + address: sellerAddress + } + }, + then: "close", + pay: 10000000n, + from_account: { + address: buyerAddress + } + }, + case: { + for_choice: { + choice_owner: { + address: sellerAddress + }, + choice_name: "Dismiss claim" + }, + choose_between: [ + { + to: 0n, + from: 0n + } + ] + } + }, + { + then: "close", + case: { + for_choice: { + choice_owner: { + address: sellerAddress + }, + choice_name: "Confirm problem" + }, + choose_between: [ + { + to: 1n, + from: 1n + } + ] + } + } + ], + timeout_continuation: "close", + timeout: inTwentyMinutes + }, + case: { + for_choice: { + choice_owner: { + address: sellerAddress + }, + choice_name: "Dispute problem" + }, + choose_between: [ + { + to: 0n, + from: 0n + } + ] + } + } + ], + timeout_continuation: "close", + timeout: inTwentyMinutes + }, + pay: 10000000n, + from_account: { + address: sellerAddress + } + }, + case: { + for_choice: { + choice_owner: { + address: buyerAddress + }, + choice_name: "Report problem" + }, + choose_between: [ + { + to: 1n, + from: 1n + } + ] + } } - ] - } - }, - { - then: "close", + ], + timeout_continuation: "close", + timeout: inTwentyMinutes + }, case: { - for_choice: { - choice_owner: { - address: address2 - }, - choice_name: "Choice between 1-6" + party: { + address: buyerAddress }, - choose_between: [ - { - to: 3n, - from: 1n - } - ] - } - }, - { - then: "close", - case: { - for_choice: { - choice_owner: { - address: address2 - }, - choice_name: "Choice between 1-5" + of_token: { + token_name: "", + currency_symbol: "" }, - choose_between: [ - { - to: 4n, - from: 1n - } - ] + into_account: { + address: sellerAddress + }, + deposits: 10000000n } } ],