Skip to content

Commit

Permalink
Now able to property-test html
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Jul 15, 2024
1 parent 86f7144 commit 8e1a84c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
8 changes: 7 additions & 1 deletion packages/client/test/features/desktop-agent-strategy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ Feature: Different Strategies for Accessing the Desktop Agent

Scenario: Running inside a Browser and using post message
Given Parent Window listens for postMessage events
Given I call getAgentAPI for a promise result
And I call getAgentAPI for a promise result
And a browser document in "document"
And I refer to "{result}" as "theAPIPromise"
And we wait for a period of "200" ms
Then the promise "{theAPIPromise}" should resolve
And I call "{result}" with "getInfo"
Then "{result}" is an object with the following contents
| fdc3Version | appMetadata.appId | provider |
| 2.0 | Test App Id | cucumber-provider |
And I refer to "{document.body.children[0]}" as "channel-selector"
And I refer to "{channel-selector.children[0]}" as "iframe"
Then "{iframe}" is an object with the following contents
| tag | atts.name | atts.src | style.width | style.height |
| iframe | FDC3 Channel Selector | http://localhost:4000/channel_selector.html | 100% | 100% |
# Scenario: Running inside an Electron Container
# In this scenario, window.fdc3 is set by the electron container and returned by getAgentAPI
# Given I call getAgentAPI for a promise result
Expand Down
4 changes: 4 additions & 0 deletions packages/client/test/step-definitions/desktop-agent.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ When('I call getAgentAPI for a promise result', function (this: CustomWorld) {
} catch (error) {
this.props['result'] = error
}
})

Given('a browser document in {string}', async function (this: CustomWorld, field: string) {
this.props[field] = globalThis.document as any
})
6 changes: 2 additions & 4 deletions packages/client/test/support/MockDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

class MockCSSStyleDeclaration {

props: { [name: string]: any } = {}

setProperty(name: string, value: string) {
this.props[name] = value
(this as any)[name] = value
}

removeProperty(name: string) {
delete this.props[name]
delete (this as any)[name]
}

}
Expand Down
6 changes: 1 addition & 5 deletions packages/testing/src/support/matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ export function indexOf(cw: PropsWorld, rows: Record<string, string>[], data: an
export function handleResolve(name: string, on: PropsWorld): any {
if (name.startsWith("{") && name.endsWith("}")) {
const stripped = name.substring(1, name.length - 1)
const parts = stripped.split(".")
var out = on.props[parts[0]]
for (let i = 1; i < parts.length; i++) {
out = out[parts[i]]
}
const out = JSONPath({ path: stripped, json: on.props })[0];
return out
} else {
return name
Expand Down

0 comments on commit 8e1a84c

Please sign in to comment.