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.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/advanced/fdc3.raiseIntent.ts b/src/test/v2.0/advanced/fdc3.raiseIntent.ts index f84b8c42..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(); @@ -103,7 +104,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 +113,14 @@ 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); + 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; - 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/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 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..5b007c49 100644 --- a/src/test/v2.0/support/intent-support-2.0.ts +++ b/src/test/v2.0/support/intent-support-2.0.ts @@ -82,7 +82,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; } diff --git a/src/test/v2.0/testSuite.ts b/src/test/v2.0/testSuite.ts index 50b07cb4..76311703 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,8 @@ 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); + (mocha as any).timeout(constants.ManualTimeout); const suite = allManualTests[pack]; console.log('************ found suite******', suite) suite.forEach((s) => s());