Skip to content

Commit

Permalink
PLT-5884 begin simulation of escrow contract
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamesny committed May 30, 2023
1 parent c164cd0 commit f6875f2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
3 changes: 3 additions & 0 deletions e2e/config/mappings/page-elements/contract-simulation.json
@@ -0,0 +1,3 @@
{
"Simulation Currency" : { "role": "spinbutton", "name": "0.000000"}
}
2 changes: 1 addition & 1 deletion e2e/config/pages.json
Expand Up @@ -19,7 +19,7 @@
"route": "/#/blockly",
"regex": "^/#/blockly$"
},
"contract simulation": {
"contract-simulation": {
"route": "/#/simulation",
"regex": "^/#/simulation$"
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/env/global.ts
@@ -1,7 +1,7 @@
export type PageId = string;
export type PagesConfig = Record<PageId, Record<string, string>>;
export type HostsConfig = Record<string, string>;
export type ValidAccessibilityRoles = "link" | "button" | "group" | "heading";
export type ValidAccessibilityRoles = "link" | "button" | "group" | "heading" | "spinbutton";
export type ElementKey = string;
export type ElementLocator = Record<string, string>;
export type PageElementMappings = Record<PageId, Record<ElementKey, ElementLocator>>;
Expand Down
8 changes: 6 additions & 2 deletions e2e/src/features/contract-simulation.feature
Expand Up @@ -15,6 +15,10 @@ Feature: Simulated a contract
Then I should see a "button" with "Compiled" text

When I click the "button" with "Send To Simulator" text
Then I should be on the "contract simulation" page
Then I should be on the "contract-simulation" page
# And I should see a "heading" with "SIMULATION HAS NOT STARTED YET" text
And I should see a "button" with "Start simulation" text
And I should see a "button" with "Start simulation" text

When I fill in the "Simulation Currency" input with "100"
And I click the "button" with "Start simulation" text
Then I should see a "button" with "Reset" text
1 change: 0 additions & 1 deletion e2e/src/step-definitions/click.ts
@@ -1,7 +1,6 @@
import { When } from '@cucumber/cucumber';
import { ScenarioWorld } from './setup/world';
import { ValidAccessibilityRoles } from '../env/global';
import { waitFor } from '../support/wait-for-behavior';

When(
/^I click the "([^"]*)" with "([^"]*)" text$/,
Expand Down
71 changes: 32 additions & 39 deletions e2e/src/step-definitions/form.ts
@@ -1,42 +1,35 @@
// import { When } from "@cucumber/cucumber";
// import { waitFor } from "../support/wait-for-behavior";
// import { queries, getDocument } from 'playwright-testing-library';
// import { ScenarioWorld } from './setup/world';
// import { getElementLocator } from '../support/web-element-helper';
// import { getFixtureText } from '../support/fixture-helper';
// import { ElementKey, FixtureKey } from '../env/global';
// import { Locator } from 'playwright';
// import {
// inputValue,
// selectValue
// } from '../support/html-behavior';

// When(
// /^I fill in the "([^"]*)" input with "([^"]*)"$/,
// async function(this: ScenarioWorld, elementKey: ElementKey, input: string) {
// const {
// screen: { page },
// globalConfig
// } = this;


// console.log(`I fill in the ${elementKey} input with ${input}`);

// const elementIdentifier = getElementLocator(page, elementKey, globalConfig);
// const { role, name } = elementIdentifier;
// const document = await getDocument(page);

// await waitFor(async() => {
// const locator = await queries.getByRole(document, role, { name })
// const result = await locator.isVisible();

// if (result) {
// await inputValue(locator, input)
// return result;
// }
// });
// }
// )
import { When } from "@cucumber/cucumber";
import { ScenarioWorld } from './setup/world';
import { getElementLocator } from '../support/web-element-helper';
import { ElementKey } from '../env/global';
import { ValidAccessibilityRoles } from '../env/global';
import {
inputValue,
} from '../support/html-behavior';

When(
/^I fill in the "([^"]*)" input with "([^"]*)"$/,
async function(this: ScenarioWorld, elementKey: ElementKey, input: string) {
const {
screen: { page },
globalConfig
} = this;


console.log(`I fill in the ${elementKey} input with ${input}`);

const elementIdentifier = getElementLocator(page, elementKey, globalConfig);
const { role, name } = elementIdentifier;

const locator = await page.getByRole(role as ValidAccessibilityRoles, { name });
const result = await locator.isVisible();

if (result) {
await inputValue(locator, input)
return result;
}
}
)

// When(
// /^I fill in the "playground editor" input with "([^"]*)" contract code$/,
Expand Down
1 change: 1 addition & 0 deletions e2e/src/support/web-element-helper.ts
Expand Up @@ -9,6 +9,7 @@ export const getElementLocator = (
): ElementLocator => {

const currentPage = getCurrentPageId(page, globalConfig);
console.log(`currentPage: ${currentPage}`);

const { pageElementMappings } = globalConfig;
return pageElementMappings[currentPage]?.[elementKey] || pageElementMappings[currentPage]?.common?.[elementKey]
Expand Down

0 comments on commit f6875f2

Please sign in to comment.