Skip to content

Commit

Permalink
Revert tests back, to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jlacivita committed May 2, 2024
1 parent 1d300c4 commit 2c5bc23
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 151 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/sdks/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
},
"type": "module",
"scripts": {
"validate": "npx firebolt-openrpc validate --input ./dist/firebolt-open-rpc.json",
"sdk": "npx firebolt-openrpc sdk --server ./dist/firebolt-open-rpc.json --client ./dist/firebolt-app-open-rpc.json --template ./src/js --output ./build/javascript/src",
"native": "npx firebolt-openrpc sdk --server ./dist/firebolt-open-rpc.json --client ./dist/firebolt-app-open-rpc.json --template ./src/cpp --output ./build/c/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/cpp",
"validate": "npx firebolt-openrpc validate --input ./dist/firebolt-core-open-rpc.json",
"sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-core-open-rpc.json --template ./src/js --output ./build/javascript/src --static-module Platform",
"native": "npx firebolt-openrpc sdk --input ./dist/firebolt-core-open-rpc.json --template ./src/cpp --output ./build/c/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/c",
"compile": "cd ../../.. && npm run compile",
"slice": "npm run slice:server; npm run slice:client",
"slice:server": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-open-rpc.json",
Expand Down
2 changes: 1 addition & 1 deletion src/sdks/core/src/js/sdk/Device/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

function version() {
return new Promise( (resolve, reject) => {
Gateway.request('Device.version').then( v => {
Transport.send('device', 'version').then( v => {
v = v || {}
v.sdk = v.sdk || {}
v.sdk.major = parseInt('${major}')
Expand Down
6 changes: 3 additions & 3 deletions src/sdks/core/src/js/sdk/Lifecycle/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const store = {

async function ready() {
let readyRes;
prioritize('Lifecycle', (event, value) => {
await prioritize('Lifecycle', (event, value) => {
store._current = event
})
readyRes = await Gateway.request('Lifecycle.ready', {})
readyRes =await Transport.send('lifecycle', 'ready', {})
setTimeout(_ => {
logReady()
})
Expand All @@ -49,7 +49,7 @@ function state() {

function finished() {
if (store.current === 'unloading') {
return Gateway.request('Lifecycle.finished')
return Transport.send('lifecycle', 'finished')
} else {
throw 'Cannot call finished() except when in the unloading transition'
}
Expand Down
6 changes: 3 additions & 3 deletions src/sdks/core/src/js/sdk/Metrics/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
/* ${INITIALIZATION} */

function ready() {
return Gateway.request('Metrics.ready', {})
return Transport.send('metrics', 'ready', {})
}

function signIn() {
return Gateway.request('Metrics.signIn', {})
return Transport.send('metrics', 'signIn', {})
}

function signOut() {
return Gateway.request('Metrics.signOut', {})
return Transport.send('metrics', 'signOut', {})
}


Expand Down
6 changes: 3 additions & 3 deletions src/sdks/core/test/suite/declarations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Setup from "../../../../../test/Setup"
import { sent } from "../../../../../test/Setup"

import { test, expect } from "@jest/globals"
import { Lifecycle, Device, Discovery, Entertainment } from "../../build/javascript/src/firebolt";
import { Lifecycle, Device, Discovery } from "../../build/javascript/src/firebolt";

let listenerId:number

Expand Down Expand Up @@ -39,7 +39,7 @@ const result: Discovery.EntityInfoResult = {
"identifiers": {
"entityId": "123"
},
"programType": Entertainment.ProgramType.MOVIE,
"programType": Discovery.ProgramType.MOVIE,
"title": "A title"
},
"expires": ""
Expand Down Expand Up @@ -67,7 +67,7 @@ test('entityInfo pull', () => {
return Promise.resolve(result)
})

Setup.emit('Discovery', 'pullEntityInfo', {
Setup.emit('discovery', 'pullEntityInfo', {
correlationId: '123',
parameters: {
entityId: '123'
Expand Down
16 changes: 8 additions & 8 deletions src/sdks/core/test/suite/device.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@
*/

import { test, expect } from "@jest/globals";
import { Device, Types } from "../../build/javascript/src/firebolt";
import { Device } from "../../build/javascript/src/firebolt";

test("Device.version()", () => {
const debug: string = "Non-parsable build info for error logging only."

const os:Types.SemanticVersion = {
const os:Device.SemanticVersion = {
major: 0,
minor: 1,
patch: 0,
readable: "Firebolt OS v0.1.0"
}

const sdk:Types.SemanticVersion = {
const sdk:Device.SemanticVersion = {
major: 0,
minor: 8,
patch: 0,
readable: "The Firebolt JS SDK",
}

const firmware:Types.SemanticVersion = {
const firmware:Device.SemanticVersion = {
major: 1,
minor: 2,
patch: 3,
readable: "Device Firmware v1.2.3"
}

const api:Types.SemanticVersion = {
const api:Device.SemanticVersion = {
major: 0,
minor: 8,
patch: 0,
Expand Down Expand Up @@ -112,17 +112,17 @@ test("Device.make()", () => {
});

test("Device.hdcp()", () => {
const expectedOutput: Types.BooleanMap = {
const expectedOutput: Device.BooleanMap = {
"hdcp1.4": true,
"hdcp2.2": true,
};
return Device.hdcp().then((res: Types.BooleanMap) => {
return Device.hdcp().then((res: Device.BooleanMap) => {
expect(res).toEqual(expectedOutput);
});
});

test("Device.hdcp(subscriber)", () => {
return Device.hdcp((supportedHdrProfiles: Types.BooleanMap) => {}).then(
return Device.hdcp((supportedHdrProfiles: Device.BooleanMap) => {}).then(
(res: number) => {
expect(res > 0).toBe(true);
}
Expand Down
10 changes: 5 additions & 5 deletions src/sdks/core/test/suite/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import { test, expect } from "@jest/globals";
import { Discovery, Entertainment } from "../../build/javascript/src/firebolt";
import { Discovery } from "../../build/javascript/src/firebolt";

test("watched(entityId)", () => {
return Discovery.watched("abc").then((success: boolean) => {
Expand Down Expand Up @@ -50,7 +50,7 @@ test("entityInfo(EntityInfoResult)", () => {
},
title: "Test",
entityType: "program",
programType: Entertainment.ProgramType.MOVIE,
programType: Discovery.ProgramType.MOVIE,
},
};
return Discovery.entityInfo(dummyData).then((res: boolean) => {
Expand All @@ -65,7 +65,7 @@ test("watchNext(title?: LocalizedString, identifiers: ContentIdentifiers, expire
});

test("entitlements(entitlements: Entitlement[])", () => {
const dummyData: Array<Entertainment.Entitlement> = [
const dummyData: Array<Discovery.Entitlement> = [
{
entitlementId: "test123",
startTime: `${new Date().getTime()}`,
Expand All @@ -84,7 +84,7 @@ test("launch(appId)", () => {
});

test("signIn(appId)", () => {
const dummyData: Array<Entertainment.Entitlement> = [
const dummyData: Array<Discovery.Entitlement> = [
{
entitlementId: "test123",
startTime: `${new Date().getTime()}`,
Expand Down Expand Up @@ -113,7 +113,7 @@ test("purchasedContent()", () => {
},
title: "TEST",
entityType: "program",
programType: Entertainment.ProgramType.MOVIE,
programType: Discovery.ProgramType.MOVIE,
},
],
};
Expand Down
67 changes: 29 additions & 38 deletions src/sdks/core/test/suite/federation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
// setup for Firebolt SDK/TL handshake

import { test, expect, beforeAll } from "@jest/globals";
import { Lifecycle, Discovery, Entertainment, Types } from '../../build/javascript/src/firebolt'
import { Lifecycle, Discovery } from '../../build/javascript/src/firebolt'

// holds test transport layer state, e.g. callback

const state = {
callback:(a:object) => {}
callback:(a:string) => {}
}

let pullEntityInfoListenCount = 0
Expand All @@ -40,8 +40,9 @@ let secondRegistrationFailed = false
beforeAll(() => {
return new Promise( (resolve, reject) => {
const transport = {
send: function(json: any) {
send: function(message: string) {
sendCalled = true
const json = JSON.parse(message)
if (json.method.toLowerCase() === 'discovery.onpullentityinfo') {
// we'll assert on this later...
pullEntityInfoListenCount++
Expand All @@ -53,12 +54,12 @@ beforeAll(() => {
id: json.id,
result: {
listening: true,
event: 'Discovery.onPullEntityInfo'
event: 'discovery.onPullEntityInfo'
}
}
// catching errors, so all tests don't fail if this breaks
try {
state.callback(response)
state.callback(JSON.stringify(response))
}
catch (err) {
throw err
Expand All @@ -70,31 +71,27 @@ beforeAll(() => {
try {
response = {
jsonrpc: '2.0',
method: 'Discovery.pullEntityInfo',
params: {
value: {
correlationId: correlationId,
parameters: {
entityId: "345"
}
id: json.id,
result: {
correlationId: correlationId,
parameters: {
entityId: "345"
}
}
}

state.callback(response)
state.callback(JSON.stringify(response))

state.callback({
state.callback(JSON.stringify({
jsonrpc: '2.0',
method: 'Discovery.pullEntityInfo',
params: {
value: {
correlationId: 'this-will-fail',
parameters: {
entityId: "this-will-fail"
}
id: json.id,
result: {
correlationId: 'this-will-fail',
parameters: {
entityId: "this-will-fail"
}
}
})
}))
}
catch (err) {
throw err
Expand All @@ -114,24 +111,21 @@ beforeAll(() => {
else if (!json.params.correlationId && json.params.result.entity.identifiers.entityId === "PUSH:345") {
entityInfoPushed = true
}

setTimeout(() => {
state.callback({
jsonrpc: '2.0',
id: json.id,
result: true
})
}, 100)
state.callback(JSON.stringify({
jsonrpc: '2.0',
id: json.id,
result: true
}))
}
},
receive: function(callback: (a:object) => void) {
receive: function(callback: (a:string) => void) {
// store the callback
state.callback = callback
}
}

const win:any = window;
win.__firebolt.transport = transport
win.__firebolt.setTransportLayer(transport)

const result:Discovery.EntityInfoResult = {
"expires": "2025-01-01T00:00:00.000Z",
Expand All @@ -140,7 +134,7 @@ beforeAll(() => {
"entityId": "PUSH:345"
},
"entityType": "program",
"programType": Entertainment.ProgramType.MOVIE,
"programType": Discovery.ProgramType.MOVIE,
"title": "Cool Runnings",
"synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.",
"releaseDate": "1993-01-01T00:00:00.000Z",
Expand All @@ -162,9 +156,9 @@ beforeAll(() => {
"expires": "2025-01-01T00:00:00.000Z",
"entitled": true,
"entitledExpires": "2025-01-01T00:00:00.000Z",
"offeringType": Entertainment.OfferingType.BUY,
"offeringType": Discovery.OfferingType.BUY,
"price": 2.99,
"audioProfile": [Types.AudioProfile.DOLBY_ATMOS],
"audioProfile": [Discovery.AudioProfile.DOLBY_ATMOS],
"videoQuality": ["UHD"],
"audioLanguages": [
"en"
Expand All @@ -186,8 +180,6 @@ beforeAll(() => {
// Setup a callback that returns the correct payload
Discovery.entityInfo((parameters:Discovery.EntityInfoParameters) => {

console.dir(parameters)

if (parameters.entityId === 'this-will-fail') {
throw "Intentional Test failure"
}
Expand Down Expand Up @@ -217,7 +209,6 @@ test('Transport was sent each listener only once', () => {
});

test('Entity Info was pulled from the app', ()=> {
expect(callbackWiredUp).toBe(true)
expect(entityInfoPulled).toBe(true)
expect(entityInfoReceived).toBe(true)
});
Expand Down
Loading

0 comments on commit 2c5bc23

Please sign in to comment.