From ed6f32d823cd0de4b54670d88d33a16dfadec9e5 Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Mon, 16 Sep 2024 15:52:18 +0100 Subject: [PATCH 1/5] Fixing display names issue --- src/test/v2.0/advanced/fdc3.findIntent.ts | 12 +- src/test/v2.0/manual/fdc3.manual.ts | 147 +++++++++++----------- 2 files changed, 79 insertions(+), 80 deletions(-) diff --git a/src/test/v2.0/advanced/fdc3.findIntent.ts b/src/test/v2.0/advanced/fdc3.findIntent.ts index 6819bd63..0f632e9a 100644 --- a/src/test/v2.0/advanced/fdc3.findIntent.ts +++ b/src/test/v2.0/advanced/fdc3.findIntent.ts @@ -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 () => { @@ -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'", async () => { const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2, { type: ContextType.testContextY }, "channel"); - 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); }); }); @@ -93,4 +93,4 @@ function validateAppIntent(appIntent: AppIntent, expectedNumberOfApps: number, e appsThatNeedValidating.forEach((appId, index) => { expect(appIntent.apps[index], `AppIntent.apps[${index}] did not have expected property 'appId' ${findIntentDocs}`).to.have.property("appId", appId); }); -} +} \ No newline at end of file diff --git a/src/test/v2.0/manual/fdc3.manual.ts b/src/test/v2.0/manual/fdc3.manual.ts index 547015ef..47869d5a 100644 --- a/src/test/v2.0/manual/fdc3.manual.ts +++ b/src/test/v2.0/manual/fdc3.manual.ts @@ -1,10 +1,9 @@ -import { ResolveError, DesktopAgent } from "fdc3_2_0"; +import { DesktopAgent } from "fdc3_2_0"; import { closeMockAppWindow } from "../fdc3-2_0-utils"; import { assert, expect } from "chai"; import { APIDocumentation2_0 } from "../apiDocuments-2.0"; import { ContextType, IntentApp, Intent, RaiseIntentControl2_0 } from "../support/intent-support-2.0"; -import constants from "../../../constants"; import { wait } from "../../../utils"; @@ -19,81 +18,81 @@ declare let fdc3: DesktopAgent; */ export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("ResolveAmbiguousIntentTarget_2.0", () => { - after(async function after() { - await closeMockAppWindow(this.currentTest.title); - }); - const ResolveAmbiguousIntentTarget = "(ResolveAmbiguousIntentTarget) Should be able to raise intent using Intent and Context and manually select an app out of 'E','F','G','H' and 'I'"; - it(ResolveAmbiguousIntentTarget, async () => { - try { - const context = { - type: ContextType.testContextY, - }; - await fdc3.raiseIntent(Intent.sharedTestingIntent2, context); - } catch (ex) { - assert.fail(raiseIntentDocs + (ex.message ?? ex)); - } - }); + after(async function after() { + await closeMockAppWindow(this.currentTest.title); }); + const ResolveAmbiguousIntentTarget = "(ResolveAmbiguousIntentTarget) Should be able to raise intent using Intent and Context and manually select an app out of 'E','F','G','H' and 'I'"; + it(ResolveAmbiguousIntentTarget, async () => { + try { + const context = { + type: ContextType.testContextY, + }; + await fdc3.raiseIntent(Intent.sharedTestingIntent2, context); + } catch (ex) { + assert.fail(raiseIntentDocs + (ex.message ?? ex)); + } + }); +}); + +export let fdc3ResolveAmbiguousContextTarget_2_0 = () => describe("ResolveAmbiguousContextTarget_2.0", () => { + after(async function after() { + await closeMockAppWindow(this.currentTest.title); + }); + const ResolveAmbiguousIntentTarget = "(ResolveAmbiguousContextTarget) Should be able to raise intent using ContextY and manually select an app out of 'E','F','G','H' and 'I'"; + it(ResolveAmbiguousIntentTarget, async () => { + try { + const context = { + type: ContextType.testContextY, + }; + await fdc3.raiseIntentForContext(context); + } catch (ex) { + assert.fail(raiseIntentDocs + (ex.message ?? ex)); + } + }); +}); - export let fdc3ResolveAmbiguousContextTarget_2_0 = () => describe("ResolveAmbiguousContextTarget_2.0", () => { - after(async function after() { - await closeMockAppWindow(this.currentTest.title); - }); - const ResolveAmbiguousIntentTarget = "(ResolveAmbiguousContextTarget) Should be able to raise intent using ContextY and manually select an app out of 'E','F','G','H' and 'I'"; - it(ResolveAmbiguousIntentTarget, async () => { - try { - const context = { - type: ContextType.testContextY, - }; - await fdc3.raiseIntentForContext(context); - } catch (ex) { - assert.fail(raiseIntentDocs + (ex.message ?? ex)); - } - }); +export let fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousIntentTargetMultiInstance_2.0", () => { + after(async function after() { + await closeMockAppWindow(this.currentTest.title); }); + const ResolveAmbiguousIntentTargetMultiInstance = "(ResolveAmbiguousIntentTargetMultiInstance) Open 2 instances of App E and AppF respectively and then should be able to raise intent using Intent and Context and manually select an app out of 'E','F','G','H' and 'I'"; + it(ResolveAmbiguousIntentTargetMultiInstance, async () => { + try { + const context = { + type: ContextType.testContextY, + }; + await control.openIntentApp(IntentApp.IntentAppE); + await control.openIntentApp(IntentApp.IntentAppE); + await control.openIntentApp(IntentApp.IntentAppF); + await control.openIntentApp(IntentApp.IntentAppF); + await wait(100); - export let fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousIntentTargetMultiInstance_2.0", () => { - after(async function after() { - await closeMockAppWindow(this.currentTest.title); - }); - const ResolveAmbiguousIntentTargetMultiInstance = "(ResolveAmbiguousIntentTargetMultiInstance) Open 2 instances of App E and AppF respectively and then should be able to raise intent using Intent and Context and manually select an app out of 'E','F','G','H' and 'I'"; - it(ResolveAmbiguousIntentTargetMultiInstance, async () => { - try { - const context = { - type: ContextType.testContextY, - }; - await control.openIntentApp(IntentApp.IntentAppE); - await control.openIntentApp(IntentApp.IntentAppE); - await control.openIntentApp(IntentApp.IntentAppF); - await control.openIntentApp(IntentApp.IntentAppF); - await wait(100); - - await fdc3.raiseIntent(Intent.sharedTestingIntent2, context); - } catch (ex) { - assert.fail(raiseIntentDocs + (ex.message ?? ex)); - } - }); + await fdc3.raiseIntent(Intent.sharedTestingIntent2, context); + } catch (ex) { + assert.fail(raiseIntentDocs + (ex.message ?? ex)); + } }); +}); - export let fdc3ResolveAmbiguousContextTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousContextTargetMultiInstance_2.0", () => { - after(async function after() { - await closeMockAppWindow(this.currentTest.title); - }); - const ResolveAmbiguousContextTargetMultiInstance = "(ResolveAmbiguousContextTargetMultiInstance) Open 2 instances of App E and AppF respectively and then should be able to raise intent using Context and manually select an app out of 'E','F','G','H' and 'I'"; - it(ResolveAmbiguousContextTargetMultiInstance, async () => { - try { - const context = { - type: ContextType.testContextY, - }; - await control.openIntentApp(IntentApp.IntentAppE); - await control.openIntentApp(IntentApp.IntentAppE); - await control.openIntentApp(IntentApp.IntentAppF); - await control.openIntentApp(IntentApp.IntentAppF); - await wait(100); - - await fdc3.raiseIntentForContext(context); - } catch (ex) { - assert.fail(raiseIntentDocs + (ex.message ?? ex)); - } - }); - }); \ No newline at end of file +export let fdc3ResolveAmbiguousContextTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousContextTargetMultiInstance_2.0", () => { + after(async function after() { + await closeMockAppWindow(this.currentTest.title); + }); + const ResolveAmbiguousContextTargetMultiInstance = "(ResolveAmbiguousContextTargetMultiInstance) Open 2 instances of App E and AppF respectively and then should be able to raise intent using Context and manually select an app out of 'E','F','G','H' and 'I'"; + it(ResolveAmbiguousContextTargetMultiInstance, async () => { + try { + const context = { + type: ContextType.testContextY, + }; + await control.openIntentApp(IntentApp.IntentAppE); + await control.openIntentApp(IntentApp.IntentAppE); + await control.openIntentApp(IntentApp.IntentAppF); + await control.openIntentApp(IntentApp.IntentAppF); + await wait(100); + + await fdc3.raiseIntentForContext(context); + } catch (ex) { + assert.fail(raiseIntentDocs + (ex.message ?? ex)); + } + }); +}); \ No newline at end of file From bffcd5ca2baa09cbe21d725e9bc111410c5c0c5d Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Mon, 16 Sep 2024 15:53:05 +0100 Subject: [PATCH 2/5] Removed timeout on manual tests --- src/test/v2.0/testSuite.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/v2.0/testSuite.ts b/src/test/v2.0/testSuite.ts index 50b07cb4..f02e59fe 100644 --- a/src/test/v2.0/testSuite.ts +++ b/src/test/v2.0/testSuite.ts @@ -10,8 +10,8 @@ import fdc3Open_2_0 from "./advanced/fdc3.open"; import fdc3RaiseIntent_2_0 from "./advanced/fdc3.raiseIntent"; import fdc3RaiseIntent_2_0_Result from "./advanced/fdc3.raiseIntent-Result"; import fdc3RaiseIntent_2_0_NoAppsFound from "./advanced/fdc3.raiseIntent-NoAppsFound"; -import {fdc3BasicCL1_2_0, fdc3BasicCL2_2_0, fdc3BasicIL1_2_0, fdc3BasicGI1_2_0 , fdc3BasicAC1_2_0 , fdc3BasicUC1_2_0, fdc3BasicJC1_2_0, fdc3BasicRI1_2_0, fdc3BasicRI2_2_0 } from './basic/fdc3.basic'; -import {fdc3ResolveAmbiguousIntentTarget_2_0, fdc3ResolveAmbiguousContextTarget_2_0, fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0, fdc3ResolveAmbiguousContextTargetMultiInstance_2_0} from './manual/fdc3.manual'; +import { fdc3BasicCL1_2_0, fdc3BasicCL2_2_0, fdc3BasicIL1_2_0, fdc3BasicGI1_2_0, fdc3BasicAC1_2_0, fdc3BasicUC1_2_0, fdc3BasicJC1_2_0, fdc3BasicRI1_2_0, fdc3BasicRI2_2_0 } from './basic/fdc3.basic'; +import { fdc3ResolveAmbiguousIntentTarget_2_0, fdc3ResolveAmbiguousContextTarget_2_0, fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0, fdc3ResolveAmbiguousContextTargetMultiInstance_2_0 } from './manual/fdc3.manual'; type testSet = { [key: string]: (() => void)[] }; @@ -22,7 +22,7 @@ const basicSuite_2_0: testSet = { "fdc3.basicGI1 2.0": [fdc3BasicGI1_2_0], "fdc3.basicAC1 2.0": [fdc3BasicAC1_2_0], "fdc3.basicUC1 2.0": [fdc3BasicUC1_2_0], - "fdc3.basicJC1 2.0": [fdc3BasicJC1_2_0], + "fdc3.basicJC1 2.0": [fdc3BasicJC1_2_0], "fdc3.basicRI1 2.0": [fdc3BasicRI1_2_0], "fdc3.basicRI2 2.0": [fdc3BasicRI2_2_0], }; @@ -98,8 +98,7 @@ export const executeTestsInBrowser = (pack: string) => { * in HTML page */ export const executeManualTestsInBrowser = (pack: string) => { - console.log('Pack',pack); - (mocha as any).timeout(constants.TestTimeout); + console.log('Pack', pack); const suite = allManualTests[pack]; console.log('************ found suite******', suite) suite.forEach((s) => s()); From 4ea37681c7921bb3d99c2eceeca8449f7d0715fd Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Mon, 16 Sep 2024 15:59:27 +0100 Subject: [PATCH 3/5] Changed manual test timeout --- src/constants.ts | 1 + src/test/v2.0/advanced/fdc3.raiseIntent.ts | 9 +++++---- src/test/v2.0/testSuite.ts | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 537b3123..5263a15f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -5,6 +5,7 @@ const constants = { ShortWait: 1000, Fdc3Timeout: 500, // The amount of time to wait for the FDC3Ready event during initialisation TestTimeout: 20000, // Tests that take longer than this (in milliseconds) will fail + ManualTimeout: 100000, // Manual tests that take longer than this (in milliseconds) will fail WaitTime: 5000, // The amount of time to wait for mock apps to finish processing WindowCloseWaitTime: 1000, // The amount of time to allow for clean-up of closed windows NoListenerTimeout: 120000, // the amount of time to allow for a DA to timeout waiting on a context or intent listener diff --git a/src/test/v2.0/advanced/fdc3.raiseIntent.ts b/src/test/v2.0/advanced/fdc3.raiseIntent.ts index f84b8c42..84de12df 100644 --- a/src/test/v2.0/advanced/fdc3.raiseIntent.ts +++ b/src/test/v2.0/advanced/fdc3.raiseIntent.ts @@ -103,7 +103,7 @@ export default () => const PrivateChannelsLifecycleEvents = "(2.0-PrivateChannelsLifecycleEvents) PrivateChannel lifecycle events are triggered when expected"; it(PrivateChannelsLifecycleEvents, async () => { errorListener = await control.listenForError(); - let onUnsubscribeReceiver = control.receiveContext(ControlContextType.onUnsubscribeTriggered); + const onUnsubscribeReceiver = control.receiveContext(ControlContextType.onUnsubscribeTriggered); const intentResolution = await control.raiseIntent(Intent.kTestingIntent, ContextType.testContextX, { appId: IntentApp.IntentAppK, }); @@ -112,12 +112,13 @@ export default () => control.validateIntentResult(result, IntentResultType.PrivateChannel); let listener = await control.receiveContextStreamFromMockApp(result, 1, 5); control.unsubscribeListener(listener); + await onUnsubscribeReceiver; //should receive context from privChannel.onUnsubscribe in mock app - let textContextXReceiver = control.receiveContext(ContextType.testContextX); + const textContextXReceiver = control.receiveContext(ContextType.testContextX); control.privateChannelBroadcast(result, ContextType.testContextX); await textContextXReceiver; - let onUnsubscribeReceiver2 = control.receiveContext(ControlContextType.onUnsubscribeTriggered); - let onDisconnectReceiver = control.receiveContext(ControlContextType.onDisconnectTriggered); + const onUnsubscribeReceiver2 = control.receiveContext(ControlContextType.onUnsubscribeTriggered); + const onDisconnectReceiver = control.receiveContext(ControlContextType.onDisconnectTriggered); let listener2 = await control.receiveContextStreamFromMockApp(result, 6, 10); control.disconnectPrivateChannel(result); diff --git a/src/test/v2.0/testSuite.ts b/src/test/v2.0/testSuite.ts index f02e59fe..76311703 100644 --- a/src/test/v2.0/testSuite.ts +++ b/src/test/v2.0/testSuite.ts @@ -99,6 +99,7 @@ export const executeTestsInBrowser = (pack: string) => { */ export const executeManualTestsInBrowser = (pack: string) => { console.log('Pack', pack); + (mocha as any).timeout(constants.ManualTimeout); const suite = allManualTests[pack]; console.log('************ found suite******', suite) suite.forEach((s) => s()); From b3208836af7cfaddd9fd316ff17230a7288781e7 Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Tue, 17 Sep 2024 15:23:09 +0100 Subject: [PATCH 4/5] potential fix for promises resolving in wrong order. --- src/test/v2.0/support/intent-support-2.0.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/test/v2.0/support/intent-support-2.0.ts b/src/test/v2.0/support/intent-support-2.0.ts index bac5f9d4..3f293b10 100644 --- a/src/test/v2.0/support/intent-support-2.0.ts +++ b/src/test/v2.0/support/intent-support-2.0.ts @@ -12,19 +12,23 @@ export class RaiseIntentControl2_0 { async receiveContext(contextType: string, waitTime?: number): Promise { let timeout; const appControlChannel = await getOrCreateChannel(constants.ControlChannel); - return new Promise(async (resolve, reject) => { - const listener = await appControlChannel.addContextListener(contextType, (context: AppControlContext) => { - resolve(context); - clearTimeout(timeout); - listener.unsubscribe(); - }); - + var doResolve = null; + const out = new Promise(async (resolve, reject) => { + doResolve = resolve; //if no context received reject promise const { promise: sleepPromise, timeout: theTimeout } = sleep(waitTime ?? constants.WaitTime); timeout = theTimeout; await sleepPromise; reject(new Error("No context received. Listener expected to receive context of type " + contextType + " from mock app")); }); + + const listener = await appControlChannel.addContextListener(contextType, (context: AppControlContext) => { + doResolve(context); + clearTimeout(timeout); + listener.unsubscribe(); + }); + + return out } async openIntentApp(appId): Promise { @@ -82,7 +86,7 @@ export class RaiseIntentControl2_0 { const intentResult = intentResolution.getResult(); if (typeof intentResult.then !== "function") { assert.fail(`intentResolution.getResult() did not return a Promise: ${JSON.stringify(intentResult, null, 2)}`); - } + } clearTimeout(timeout); return intentResult; } From 03df2de5a38e96a960097fc7f993440e34df32ba Mon Sep 17 00:00:00 2001 From: Rob Moffat Date: Tue, 17 Sep 2024 15:27:35 +0100 Subject: [PATCH 5/5] Fix for race condition --- src/test/v2.0/advanced/fdc3.raiseIntent.ts | 2 ++ src/test/v2.0/support/intent-support-2.0.ts | 18 +++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/test/v2.0/advanced/fdc3.raiseIntent.ts b/src/test/v2.0/advanced/fdc3.raiseIntent.ts index 84de12df..f041fa10 100644 --- a/src/test/v2.0/advanced/fdc3.raiseIntent.ts +++ b/src/test/v2.0/advanced/fdc3.raiseIntent.ts @@ -2,6 +2,7 @@ import { ChannelError, PrivateChannel, Listener } from "fdc3_2_0"; import { assert, expect } from "chai"; import { RaiseIntentControl2_0, IntentResultType, IntentApp, ContextType, Intent, ControlContextType } from "../support/intent-support-2.0"; import { closeMockAppWindow } from "../fdc3-2_0-utils"; +import { wait } from "../../../utils"; const control = new RaiseIntentControl2_0(); @@ -115,6 +116,7 @@ export default () => await onUnsubscribeReceiver; //should receive context from privChannel.onUnsubscribe in mock app const textContextXReceiver = control.receiveContext(ContextType.testContextX); + await wait(300) // ADDED DUE TO RACE CONDITION in intent-support-2.0.ts/receiveContext on line 12. control.privateChannelBroadcast(result, ContextType.testContextX); await textContextXReceiver; const onUnsubscribeReceiver2 = control.receiveContext(ControlContextType.onUnsubscribeTriggered); diff --git a/src/test/v2.0/support/intent-support-2.0.ts b/src/test/v2.0/support/intent-support-2.0.ts index 3f293b10..5b007c49 100644 --- a/src/test/v2.0/support/intent-support-2.0.ts +++ b/src/test/v2.0/support/intent-support-2.0.ts @@ -12,23 +12,19 @@ export class RaiseIntentControl2_0 { async receiveContext(contextType: string, waitTime?: number): Promise { let timeout; const appControlChannel = await getOrCreateChannel(constants.ControlChannel); - var doResolve = null; - const out = new Promise(async (resolve, reject) => { - doResolve = resolve; + return new Promise(async (resolve, reject) => { + const listener = await appControlChannel.addContextListener(contextType, (context: AppControlContext) => { + resolve(context); + clearTimeout(timeout); + listener.unsubscribe(); + }); + //if no context received reject promise const { promise: sleepPromise, timeout: theTimeout } = sleep(waitTime ?? constants.WaitTime); timeout = theTimeout; await sleepPromise; reject(new Error("No context received. Listener expected to receive context of type " + contextType + " from mock app")); }); - - const listener = await appControlChannel.addContextListener(contextType, (context: AppControlContext) => { - doResolve(context); - clearTimeout(timeout); - listener.unsubscribe(); - }); - - return out } async openIntentApp(appId): Promise {