Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
270 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Feature: Switching text editors | ||
|
||
As a user I expect to be able to switch between text editors | ||
|
||
@wip | ||
Scenario: As a user I want to switch from Haskell, to Javascript, to Marlowe, to Blockly | ||
|
||
Given I am on the "home" page | ||
When I click the "link" with "Start in Haskell" text | ||
Then I should be on the "haskell editor" page | ||
And the "heading" for "project-title" should contain "New Project" text | ||
|
||
When I click the "link" with "New Project" text | ||
And I click the "button" with "JS Editor" text | ||
And I click the "button" with "Don't Save" text | ||
Then I should be on the "javascript editor" page | ||
|
||
When I click the "link" with "New Project" text | ||
And I click the "button" with "Marlowe" text | ||
And I click the "button" with "Don't Save" text | ||
Then I should be on the "marlowe editor" page | ||
|
||
When I click the "link" with "New Project" text | ||
And I click the "button" with "Blockly" text | ||
And I click the "button" with "Don't Save" text | ||
Then I should be on the "blockly editor" page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 9 additions & 72 deletions
81
e2e/src/step-definitions/assertions/verify-element-value.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,34 @@ | ||
import { Then } from '@cucumber/cucumber'; | ||
import { ElementKey, FixtureKey } from '../../env/global'; | ||
import { queries, getDocument } from 'playwright-testing-library'; | ||
import { getElementLocator } from '../../support/web-element-helper'; | ||
import { getFixtureText } from '../../support/fixture-helper'; | ||
import { ValidAccessibilityRoles } from '../../env/global'; | ||
import { ScenarioWorld } from '../setup/world' | ||
import { waitFor } from '../../support/wait-for-behavior'; | ||
|
||
Then( | ||
/^I should see a button with "([^"]*)" text$/, | ||
async function(this: ScenarioWorld, elementKey: ElementKey) { | ||
const { | ||
screen: { page }, | ||
globalConfig | ||
} = this; | ||
const document = await getDocument(page); | ||
|
||
const elementIdentifier = getElementLocator(page, elementKey, globalConfig); | ||
const { role, name } = elementIdentifier; | ||
await waitFor(async() => { | ||
try { | ||
const locator = await queries.getByRole(document, role, { name }) | ||
const isElementVisible = await locator.isVisible(); | ||
return isElementVisible; | ||
} catch { | ||
return false; | ||
} | ||
}) | ||
} | ||
); | ||
|
||
Then( | ||
/^the "([^"]*)" should contain "([^"]*)" text$/, | ||
async function(this: ScenarioWorld, elementKey: ElementKey, expectedElementText: string) { | ||
async function(this: ScenarioWorld, role: ValidAccessibilityRoles, name: string) { | ||
const { | ||
screen: { page }, | ||
globalConfig | ||
} = this; | ||
const document = await getDocument(page); | ||
const elementIdentifier = getElementLocator(page, elementKey, globalConfig); | ||
const { role, name } = elementIdentifier; | ||
await waitFor(async() => { | ||
const locator = await queries.getByRole(document, role, { name }) | ||
const locator = await page.getByRole(role, { name, exact: true }); | ||
const elementText = await locator.textContent(); | ||
return elementText?.includes(expectedElementText); | ||
return elementText?.includes(name); | ||
}) | ||
} | ||
); | ||
|
||
Then( | ||
/^the "playground editor" should contain "([^"]*)" contract code$/, | ||
async function(this: ScenarioWorld, contractFixtureKey: FixtureKey) { | ||
/^the "([^"]*)" for "([^"]*)" should contain "([^"]*)" text$/, | ||
async function(this: ScenarioWorld, role: ValidAccessibilityRoles, name: string, expectedText: string) { | ||
const { | ||
screen: { page }, | ||
globalConfig | ||
} = this; | ||
const document = await getDocument(page); | ||
// const elementIdentifier = getElementLocator(page, "playground editor", globalConfig); | ||
// const { role, name } = elementIdentifier; | ||
const fixture = getFixtureText(contractFixtureKey, globalConfig); | ||
await waitFor(async() => { | ||
|
||
const locator = await page.locator('.monaco-scrollable-element'); | ||
const elementText = await locator.textContent() | ||
// const locator = await queries.getByRole(document, role, { name }) | ||
// console.log("LOCATOR: ", locator) | ||
// const elementText = await locator.innerText() | ||
// console.log("Text Length: ", elementText.length) | ||
console.log("VALUE: ", elementText) | ||
|
||
return elementText?.includes(fixture); | ||
const locator = await page.getByRole(role, { name, exact: true }); | ||
const elementText = await locator.textContent(); | ||
return elementText?.includes(expectedText); | ||
}) | ||
} | ||
); | ||
|
||
Then( | ||
/^I should see the "([^"]*)"$/, | ||
async function(this: ScenarioWorld, elementKey: ElementKey) { | ||
const { | ||
screen: { page }, | ||
globalConfig | ||
} = this; | ||
|
||
const document = await getDocument(page); | ||
const elementIdentifier = getElementLocator(page, elementKey, globalConfig); | ||
const { role, name } = elementIdentifier; | ||
await waitFor(async() => { | ||
try { | ||
const locator = await queries.getByRole(document, role, { name }) | ||
const isElementVisible = await locator.isVisible(); | ||
return isElementVisible; | ||
} catch { | ||
return false; | ||
} | ||
}) | ||
} | ||
) |
20 changes: 7 additions & 13 deletions
20
e2e/src/step-definitions/assertions/verify-elements-visibility.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
e2e/src/step-definitions/assertions/verify-page-navigation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { Then } from '@cucumber/cucumber'; | ||
import { ElementKey } from '../../env/global'; | ||
import { getElementLocator } from '../../support/web-element-helper'; | ||
import { PageId } from '../../env/global'; | ||
import { ScenarioWorld } from '../setup/world' | ||
import { waitFor } from '../../support/wait-for-behavior'; | ||
import { | ||
currentPathMatchesPageId, | ||
} from '../../support/navigation-behavior'; | ||
|
||
Then( | ||
/^I should be on the "([^"]*)" page$/, | ||
async function (string) { | ||
// Write code here that turns the phrase above into concrete actions | ||
return 'pending'; | ||
async function(this: ScenarioWorld, pageId: PageId) { | ||
const { | ||
screen: { page }, | ||
globalConfig, | ||
} = this; | ||
|
||
await waitFor(() => currentPathMatchesPageId(page, pageId, globalConfig)) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,29 @@ | ||
import { When } from '@cucumber/cucumber'; | ||
import { ScenarioWorld } from './setup/world'; | ||
import { queries, getDocument } from 'playwright-testing-library'; | ||
import { | ||
clickElement | ||
} from '../support/html-behavior'; | ||
import { clickElement } from '../support/html-behavior'; | ||
import { waitFor } from '../support/wait-for-behavior'; | ||
import { getElementLocator } from '../support/web-element-helper'; | ||
import { ElementKey } from '../env/global'; | ||
import { ValidAccessibilityRoles } from '../env/global'; | ||
|
||
When( | ||
/^I click the "([^"]*)" (?:button|link|icon|element)$/, | ||
async function(this: ScenarioWorld, elementKey: ElementKey) { | ||
/^I click the "([^"]*)" with "([^"]*)" text$/, | ||
async function(this: ScenarioWorld, role: ValidAccessibilityRoles, name: string) { | ||
const { | ||
screen: { page }, | ||
globalConfig | ||
} = this; | ||
|
||
console.log(`I click the ${elementKey} (?:button|link|icon|element|text)`); | ||
const document = await getDocument(page); | ||
|
||
const elementIdentifier = getElementLocator(page, elementKey, globalConfig); | ||
const { role, name } = elementIdentifier; | ||
const locator = await queries.getByRole(document, role, { name }) | ||
try { | ||
|
||
await waitFor(async() => { | ||
// NOTE: This locator uses html accessibility roles and names to find elements. | ||
// If your test is not finding an element, please verify that the role and name are correct. | ||
const locator = await page.getByRole(role, { name, exact: true }); | ||
const result = await locator.isVisible(); | ||
if (result) { | ||
await clickElement(locator); | ||
} | ||
|
||
return result; | ||
if (result) await clickElement(locator); | ||
}) | ||
} catch (e) { | ||
console.log("error: ", e); | ||
} | ||
} | ||
) |
Oops, something went wrong.