Skip to content

Commit

Permalink
Creating tests for da-server
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Feb 26, 2024
1 parent e4a1bce commit c28aee0
Show file tree
Hide file tree
Showing 13 changed files with 452 additions and 326 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ This is a minimal proof-of-concept for FDC3 For the Web.
The project is divided into several different yarn workspaces:
- `da`:
- `src`: This is an implementation of a client-side, typescript desktop agent that communicates to a server backend using the APIs/JSON Schema defined in [Agent Bridging](https://fdc3.finos.org/docs/next/agent-bridging/spec). It is expected that we would standardize this and add to the FDC3 NPM module.
- `test`: This is some cucumber/gherkin tests that exercise the functionality in `da`. These are written to be language-agnostic so that we can use the same Gherkin feature files to test .net, Java, Python APIs too. These can be run with `yarn build`
- `da-proxy`:
- `src`: This is an implementation of a client-side, typescript desktop agent proxy that communicates to a server backend using the APIs/JSON Schema defined in [Agent Bridging](https://fdc3.finos.org/docs/next/agent-bridging/spec). It is expected that we would standardize this and add to the FDC3 NPM module.
- `test`: This is some cucumber/gherkin tests that exercise the functionality in `src`. These are written to be language-agnostic so that we can use the same Gherkin feature files to test .net, Java, Python APIs too. These can be run with `yarn build`
- `client`: This exports the `getClientAPI()` function which can be used to retrieve a desktop agent API via the web.
- `server`: A minimal implementation of the post-message protocol for retrieving desktop agent details. You can see this being used in the `demo` prject.
- `da-server`:
- `src`: A minimal implementation of the desktop-agent bridging protocol for handling messages between multiple connected sources.
- `test`: This is some cucumber/gherkin tests that exercise the functionality in `src`. These can be run with `yarn build`
- `common` : Common APIs and functionality used by both `client` and `server`
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@finos/fdc3": "^2.1.0-beta.4",
"@types/uuid": "^9.0.7",
"da": "workspace:*",
"da-proxy": "workspace:*",
"fdc3-common": "workspace:*",
"uuid": "^9.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"references": [
{
"path": "../da"
"path": "../da-proxy"
},
{
"path": "../fdc3-common"
Expand Down
13 changes: 13 additions & 0 deletions packages/da-server/cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default:
format:
- html:dist/cucumber-report.html
- "@cucumber/pretty-formatter"
paths:
- test/features/*.feature
require:
- test/step-definitions/*.steps.ts
- test/support/*.ts
- test/world/index.ts
requireModule:
- ts-node/register

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "server",
"name": "da-server",
"main": "src/index.ts",
"scripts": {
"build": "tsc -b"
"build": "nyc --reporter=lcov --reporter=text cucumber-js"
},
"dependencies": {
"@finos/fdc3": "^2.1.0-beta.4",
"@types/uuid": "^9.0.7",
"da": "workspace:*",
"fdc3-common": "workspace:*",
"uuid": "^9.0.1"
},
Expand Down
23 changes: 23 additions & 0 deletions packages/da-server/src/Messaging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AppIdentifier } from "@finos/fdc3";

export interface Messaging {

/**
* UUID for outgoing message
*/
createUUID(): string;

/**
* Post an outgoing message
*/
post(message: object) : Promise<void>

/**
* Receive an incoming message
*/
receive(message: RequestMe)



createMeta() : object
}
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/da-server/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@



function createServer(messaging: Messaging) : (m: Agent)
29 changes: 29 additions & 0 deletions packages/da-server/test/features/broadcast.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Feature: Relaying Broadcast messages

Background: Desktop Agent Server

Given A Desktop Agent Server in "server"

Scenario: Broadcast message to no-one

When "App1/a1" broadcasts "fdc3.instrument" on "channel1"
Then messaging will have outgoing posts
| source.AppId |

Scenario: Broadcast message sent to one listener

When "App2/a2" adds a context listener on "channel1" with id "abc123"
And "App1/a1" broadcasts "fdc3.instrument" on "channel1"

Then messaging will have outgoing posts
| source.AppId | source.instanceId | payload.context.type |
| App1 | a1 | fdc3.instrument |

Scenario: Broadcast message sent but listener has unsubscribed

When "App2/a2" adds a context listener on "channel1" with id "abc123"
And "App2/a2" removes context listener with id "abc123"
And "App1/a1" broadcasts "fdc3.instrument" on "channel1"

Then messaging will have outgoing posts
| source.AppId | source.instanceId | payload.context.type |
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"extends": "../../tsconfig.root.json",
"compilerOptions": {
"rootDir": "src",
"rootDirs": [ "src", "test" ],
"outDir": "dist",
},
"include": [
"src"
],
"references": [
{
"path": "../da"
},
{
"path": "../fdc3-common"
}
Expand Down
1 change: 1 addition & 0 deletions packages/da-server/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"dependencies": {
"@finos/fdc3": "^2.1.0-beta.4",
"client": "workspace:*",
"da": "workspace:*",
"da-proxy": "workspace:*",
"da-server": "workspace:*",
"fdc3-common": "workspace:*",
"server": "workspace:*",
"uuid": "^9.0.1"
},
"references": [
Expand Down
Loading

0 comments on commit c28aee0

Please sign in to comment.