Skip to content

Commit cbe12d2

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

11 files changed

Lines changed: 2088 additions & 1930 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.findIntentsByContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@ export default async () =>
1616
it("(FindIntentByContextSingleContext) Should find intents by context 'testContextX'", async () => {
1717
try {
1818
const intents = await fdc3.findIntentsByContext({ type: ContextType.testContextX });
19-
expect(intents).to.have.length(5);
19+
expect(intents).to.have.length(6);
2020
const intentNames = intents.map(appIntent => appIntent.intent.name);
2121
expect(intentNames).to.have.all.members([
2222
Intent.aTestingIntent,
2323
Intent.sharedTestingIntent1,
2424
Intent.cTestingIntent,
2525
Intent.sharedTestingIntent2,
2626
Intent.kTestingIntent,
27+
Intent.lTestingIntent,
2728
]);
2829

2930
validateIntents(intents, Intent.aTestingIntent, 1, [IntentApp.IntentAppA]);
3031
validateIntents(intents, Intent.sharedTestingIntent1, 2, [IntentApp.IntentAppA, IntentApp.IntentAppB]);
3132
validateIntents(intents, Intent.cTestingIntent, 1, [IntentApp.IntentAppC]);
3233
validateIntents(intents, Intent.sharedTestingIntent2, 1, [IntentApp.IntentAppD]);
3334
validateIntents(intents, Intent.kTestingIntent, 1, [IntentApp.IntentAppK]);
35+
validateIntents(intents, Intent.lTestingIntent, 1, [IntentApp.IntentAppL]);
3436
} catch (ex) {
3537
handleFail(findIntentsByContextDocs, ex);
3638
}

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',

toolbox/fdc3-conformance/src/test/support/intent-support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export enum Intent {
326326
bTestingIntent = 'bTestingIntent',
327327
cTestingIntent = 'cTestingIntent',
328328
kTestingIntent = 'kTestingIntent',
329-
lTestingIntent = 'LTestingIntent',
329+
lTestingIntent = 'lTestingIntent',
330330
sharedTestingIntent1 = 'sharedTestingIntent1',
331331
sharedTestingIntent2 = 'sharedTestingIntent2',
332332
privateChannelIsPrivate = 'privateChannelIsPrivate',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html lang="en">
2+
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="stylesheet" href="../../lib/index.css" />
6+
</head>
7+
8+
<body>
9+
<p>Conformance Framework Mock Intent App L</p>
10+
<p>This app is only used by the conformance framework for intent context metadata test purposes.</p>
11+
<script src="../../lib/intent-l.js"></script>
12+
13+
</body>
14+
15+
</html>

0 commit comments

Comments
 (0)