Skip to content

Commit

Permalink
PLT-8561 update escrow contract for test - updated second user flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamesny authored and paluh committed Nov 28, 2023
1 parent b2940c2 commit 69626f7
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 62 deletions.
26 changes: 23 additions & 3 deletions e2e/src/features/apply-inputs.feature
Expand Up @@ -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
20 changes: 20 additions & 0 deletions e2e/src/step-definitions/form.ts
Expand Up @@ -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;
}
});
}
)
213 changes: 154 additions & 59 deletions e2e/src/step-definitions/generate-contract.ts
Expand Up @@ -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));

Expand All @@ -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
}
}
],
Expand Down

0 comments on commit 69626f7

Please sign in to comment.