Skip to content

Commit

Permalink
PLT-5884 contract examples by language test
Browse files Browse the repository at this point in the history
  • Loading branch information
ladamesny committed May 30, 2023
1 parent 2d07a8d commit 08829d5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
38 changes: 36 additions & 2 deletions e2e/config/mappings/page-elements/home.json
Expand Up @@ -6,5 +6,39 @@
"Open existing project": { "role": "button", "name": "Open existing project" },
"Open an example": { "role": "button", "name": "Open an example" },
"Login with github": { "role": "heading", "name": "Login with github" },
"Escrow Javascript": { "role": "button", "name": "Escrow Javascript" }
}
"Escrow header": { "role": "heading", "name": "Escrow" },
"Escrow Haskell": { "role": "button", "name": "Escrow Haskell" },
"Escrow Javascript": { "role": "button", "name": "Escrow Javascript" },
"Escrow Marlowe": { "role": "button", "name": "Escrow Marlowe" },
"Escrow Blockly": { "role": "button", "name": "Escrow Blockly" },
"Escrow with Collateral header": { "role": "heading", "name": "Escrow With Collateral" },
"Escrow with Collateral Haskell": { "role": "button", "name": "Escrow With Collateral Haskell" },
"Escrow with Collateral Javascript": { "role": "button", "name": "Escrow With Collateral Javascript" },
"Escrow with Collateral Marlowe": { "role": "button", "name": "Escrow With Collateral Marlowe" },
"Escrow with Collateral Blockly": { "role": "button", "name": "Escrow With Collateral Blockly" },
"Zero Coupon Bond header": { "role": "heading", "name": "Zero Coupon Bond" },
"Zero Coupon Bond Haskell": { "role": "button", "name": "Zero Coupon Bond Haskell" },
"Zero Coupon Bond Javascript": { "role": "button", "name": "Zero Coupon Bond Javascript" },
"Zero Coupon Bond Marlowe": { "role": "button", "name": "Zero Coupon Bond Marlowe" },
"Zero Coupon Bond Blockly": { "role": "button", "name": "Zero Coupon Bond Blockly" },
"Coupon Bond Guaranteed header": { "role": "heading", "name": "Coupon Bond Guaranteed" },
"Coupon Bond Guaranteed Haskell": { "role": "button", "name": "Coupon Bond Guaranteed Haskell" },
"Coupon Bond Guaranteed Javascript": { "role": "button", "name": "Coupon Bond Guaranteed Javascript" },
"Coupon Bond Guaranteed Marlowe": { "role": "button", "name": "Coupon Bond Guaranteed Marlowe" },
"Coupon Bond Guaranteed Blockly": { "role": "button", "name": "Coupon Bond Guaranteed Blockly" },
"Swap header": { "role": "heading", "name": "Swap" },
"Swap Haskell": { "role": "button", "name": "Swap Haskell" },
"Swap Javascript": { "role": "button", "name": "Swap Javascript" },
"Swap Marlowe": { "role": "button", "name": "Swap Marlowe" },
"Swap Blockly": { "role": "button", "name": "Swap Blockly" },
"Contract For Differences header": { "role": "heading", "name": "Contract For Differences" },
"Contract For Differences Haskell": { "role": "button", "name": "Contract For Differences Haskell" },
"Contract For Differences Javascript": { "role": "button", "name": "Contract For Differences Javascript" },
"Contract For Differences Marlowe": { "role": "button", "name": "Contract For Differences Marlowe" },
"Contract For Differences Blockly": { "role": "button", "name": "Contract For Differences Blockly" },
"Contract For Differences with Oracle header": { "role": "heading", "name": "Contract For Differences with Oracle" },
"Contract For Differences with Oracle Haskell": { "role": "button", "name": "Contract For Differences with Oracle Haskell" },
"Contract For Differences with Oracle Javascript": { "role": "button", "name": "Contract For Differences with Oracle Javascript" },
"Contract For Differences with Oracle Marlowe": { "role": "button", "name": "Contract For Differences with Oracle Marlowe" },
"Contract For Differences with Oracle Blockly": { "role": "button", "name": "Contract For Differences with Oracle Blockly" }
}
1 change: 1 addition & 0 deletions e2e/src/env/global.ts
@@ -1,6 +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" | "heading";
export type ElementKey = string;
export type ElementLocator = Record<string, string>;
export type PageElementMappings = Record<PageId, Record<ElementKey, ElementLocator>>;
Expand Down
23 changes: 21 additions & 2 deletions e2e/src/features/home-page.feature
Expand Up @@ -3,7 +3,6 @@ Feature: As a user I should be able to see the Marlowe Playground home page
As a user I should be able to navigate to the marlowe playground home page and
see all the starting point options available

@dev
@smoke
@regression
Scenario: As a user I expect to be able to see the available languages
Expand All @@ -18,4 +17,24 @@ Feature: As a user I should be able to see the Marlowe Playground home page
And I should see a button with "Open an example" text

When I click the "Open existing project" button
Then I should see "Login with github" text
Then I should see "Login with github" text

@dev
Scenario Outline: As a user, I would like to see a list of example contracts by language
Given I am on the "home" page
When I click the "Open an example" button
Then I should see "<Contract Name> header" text
And I should see "<Contract Name> Haskell" text
And I should see "<Contract Name> Javascript" text
And I should see "<Contract Name> Marlowe" text
And I should see "<Contract Name> Blockly" text

Examples:
| Contract Name |
| Escrow |
| Escrow with Collateral |
| Zero Coupon Bond |
| Coupon Bond Guaranteed |
| Swap |
| Contract For Differences |
| Contract For Differences with Oracle |
4 changes: 2 additions & 2 deletions e2e/src/step-definitions/assertions/verify-element-value.ts
Expand Up @@ -55,8 +55,8 @@ Then(
globalConfig
} = this;
const document = await getDocument(page);
const elementIdentifier = getElementLocator(page, "playground editor", globalConfig);
const { role, name } = elementIdentifier;
// const elementIdentifier = getElementLocator(page, "playground editor", globalConfig);
// const { role, name } = elementIdentifier;
const fixture = getFixtureText(contractFixtureKey, globalConfig);
await waitFor(async() => {

Expand Down
@@ -1,23 +1,27 @@
import { Then } from '@cucumber/cucumber';
import { ElementKey } from '../../env/global';
import { ElementKey, ValidAccessibilityRoles } from '../../env/global';
import { getElementLocator } from '../../support/web-element-helper';
import { ScenarioWorld } from '../setup/world'
import { waitFor } from '../../support/wait-for-behavior';


Then(
/^I should see "([^"]*)" text$/,
async function(this: ScenarioWorld, elementKey: ElementKey) {

const {
screen: { page, document },
screen: { page },
globalConfig
} = this;

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

await waitFor(async() => {
const locator = await page.getByRole(role as "link" | "button" | "heading", { name });
const locator = await page.getByRole(
role as ValidAccessibilityRoles,
{ name, exact: true }
);
const isElementVisible = await locator.isVisible()
return isElementVisible;
})
Expand Down

0 comments on commit 08829d5

Please sign in to comment.