Skip to content

Commit 5ecfb51

Browse files
committed
Resolving issues with findIntent conformance tests cause by context metadata test additions
1 parent 8b6c7ad commit 5ecfb51

6 files changed

Lines changed: 1030 additions & 970 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { closeWindowOnCompletion, sendContextToTests, validateContext } from './mock-functions';
2+
import { getAgent } from '@finos/fdc3';
3+
import { IntentUtilityContext } from '../context-types';
4+
import { ContextMetadata, IntentResult } from '@finos/fdc3';
5+
import { ContextType, ControlContextType, Intent } from '../test/support/intent-support';
6+
7+
// Used in 'IntentContextMetadata' and 'IntentContextMetadataWithAppMetadata' conformance tests
8+
getAgent().then(async fdc3 => {
9+
await closeWindowOnCompletion(fdc3);
10+
11+
fdc3.addIntentListener(
12+
Intent.lTestingIntent,
13+
async (context: IntentUtilityContext, metadata?: ContextMetadata): Promise<IntentResult> => {
14+
validateContext(fdc3, context.type, ContextType.testContextX);
15+
16+
const { appMetadata } = await fdc3.getInfo();
17+
18+
const controlContext: Record<string, unknown> = {
19+
type: ControlContextType.A_TESTING_INTENT_LISTENER_TRIGGERED,
20+
instanceId: appMetadata.instanceId,
21+
};
22+
23+
if (metadata) {
24+
controlContext.contextMetadata = {
25+
source: metadata.source,
26+
timestamp: metadata.timestamp instanceof Date ? metadata.timestamp.toISOString() : String(metadata.timestamp),
27+
traceId: metadata.traceId,
28+
signature: metadata.signature,
29+
custom: metadata.custom,
30+
};
31+
}
32+
33+
await sendContextToTests(fdc3, controlContext as unknown as IntentUtilityContext);
34+
35+
return;
36+
}
37+
);
38+
});

toolbox/fdc3-conformance/src/test/advanced/fdc3.findIntent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default async () =>
6060
);
6161
});
6262

63-
it("(IntentAppDMultiple2) Should find intent 'sharedTestingIntent2' belonging to multiple apps (intent-a & intent-b) filtered by specific context 'testContextY'", async () => {
63+
it("(FindIntentAppDMultiple2) Should find intent 'sharedTestingIntent2' belonging to multiple apps (intent-a & intent-b) filtered by specific context 'testContextY'", async () => {
6464
const appIntent = await fdc3.findIntent(Intent.sharedTestingIntent2, { type: ContextType.testContextY });
6565
validateAppIntent(
6666
appIntent,

toolbox/fdc3-conformance/src/test/advanced/fdc3.intent-context-metadata.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export default async () => {
3232
}
3333
);
3434

35-
const resolution = await control.raiseIntent(Intent.aTestingIntent, ContextType.testContextX, {
36-
appId: IntentApp.IntentAppA,
35+
const resolution = await control.raiseIntent(Intent.lTestingIntent, ContextType.testContextX, {
36+
appId: IntentApp.IntentAppL,
3737
});
38-
control.validateIntentResolution(IntentApp.IntentAppA, resolution);
38+
control.validateIntentResolution(IntentApp.IntentAppL, resolution);
3939

4040
await wrapper.promise;
4141
listener.unsubscribe();
@@ -65,9 +65,9 @@ export default async () => {
6565
// Raise intent with app-provided metadata
6666
const context = { type: ContextType.testContextX };
6767
await fdc3.raiseIntent(
68-
Intent.aTestingIntent,
68+
Intent.lTestingIntent,
6969
context,
70-
{ appId: IntentApp.IntentAppA },
70+
{ appId: IntentApp.IntentAppL },
7171
{
7272
traceId: 'intent-trace-456',
7373
signature: 'intent-sig',

0 commit comments

Comments
 (0)