Skip to content

Commit

Permalink
Merge branch '2_0_fdc3_for_the_web' into conformance-osff-nyc-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Sep 16, 2024
2 parents 889e356 + 4433915 commit 40e831f
Show file tree
Hide file tree
Showing 17 changed files with 3,175 additions and 3,073 deletions.
3,829 changes: 962 additions & 2,867 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"compile": "webpack build",
"replace-glue-core": "npm run copy && npx replace-in-file --configFile=options/glue-core-app-1.2.js && npx replace-in-file --configFile=options/glue-core-support-1.2.js && npx replace-in-file --configFile=options/glue-core-app-2.0.js && npx replace-in-file --configFile=options/glue-core-support-2.0.js",
"replace-glue-core-plus": "npm run copy && npx replace-in-file --configFile=options/glue-core-plus-app-2.0.js && npx replace-in-file --configFile=options/glue-core-support-2.0.js",
"copy-glue-libs" : "shx cp -R options/glue/* ./dist",
"copy-glue-libs": "shx cp -R options/glue/* ./dist",
"replace-connectifi": "npm run copy && npx replace-in-file --configFile=options/connectifi-adapter.js",
"serve": "npx http-server ./dist -p 3001 -c-1",
"start": "npm run copy && npm run compile && npm run serve",
Expand All @@ -15,6 +15,7 @@
"build-static": "npm run compile && npm run copy"
},
"dependencies": {
"@kite9/client": "0.0.30",
"buffer": "^6.0.3",
"chai": "^4.3.6",
"fdc3_1_2": "npm:@finos/fdc3@^1.2.0",
Expand All @@ -40,4 +41,4 @@
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
}
}
}
4 changes: 4 additions & 0 deletions src/context-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export interface AppControlContext extends CommonContext {
errorMessage?: string;
}

export interface AppControlContextListener {
listenerPromise: Promise<AppControlContext>
}

export interface IntentUtilityContext extends CommonContext {
delayBeforeReturn?: number;
onUnsubscribedTriggered?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion src/mock/v1.2/mock-functions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DesktopAgent } from "fdc3_1_2/dist/api/DesktopAgent";
import constants from "../../constants";
import { AppControlContext } from "../../context-types";
import { fdc3Ready } from "@kite9/client";

declare let fdc3: DesktopAgent;

Expand All @@ -9,7 +10,7 @@ export const onFdc3Ready = () =>
if (window.fdc3) {
resolve(undefined);
} else {
window.addEventListener("fdc3Ready", () => resolve(undefined));
fdc3Ready().then(() => resolve(undefined));
}
});

Expand Down
3 changes: 2 additions & 1 deletion src/mock/v2.0/mock-functions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DesktopAgent } from "fdc3_2_0/dist/api/DesktopAgent";
import constants from "../../constants";
import { AppControlContext } from "../../context-types";
import { fdc3Ready } from "@kite9/client";

declare let fdc3: DesktopAgent;

Expand All @@ -9,7 +10,7 @@ export const onFdc3Ready = () =>
if (window.fdc3) {
resolve(undefined);
} else {
window.addEventListener("fdc3Ready", () => resolve(undefined));
fdc3Ready().then(() => resolve(undefined));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/fdc3-1_2-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const broadcastCloseWindow = async (currentTest) => {
} as AppControlContext);
};

export const waitForContext = (contextType: string, testId: string, channel?: Channel): Promise<AppControlContext> => {
export const waitForContext = (contextType: string, testId: string, channel: Channel): Promise<AppControlContext> => {
let executionListener: Listener;
return new Promise<Context>(async (resolve) => {
console.log(Date.now() + ` Waiting for type: "${contextType}", on channel: "${channel.id}" in test: "${testId}"`);
Expand Down
3 changes: 2 additions & 1 deletion src/test/v1.2/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fdc3Ready } from "@kite9/client";
import { getPackMembers, getPackNames, executeTestsInBrowser } from "./testSuite";

require("mocha/mocha.css");
Expand Down Expand Up @@ -29,7 +30,7 @@ function executeTests() {
if (window.fdc3) {
action();
} else {
window.addEventListener("fdc3Ready", action);
fdc3Ready().then(() => action());
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/v2.0/advanced/fdc3.findInstances.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, expect } from "chai";
import { APIDocumentation2_0 } from "../../v2.0/apiDocuments-2.0";
import { failOnTimeout, wrapPromise } from "../../../utils";
import { failOnTimeout, wait, wrapPromise } from "../../../utils";
import { closeMockAppWindow } from "../fdc3-2_0-utils";
import { IntentUtilityContext } from "../../../context-types";
import { MetadataFdc3Api } from "../support/metadata-support-2.0";
Expand All @@ -14,14 +14,15 @@ const control = new RaiseIntentControl2_0();
export default () =>
describe("fdc3.findInstances", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
await closeMockAppWindow(this.currentTest.title, 2);
});

const findInstances = "(2.0-FindInstances) valid appID when opening multiple instances of the same app";
it(findInstances, async () => {
const api = new MetadataFdc3Api();
let listener;
try {

const appIdentifier = await control.openIntentApp(IntentApp.IntentAppA); // open IntentAppA
const appIdentifier2 = await control.openIntentApp(IntentApp.IntentAppA); // open second instance of IntentAppA

Expand All @@ -45,7 +46,7 @@ export default () =>
const resolution = await api.raiseIntent(Intent.aTestingIntent, ContextType.testContextX, appIdentifier); // raise an intent that targets appIdentifier
validateResolutionSource(resolution, appIdentifier);
await wrapper.promise; // wait for context from IntentAppA

} catch (ex) {
assert.fail(findInstancesDocs + (ex.message ?? ex));
}
Expand All @@ -66,7 +67,7 @@ function validateInstances(instances: AppIdentifier[], appIdentifier: AppIdentif
const compareAppIdentifiers = (a: AppIdentifier, b: AppIdentifier) => a.appId === b.appId && a.instanceId === b.instanceId;

if (!(instances.some((instance) => compareAppIdentifiers(instance, appIdentifier)) &&
instances.some((instance) => compareAppIdentifiers(instance, appIdentifier2)))) {
instances.some((instance) => compareAppIdentifiers(instance, appIdentifier2)))) {
assert.fail(`At least one AppIdentifier object is missing from the AppIdentifier array returned after calling fdc3.findInstances(app: AppIdentifier)${findInstancesDocs}`);
}
}
16 changes: 8 additions & 8 deletions src/test/v2.0/advanced/fdc3.raiseIntent-Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const control = new RaiseIntentControl2_0();

export default () =>

describe("fdc3.raiseIntent (Result)", () => {
describe("fdc3.raiseIntent (Result)", () => {
let errorListener: Listener = undefined;

afterEach(async function afterEach() {
await closeMockAppWindow(this.currentTest.title);

Expand All @@ -32,7 +32,7 @@ describe("fdc3.raiseIntent (Result)", () => {
const RaiseIntentVoidResult5secs = "(2.0-RaiseIntentVoidResult5secs) App A receives a void IntentResult after a 5 second delay";
it(RaiseIntentVoidResult5secs, async () => {
errorListener = await control.listenForError();
let receiver = control.receiveContext(ControlContextType.aTestingIntentListenerTriggered, 8000);
const receiver = control.receiveContext(ControlContextType.aTestingIntentListenerTriggered, 8000);
const intentResolution = await control.raiseIntent(Intent.aTestingIntent, ContextType.testContextX, undefined, 5000);
control.validateIntentResolution(IntentApp.IntentAppA, intentResolution);
let intentResultPromise = control.getIntentResult(intentResolution);
Expand All @@ -56,7 +56,7 @@ describe("fdc3.raiseIntent (Result)", () => {
const RaiseIntentContextResult5secs = "(2.0-RaiseIntentContextResult5secs) IntentResult resolves to testContextY instance after a 5 second delay";
it(RaiseIntentContextResult5secs, async () => {
errorListener = await control.listenForError();
let receiver = control.receiveContext(ControlContextType.sharedTestingIntent1ListenerTriggered, 8000);
const receiver = control.receiveContext(ControlContextType.sharedTestingIntent1ListenerTriggered, 8000);
const intentResolution = await control.raiseIntent(Intent.sharedTestingIntent1, ContextType.testContextY, undefined, 5000);
control.validateIntentResolution(IntentApp.IntentAppB, intentResolution);
const intentResultPromise = control.getIntentResult(intentResolution);
Expand All @@ -71,7 +71,7 @@ describe("fdc3.raiseIntent (Result)", () => {
const RaiseIntentChannelResult = "(2.0-RaiseIntentChannelResult) IntentResult resolves to a Channel object";
it(RaiseIntentChannelResult, async () => {
errorListener = await control.listenForError();
let receiver = control.receiveContext(ControlContextType.sharedTestingIntent2ResultSent, constants.WaitTime);
const receiver = control.receiveContext(ControlContextType.sharedTestingIntent2ResultSent, constants.WaitTime);
const intentResolution = await control.raiseIntent(Intent.sharedTestingIntent2, ContextType.testContextY, {
appId: IntentApp.IntentAppE,
});
Expand Down Expand Up @@ -105,7 +105,7 @@ describe("fdc3.raiseIntent (Result)", () => {
const RaiseIntentVoidResult61secs = "(2.0-RaiseIntentVoidResult61secs) App A receives a void IntentResult after a 61 second delay";
it(RaiseIntentVoidResult61secs, async () => {
errorListener = await control.listenForError();
let receiver = control.receiveContext(ControlContextType.aTestingIntentListenerTriggered, 64000);
const receiver = control.receiveContext(ControlContextType.aTestingIntentListenerTriggered, 64000);
const intentResolution = await control.raiseIntent(Intent.aTestingIntent, ContextType.testContextX, undefined, 61000);
control.validateIntentResolution(IntentApp.IntentAppA, intentResolution);
let intentResultPromise = control.getIntentResult(intentResolution);
Expand All @@ -120,7 +120,7 @@ describe("fdc3.raiseIntent (Result)", () => {
const RaiseIntentContextResult61secs = "(2.0-RaiseIntentContextResult61secs) IntentResult resolves to testContextY instance after a 61 second delay";
it(RaiseIntentContextResult61secs, async () => {
errorListener = await control.listenForError();
let receiver = control.receiveContext(ControlContextType.sharedTestingIntent1ListenerTriggered, 64000);
const receiver = control.receiveContext(ControlContextType.sharedTestingIntent1ListenerTriggered, 64000);
const intentResolution = await control.raiseIntent(Intent.sharedTestingIntent1, ContextType.testContextY, undefined, 61000);
control.validateIntentResolution(IntentApp.IntentAppB, intentResolution);
let intentResultPromise = control.getIntentResult(intentResolution);
Expand All @@ -131,4 +131,4 @@ describe("fdc3.raiseIntent (Result)", () => {
control.validateIntentResult(intentResult, IntentResultType.Context, ContextType.testContextY);
}
}).timeout(80000);
});
});
Loading

0 comments on commit 40e831f

Please sign in to comment.