Skip to content

Commit e198b0f

Browse files
authored
Merge pull request #1767 from finos/conformance-qualified-ids
Support fully qualified app ids to be returned by desktop agent and not fail conformance tests
2 parents a6c0870 + 9308ecd commit e198b0f

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4242
* Updated .NET API documentation for IListener.Unsubscribe to be async for 2.2 and current. ([#1690](https://github.com/finos/FDC3/pull/1690))
4343
* Fix for channel change listeners not sending addEventListenerRequests ([#1606](https://github.com/finos/FDC3/pull/1606))
4444
* Fix to ensure that Adding A Channel Change Event Listener Doesn't Send addEventListenerRequest - Conformance 2.2 ([#1606](https://github.com/finos/FDC3/pull/1606))
45+
* Updated Conformance tests to allow agents that fully qualify app Ids (as recommended in the Standard) to pass the conformance tests ([#1767](https://github.com/finos/FDC3/pull/1767))
4546

4647
## [FDC3 Standard 2.2](https://github.com/finos/FDC3/compare/v2.1..v2.2) - 2025-03-12
4748

toolbox/fdc3-conformance/src/mock/general.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { closeWindowOnCompletion, sendContextToTests } from './mock-functions';
22
import { getAgent, Context } from '@finos/fdc3';
33
import { AppControlContext } from '../context-types';
4+
import { appIdMatches } from '../utils';
45

56
getAgent().then(async fdc3 => {
67
await closeWindowOnCompletion(fdc3);
@@ -13,7 +14,7 @@ getAgent().then(async fdc3 => {
1314
type: 'fdc3-conformance-opened',
1415
};
1516

16-
if (appId !== 'MockAppId') {
17+
if (!appIdMatches(appId, 'MockAppId')) {
1718
appOpenedContext.errorMessage = `Incorrect appId retrieved from getInfo(). Expected MockAppId, got ${appId}`;
1819
}
1920

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AppIntent, IntentMetadata, ResolveError, DesktopAgent } from '@finos/fd
22
import { assert, expect } from 'chai';
33
import { APIDocumentation } from '../support/apiDocuments';
44
import { ContextType, IntentApp, Intent } from '../support/intent-support';
5+
import { appIdMatches } from '../../utils';
56

67
declare let fdc3: DesktopAgent;
78
const findIntentDocs = '\r\nDocumentation: ' + APIDocumentation.findIntent + '\r\nCause';
@@ -163,6 +164,10 @@ function validateAppIntent(
163164
expect(
164165
appIntent.apps[index],
165166
`AppIntent.apps[${index}] did not have expected property 'appId' ${findIntentDocs}`
166-
).to.have.property('appId', appId);
167+
).to.have.property('appId');
168+
expect(
169+
appIdMatches(appIntent.apps[index].appId, appId),
170+
`AppIntent.apps[${index}].appId '${appIntent.apps[index].appId}' did not match expected '${appId}' ${findIntentDocs}`
171+
).to.be.true;
167172
});
168173
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assert, expect } from 'chai';
33
import { APIDocumentation } from '../support/apiDocuments';
44
import { DesktopAgent } from '@finos/fdc3';
55
import { ContextType, IntentApp, Intent } from '../support/intent-support';
6-
import { handleFail } from '../../utils';
6+
import { appIdMatches, handleFail } from '../../utils';
77

88
declare let fdc3: DesktopAgent;
99
const findIntentsByContextDocs = '\r\nDocumentation: ' + APIDocumentation.findIntentsByContext;
@@ -59,7 +59,10 @@ function validateIntents(
5959
assert.isDefined(firstIntent);
6060
if (firstIntent !== undefined) {
6161
expect(firstIntent.apps).to.have.length(expectedAppCount);
62-
const sharedAppNames = firstIntent.apps.map(app => app.appId);
63-
expect(sharedAppNames).to.have.all.members(expectedAppIds);
62+
const sharedAppIds = firstIntent.apps.map(app => app.appId);
63+
const missingAppIds = expectedAppIds.filter(
64+
expected => !sharedAppIds.some(received => appIdMatches(received, expected))
65+
);
66+
expect(missingAppIds, `Expected app IDs not found in [${sharedAppIds.join(', ')}]`).to.be.empty;
6467
}
6568
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { OpenControlImpl } from '../support/open-support';
55
import { DesktopAgent, getAgent } from '@finos/fdc3';
66
import { assert, expect } from 'chai';
77
import { ControlContextType } from '../support/intent-support';
8+
import { appIdMatches } from '../../utils';
89

910
const documentation = '\r\nDocumentation: ' + APIDocumentation + '\r\nCause:';
1011

@@ -99,7 +100,7 @@ export default async () => {
99100
const result = control.contextReceiver('fdc3-conformance-opened');
100101
const targetApp = { appId: openApp.b.id };
101102
const instanceIdentifier = await control.openMockApp(targetApp);
102-
expect(instanceIdentifier.appId).to.eq(openApp.b.id);
103+
expect(appIdMatches(instanceIdentifier.appId, openApp.b.id)).to.be.true;
103104
expect(instanceIdentifier).to.have.property('instanceId');
104105
await result;
105106
await control.closeMockApp(AOpensB4);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@finos/fdc3';
1313
import { APIDocumentation } from './apiDocuments';
1414
import constants from '../../constants';
15-
import { handleFail, wait, wrapPromise } from '../../utils';
15+
import { appIdMatches, handleFail, wait, wrapPromise } from '../../utils';
1616
import { AppControlContext, IntentUtilityContext } from '../../context-types';
1717

1818
const raiseIntentDocs = '\r\nDocumentation: ' + APIDocumentation.raiseIntent + '\r\nCause';
@@ -194,7 +194,7 @@ export class RaiseIntentControl {
194194
expect(intentResolution.source as AppIdentifier).to.have.property('instanceId');
195195
expect(typeof intentResolution.source.instanceId).to.be.equal('string');
196196
expect(intentResolution.source.instanceId).to.not.be.equal('');
197-
expect((intentResolution.source as AppIdentifier).appId).to.eq(appId, raiseIntentDocs);
197+
expect(appIdMatches(intentResolution.source.appId, appId), raiseIntentDocs).to.be.true;
198198
} else assert.fail('Invalid intent resolution object');
199199
};
200200

toolbox/fdc3-conformance/src/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ export function handleFail(documentation: string, ex: unknown): never {
4141
const message = ex instanceof Error ? ex.message : String(ex);
4242
assert.fail(documentation + message);
4343
}
44+
45+
/**
46+
* Checks whether a received appId matches an expected unqualified appId.
47+
* Accepts either an exact match (e.g. 'MockAppId') or a fully qualified
48+
* appId with the current hostname (e.g. 'MockAppId@localhost').
49+
*/
50+
export function appIdMatches(received: string, expected: string): boolean {
51+
if (received === expected) {
52+
return true;
53+
}
54+
55+
return received.split('@')[0] === expected.split('@')[0];
56+
}

0 commit comments

Comments
 (0)