Skip to content

Commit

Permalink
Merge pull request #85 from finos/local-conformance
Browse files Browse the repository at this point in the history
Fixed Vassiliy's issue, added json file for local conformance testing
  • Loading branch information
nkolba authored Nov 10, 2022
2 parents 1102dd8 + 759235f commit 0f19756
Show file tree
Hide file tree
Showing 10 changed files with 386 additions and 201 deletions.
195 changes: 195 additions & 0 deletions directory/local-conformance-1_2.v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"applications": [
{
"appId": "ChannelsAppId",
"name": "ChannelsApp",
"title": "Channels App",
"description": "Part of the FDC3 1.2 Conformance Tests",
"type": "web",
"details": {
"url": "http://localhost:3103/index.html"
},
"hostManifests": {
"sail": {
"inject-api": "1.2",
"searchable": false
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
]
},
{
"appId": "Conformance1",
"name": "Conformance1",
"title": "FDC3 1.2 Conformance Framework",
"description": "Testing Conformance",
"type": "web",
"details": {
"url": "http://localhost:3000/index.html"
},
"screenshots": [
{
"src": "https://directory.fdc3.finos.org/assets/app/Conformance1.png"
}
],
"hostManifests": {
"sail": {
"inject-api": "1.2"
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
]
},
{
"appId": "IntentAppAId",
"name": "IntentAppA",
"title": "Intent App A",
"description": "Part of the FDC3 1.2 Conformance Tests",
"type": "web",
"details": {
"url": "http://localhost:3100/index.html"
},
"hostManifests": {
"sail": {
"inject-api": "1.2",
"searchable": false
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
],
"interop": {
"intents": {
"listensFor": {
"aTestingIntent": {
"displayName": "A Testing Intent",
"contexts": [
"testContextX",
"testContextZ"
]
},
"sharedTestingIntent1": {
"displayName": "Shared Testing Intent",
"contexts": [
"testContextX"
]
}
}
}
}
},
{
"appId": "IntentAppBId",
"name": "IntentAppB",
"title": "Intent App B",
"description": "Part of the FDC3 1.2 Conformance Tests",
"type": "web",
"details": {
"url": "http://localhost:3101/index.html"
},
"hostManifests": {
"sail": {
"inject-api": "1.2",
"searchable": false
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
],
"interop": {
"intents": {
"listensFor": {
"bTestingIntent": {
"displayName": "B Testing Intent",
"contexts": [
"testContextY"
]
},
"sharedTestingIntent1": {
"displayName": "Shared Testing Intent",
"contexts": [
"testContextX",
"testContextY"
]
}
}
}
}
},
{
"appId": "IntentAppCId",
"name": "IntentAppC",
"title": "Intent App C",
"description": "Part of the FDC3 1.2 Conformance Tests",
"type": "web",
"details": {
"url": "http://localhost:3102/index.html"
},
"hostManifests": {
"sail": {
"inject-api": "1.2",
"searchable": false
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
],
"interop": {
"intents": {
"listensFor": {
"cTestingIntent": {
"displayName": "C Testing Intent",
"contexts": [
"testContextX"
]
}
}
}
}
},
{
"appId": "MockAppId",
"name": "MockApp",
"description": "Testing spec conformance",
"details": {
"url": "http://localhost:3001/index.html"
},
"hostManifests": {
"sail": {
"inject-api": "1.2",
"searchable": false
}
},
"version": "1.0.0",
"publisher": "Scott Logic",
"icons": [
{
"src": "https://www.scottlogic.com/sites/default/files/scott-logic-favicon.jpg"
}
]
}
],
"message": "OK"
}
8 changes: 1 addition & 7 deletions packages/main/src/directory/fdc3-12-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const DEFAULT_1_2_MANIFEST: DirectoryAppSailManifest = {
const convertToDirectoryList = (data: AllApplicationsResponseV1) =>
data.applications?.map((a) => convertApp(a)) as DirectoryApp[];

const convertSingleApp = (data: DirectoryAppV1) =>
[convertApp(data)] as DirectoryApp[];

function convertIntents(intents: DirectoryIntentV1[]): {
[key: string]: DirectoryIntent;
} {
Expand Down Expand Up @@ -110,12 +107,9 @@ function convertApp(d: DirectoryAppV1): DirectoryApp {
export const fdc3_1_2_AppDirectoryLoader: Loader = (u: string) => {
let converter;

if (u.endsWith('/v1/apps') || u.endsWith('/v1/apps/')) {
if (u.includes('/v1/apps') || u.includes('.v1.json')) {
// whole directory
converter = convertToDirectoryList;
} else if (u.includes('/v1/apps')) {
// single app
converter = convertSingleApp;
} else {
// not handled by this loader
return new Promise((resolve) => {
Expand Down
7 changes: 1 addition & 6 deletions packages/main/src/directory/fdc3-20-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export type AllApplicationsResponse = schemas['AllApplicationsResponse'];

const convertToDirectoryList = (data: AllApplicationsResponse) =>
data.applications?.map(applyDefaults) as DirectoryApp[];
const convertSingleApp = (data: DirectoryApp) =>
[applyDefaults(data)] as DirectoryApp[];

function applyDefaults(d: DirectoryApp): DirectoryApp {
// first, check manifest is set
Expand Down Expand Up @@ -59,12 +57,9 @@ export function loadLocally(u: string) {
export const fdc3_2_0_AppDirectoryLoader: Loader = (u: string) => {
let converter;

if (u.endsWith('/v2/apps') || u.endsWith('/v2/apps/')) {
if (u.endsWith('/v2/apps') || u.includes('.v2.json')) {
// whole directory
converter = convertToDirectoryList;
} else if (u.includes('/v2/apps')) {
// single app
converter = convertSingleApp;
} else {
// not handled by this loader
return new Promise((resolve) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/main/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { FDC3EventDetail } from './types/FDC3Event';
const DEFAULT_DIRECTORY = 'https://directory.fdc3.finos.org/v2/apps';

const getDirectoryUrl = (): string => {
const dir = import.meta.env.SAIL_DIRECTORY_URL
? `${import.meta.env.SAIL_DIRECTORY_URL}`
: DEFAULT_DIRECTORY;
const envVar = process.env['SAIL_DIRECTORY_URL'];
const dir = envVar ? envVar : DEFAULT_DIRECTORY;
console.log('SAIL_DIRECTORY_URL: ' + dir);
return dir;
};
Expand Down
12 changes: 2 additions & 10 deletions packages/main/tests/directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@ import {
} from '../src/directory/directory';

const REMOTE_V2 = 'https://directory.fdc3.finos.org/v2/apps';
const LOCAL_V2 = 'tests/v2/apps/appd-record.v2.json';
const LOCAL_V1 = 'tests/v1/apps/appd-record.v1.json';
const LOCAL_V2 = 'tests/v2/apps/appd-records.v2.json';
const LOCAL_V1 = 'tests/v1/apps/appd-records.v1.json';

test('Test Remote Directory Load in FDC3 2.0 Format', async () => {
const results = await fdc3_2_0_AppDirectoryLoader(REMOTE_V2);
expect(results.length).toBeGreaterThan(3);
});

test('Test Single App Load in FDC3 2.0 Format', async () => {
const results = await fdc3_2_0_AppDirectoryLoader(
'https://directory.fdc3.finos.org/v2/apps/fdc3-workbench/',
);
expect(results.length).toEqual(1);
expect(results[0].appId).toEqual('fdc3-workbench');
});

test('Test Local App Load in FDC3 2.0 Format', async () => {
const results = await fdc3_2_0_AppDirectoryLoader(LOCAL_V2);
expect(results.length).toEqual(1);
Expand Down
29 changes: 0 additions & 29 deletions packages/main/tests/v1/apps/appd-record.v1.json

This file was deleted.

34 changes: 34 additions & 0 deletions packages/main/tests/v1/apps/appd-records.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"applications": [
{
"intents": [
{
"name": "ViewNews",
"displayName": "View News",
"contexts": [
"fdc3.instrument"
]
}
],
"icons": [
{
"icon": "https://newsapi.org/favicon-32x32.png"
}
],
"images": [
{
"url": "https://appd.kolbito.com/demos/news-demo/screen-1.png"
}
],
"start_url": "https://appd.kolbito.com/demos/news-demo/",
"appId": "News-Demo",
"description": "Demo fdc3 news feed using services from NewsAPI.org",
"name": "News-Demo",
"manifest_type": "web",
"title": "News Feed Demo",
"manifest": "undefined/manifests/News-Demo",
"icon": "https://newsapi.org/favicon-32x32.png"
}
],
"message": "OK"
}
Loading

0 comments on commit 0f19756

Please sign in to comment.