Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 0 conformance rm for the web merging main #254

Closed
wants to merge 16 commits into from
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.17",
"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
13 changes: 9 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,17 +14,22 @@ 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 appsBothOpen = control.receiveContext(ControlContextType.intentAppAOpened, 2000, 2)

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

await appsBothOpen

//confirm that the instanceId for both app instantiations is different
expect(appIdentifier.instanceId, `The AppIdentifier's instanceId property for both instances of the opened app should not be the same.${findInstancesDocs}`).to.not.equal(appIdentifier2.instanceId);

Expand All @@ -45,7 +50,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 +71,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}`);
}
}
10 changes: 5 additions & 5 deletions src/test/v2.0/advanced/fdc3.findIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default () =>

it("(2.0-FindIntentAppDMultiple1) Should find intent 'sharedTestingIntent2' belonging to multiple apps (intent-a & intent-b)", async () => {
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2);
validateAppIntent(appIntent, 6, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent" }, IntentApp.IntentAppD);
validateAppIntent(appIntent, 6, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent 2" }, IntentApp.IntentAppD);
});

it("(IntentAppDMultiple2) Should find intent 'sharedTestingIntent2' belonging to multiple apps (intent-a & intent-b) filtered by specific context 'testContextY'", async () => {
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2, { type: ContextType.testContextY });
validateAppIntent(appIntent, 5, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent" }, IntentApp.IntentAppE);
validateAppIntent(appIntent, 5, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent 2" }, IntentApp.IntentAppE);
});

it("(2.0-FindIntentAppDByResultSingle) Should find intent 'cTestingIntent' belonging only to app intent-c with context 'testContextX' and result type 'testContextZ'", async () => {
Expand All @@ -61,17 +61,17 @@ export default () =>

it("(2.0-FindIntentAppDByResultMultiple) Should find intent 'sharedTestingIntent1' belonging only to app intent-b with context 'testContextX' and result type 'testContextY'", async () => {
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent1, { type: ContextType.testContextX }, ContextType.testContextY);
validateAppIntent(appIntent, 1, { name: Intent.sharedTestingIntent1, displayName: "Shared Testing Intent" }, IntentApp.IntentAppB);
validateAppIntent(appIntent, 1, { name: Intent.sharedTestingIntent1, displayName: "Shared Testing Intent 1" }, IntentApp.IntentAppB);
});

it("(2.0-FindIntentAppDByResultChannel1) Should find intent 'sharedTestingIntent2' belonging only to apps intent-e and itent-f with context 'testContextY' and result type 'channel", async () => {
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2, { type: ContextType.testContextY }, "channel");
validateAppIntent(appIntent, 2, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent" }, IntentApp.IntentAppE);
validateAppIntent(appIntent, 2, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent 2" }, IntentApp.IntentAppE);
});

it("(2.0-FindIntentAppDByResultChannel2) Should find intent 'sharedTestingIntent2' belonging only to app intent-c with context 'testContextY' and result type 'channel<testContextZ>'", async () => {
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2, { type: ContextType.testContextY }, "channel<testContextZ>");
validateAppIntent(appIntent, 1, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent" }, IntentApp.IntentAppF);
validateAppIntent(appIntent, 1, { name: Intent.sharedTestingIntent2, displayName: "Shared Testing Intent 2" }, IntentApp.IntentAppF);
});
});

Expand Down
Loading
Loading