Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/test/common/fdc3.app-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { assert, expect } from "chai";
import { wait } from "../../utils";
import { APP_CHANNEL_AND_BROADCAST, APP_CHANNEL_AND_BROADCAST_TWICE, ChannelControl, JOIN_AND_BROADCAST_TWICE } from "./control/channel-control";

export function createAppChannelTests(cc: ChannelControl<any, any, any>, documentation: string, prefix: string): Mocha.Suite {
return describe("App channels", () => {
beforeEach(cc.leaveChannel);
export function createAppChannelTests(cc: ChannelControl<any, any, any>, documentation: string, prefix: string) {
// return describe("App channels", () => {
// beforeEach(cc.leaveChannel);

afterEach(async function afterEach() {
await cc.closeMockApp(this.currentTest.title);
});
// afterEach(async function afterEach() {
// await cc.closeMockApp(this.currentTest.title);
// });

const acTestId = "(" + prefix + "ACBasicUsage1) Should receive context when app a adds a listener and app B broadcasts to the same app channel";
it(acTestId, async () => {
Expand Down Expand Up @@ -192,5 +192,4 @@ export function createAppChannelTests(cc: ChannelControl<any, any, any>, documen
expect(context.type).to.be.equals("fdc3.contact", errorMessage);
}
});
});
}
}
13 changes: 2 additions & 11 deletions src/test/common/fdc3.user-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ import { failOnTimeout, wait, wrapPromise } from "../../utils";
import { JOIN_AND_BROADCAST, JOIN_AND_BROADCAST_TWICE } from "./control/channel-control";
import { ChannelControl } from "./control/channel-control";

export function createUserChannelTests(cc: ChannelControl<any, any, any>, documentation: string, prefix: string): Mocha.Suite {
const channelName = prefix === "" ? "System channels" : "User channels";
return describe(channelName, () => {
beforeEach(cc.leaveChannel);

afterEach(async function afterEach() {
if (this.currentTest.title !== UCFilteredUsageJoin) await cc.closeMockApp(this.currentTest.title);
});

export function createUserChannelTests(cc: ChannelControl<any, any, any>, documentation: string, prefix: string) {
const scTestId1 = "(" + prefix + "UCBasicUsage1) Should receive context when adding a listener then joining a user channel before app B broadcasts context to the same channel";
it(scTestId1, async () => {
const errorMessage = `\r\nSteps to reproduce:\r\n- Add fdc3.instrument context listener to app A\r\n- App A joins channel 1\r\n- App B joins channel 1\r\n- App B broadcasts fdc3.instrument context${documentation}`;
Expand Down Expand Up @@ -302,5 +294,4 @@ export function createUserChannelTests(cc: ChannelControl<any, any, any>, docume
const currentChannel = await cc.getCurrentChannel();
expect(channels[2].id, errorMessage).to.be.equal(currentChannel.id);
});
});
}
}
12 changes: 9 additions & 3 deletions src/test/v1.2/advanced/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const documentation = "\r\nDocumentation: " + APIDocumentation1_2.desktopAgent +
const control = new ChannelControl1_2();

export default () =>
describe("channels", () => {
createUserChannelTests(control, documentation, "");
createAppChannelTests(control, documentation, "");
describe("Channels_1.2", () => {
const UCFilteredUsageJoin = "(" + '1.2-' + "UCFilteredUsageJoin) getCurrentChannel retrieves the channel that was joined";
beforeEach(control.leaveChannel);

afterEach(async function afterEach() {
if (this.currentTest.title !== UCFilteredUsageJoin) await control.closeMockApp(this.currentTest.title);
});
createUserChannelTests(control, documentation, "1.2-");
createAppChannelTests(control, documentation, "1.2-");
});
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.findIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const findIntentDocs = "\r\nDocumentation: " + APIDocumentation1_2.findIntent +
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.findIntent", () => {
describe("fdc3.findIntent_1.2", () => {
it("(IntentAppD) Should find intent 'aTestingIntent' belonging only to app intent-a", async () => {
const appIntent = await fdc3.findIntent(Intent.aTestingIntent);
expect(appIntent.intent).to.deep.eq(
Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.findIntentsByContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const findIntentsByContextDocs = "\r\nDocumentation: " + APIDocumentation1_2.fin
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.findIntentsByContext", () => {
describe("fdc3.findIntentsByContext_1.2", () => {
it("(SingleContext) Should find intents by context 'testContextX'", async () => {
try {
const intents = await fdc3.findIntentsByContext({
Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.getInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare let fdc3: DesktopAgent;
const getInfoDocs = "\r\nDocumentation: " + APIDocumentation1_2.getInfo + "\r\nCause";

export default () =>
describe("fdc3.getInfo1", () => {
describe("fdc3.getInfo_1.2", () => {

it("Method is callable", async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config: OpenCommonConfig = {
};

export default () =>
describe("fdc3.open", () => {
describe("fdc3.open_1.2", () => {
//run common open tests
getCommonOpenTests(control, openDocs, config);

Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.raiseIntent-NoAppsFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const raiseIntentDocs = "\r\nDocumentation: " + APIDocumentation1_2.raiseIntent
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.raiseIntent (throws error)", () => {
describe("fdc3.raiseIntent (throws error)_1.2", () => {
const test5 = "(FailedResolve1) Should fail to raise intent when targeted app intent-a, context 'testContextY' and intent 'aTestingIntent' do not correlate";
it(test5, async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/v1.2/advanced/fdc3.raiseIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const raiseIntentDocs = "\r\nDocumentation: " + APIDocumentation1_2.raiseIntent
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.raiseIntent", () => {
describe("fdc3.raiseIntent_1.2", () => {
afterEach(async function afterEach() {
await closeMockAppWindow(this.currentTest.title);
});
Expand Down
18 changes: 9 additions & 9 deletions src/test/v1.2/basic/fdc3.basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ const documentation_UC = "\r\nDocumentation: " + APIDocumentation1_2.getSystemCh
const documentation_JC = "\r\nDocumentation: " + APIDocumentation1_2.getCurrentChannel + "\r\nCause";
const documentation_RI = "\r\nDocumentation: " + APIDocumentation1_2.raiseIntentForContext + "\r\nCause";

export let fdc3BasicCL1_1_2 = () => describe("fdc3.basicCL1", () => basicCL1(fdc3, documentation_CL, listener));
export let fdc3BasicCL2_1_2 = () => describe("fdc3.basicCL2", () => basicCL2(fdc3, documentation_CL, listener));
export let fdc3BasicIL1_1_2 = () => describe("fdc3.basicIL1", () => basicIL1(fdc3, documentation_IL, listener));
export let fdc3BasicGI1_1_2 = () => describe("fdc3.basicGI1", () => basicGI1(control, documentation_GI));
export let fdc3BasicAC1_1_2 = () => describe("fdc3.basicAC1", () => basicAC1(fdc3, documentation_AC));
export let fdc3BasicUC1_1_2 = () => describe("fdc3.basicUC1", () => basicUC1(control,documentation_UC));
export let fdc3BasicJC1_1_2 = () => describe("fdc3.basicJC1", () => basicJC1(cc, fdc3, documentation_JC));
export let fdc3BasicRI1_1_2 = () => describe("fdc3.basicRI1", () => {
export let fdc3BasicCL1_1_2 = () => describe("fdc3.basicCL1_1.2", () => basicCL1(fdc3, documentation_CL, listener));
export let fdc3BasicCL2_1_2 = () => describe("fdc3.basicCL2_1.2", () => basicCL2(fdc3, documentation_CL, listener));
export let fdc3BasicIL1_1_2 = () => describe("fdc3.basicIL1_1.2", () => basicIL1(fdc3, documentation_IL, listener));
export let fdc3BasicGI1_1_2 = () => describe("fdc3.basicGI1_1.2", () => basicGI1(control, documentation_GI));
export let fdc3BasicAC1_1_2 = () => describe("fdc3.basicAC1_1.2", () => basicAC1(fdc3, documentation_AC));
export let fdc3BasicUC1_1_2 = () => describe("fdc3.basicUC1_1.2", () => basicUC1(control,documentation_UC));
export let fdc3BasicJC1_1_2 = () => describe("fdc3.basicJC1_1.2", () => basicJC1(cc, fdc3, documentation_JC));
export let fdc3BasicRI1_1_2 = () => describe("fdc3.basicRI1_1.2", () => {
after(async function after() {
await wait(constants.ShortWait)
await closeMockAppWindow(this.currentTest.title);
});
basicRI1(fdc3, documentation_RI, Intent.aTestingIntent, ContextType.testContextX)
});
export let fdc3BasicRI2_1_2 = () => describe("fdc3.basicRI2", () => {
export let fdc3BasicRI2_1_2 = () => describe("fdc3.basicRI2_1.2", () => {
after(async function after() {
await wait(constants.ShortWait)
await closeMockAppWindow(this.currentTest.title);
Expand Down
25 changes: 24 additions & 1 deletion src/test/v1.2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function executeTests() {
}

function returnToTestSelection() {
location.reload();
location.href = '/v1.2/app/index.html';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you test this in Sail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Sail location.reload() and location.href are not working.
Single test execution is still broken in Sail.
On clicking the button, it opens up the tests in Browser.

Copy link
Contributor

@kriswest kriswest Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything to do with scoping? window.location and location are not necessarily the same thing depending on which scope you are in.

}

function toggleVersionSelector() {
Expand All @@ -55,5 +55,28 @@ function toggleBackButton() {
}
}

function executeSingleTest(testName: string) {
toggleVersionSelector();
toggleBackButton();
const action = () => executeTestsInBrowser(testName);
if (window.fdc3) {
action();
} else {
window.addEventListener("fdc3Ready", action);
}
}

function parseQueryString(queryString: string) {
let queryParts = decodeURI(queryString.split('=')[1]).replace(/\\/g, "").split('_');
let testName = queryParts[0] + ' 1.2';
return testName;
}

const queryString = window.location.search;
if(queryString !== undefined && queryString !== '') {
let testName = parseQueryString(queryString);
executeSingleTest(testName);
}

document.getElementById("runButton").addEventListener("click", executeTests);
document.getElementById("back-button").addEventListener("click", returnToTestSelection);
4 changes: 2 additions & 2 deletions src/test/v1.2/testSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const basicSuite_1_2: testSet = {
const advancedSuite_1_2: testSet = {
"fdc3.open 1.2": [fdc3Open_1_2],
"fdc3.getInfo 1.2": [fdc3GetInfo_1_2],
"channels 1.2": [channels_1_2],
"Channels 1.2": [channels_1_2],
"fdc3.findIntent 1.2": [fdc3FindIntent_1_2],
"fdc3.raiseIntent 1.2": [fdc3RaiseIntent_1_2],
"fdc3.raiseIntent 1.2 (NoAppsFound)": [fdc3RaiseIntent_1_2_NoAppsFound],
"fdc3.raiseIntent (throws error) 1.2": [fdc3RaiseIntent_1_2_NoAppsFound],
"fdc3.findIntentsByContext 1.2": [fdc3FindIntentsByContext_1_2],
};

Expand Down
8 changes: 7 additions & 1 deletion src/test/v2.0/advanced/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const documentation = "\r\nDocumentation: " + APIDocumentation2_0.desktopAgent +
const control = new ChannelControl2_0();

export default () =>
describe("channels", () => {
describe("Channels_2.0", () => {
const UCFilteredUsageJoin = "(" + '2.0-' + "UCFilteredUsageJoin) getCurrentChannel retrieves the channel that was joined";
beforeEach(control.leaveChannel);

afterEach(async function afterEach() {
if (this.currentTest.title !== UCFilteredUsageJoin) await control.closeMockApp(this.currentTest.title);
});
createUserChannelTests(control, documentation, "2.0-");
createAppChannelTests(control, documentation, "2.0-");
});
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.findInstances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const findInstancesDocs = "\r\nDocumentation: " + APIDocumentation2_0.findInstan
const control = new RaiseIntentControl2_0();

export default () =>
describe("fdc3.findInstances", () => {
describe("fdc3.findInstances_2.0", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.findIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const findIntentDocs = "\r\nDocumentation: " + APIDocumentation2_0.findIntent +
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.findIntent", () => {
describe("fdc3.findIntent_2.0", () => {
it("(2.0-FindIntentAppD) Should find intent 'aTestingIntent' belonging only to app intent-a", async () => {
const appIntent = await fdc3.findIntent(Intent.aTestingIntent);
validateAppIntent(appIntent, 1, { name: Intent.aTestingIntent, displayName: "A Testing Intent" }, IntentApp.IntentAppA);
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.findIntentsByContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const findIntentsByContextDocs = "\r\nDocumentation: " + APIDocumentation2_0.fin
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.findIntentsByContext", () => {
describe("fdc3.findIntentsByContext_2.0", () => {
it("(2.0-FindIntentByContextSingleContext) Should find intents by context 'testContextX'", async () => {
try {
const intents = await fdc3.findIntentsByContext({ type: ContextType.testContextX });
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.getAppMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const validator = new MetadataValidator();
const api = new MetadataFdc3Api();

export default () =>
describe("fdc3.getAppMetadata", () => {
describe("fdc3.getAppMetadata_2.0", () => {
after(async () => {
await closeMockAppWindow(appInstanceMetadata);
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.getInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const validator = new MetadataValidator();
const api = new MetadataFdc3Api();

export default () =>
describe("fdc3.getInfo", () => {
describe("fdc3.getInfo_2.0", () => {
let listener: Listener | undefined;

after(async function after() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config: OpenCommonConfig = {
};

export default () =>
describe("fdc3.open", () => {
describe("fdc3.open_2.0", () => {
//run common open tests
getCommonOpenTests(control, openDocs, config);

Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.raiseIntent-NoAppsFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const raiseIntentDocs = "\r\nDocumentation: " + APIDocumentation2_0.raiseIntent
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.raiseIntent (throws error)", () => {
describe("fdc3.raiseIntent (throws error)_2.0", () => {
const RaiseIntentFailedResolve = "(RaiseIntentFailedResolve) Should fail to raise intent when targeted app intent-a, context 'testContextY' and intent 'aTestingIntent' do not correlate";
it(RaiseIntentFailedResolve, async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.raiseIntent-Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const control = new RaiseIntentControl2_0();

export default () =>

describe("fdc3.raiseIntent (Result)", () => {
describe("fdc3.raiseIntent (Result)_2.0", () => {
let errorListener: Listener = undefined;

afterEach(async function afterEach() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/v2.0/advanced/fdc3.raiseIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const control = new RaiseIntentControl2_0();
* Details on the mock apps used in these tests can be found in /mock/README.md
*/
export default () =>
describe("fdc3.raiseIntent", () => {
describe("fdc3.raiseIntent_2.0", () => {
let errorListener: Listener = undefined;

afterEach(async function afterEach() {
Expand Down
28 changes: 26 additions & 2 deletions src/test/v2.0/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function executeManualTests() {
toggleBackButton();
const manualTests = document.getElementById("manualTests") as HTMLSelectElement;
var selectedManualTest = manualTests.options[manualTests.selectedIndex].innerHTML;
console.log('******** Selected manual test is',selectedManualTest);
const action = () => executeManualTestsInBrowser(selectedManualTest);
if (window.fdc3) {
action();
Expand All @@ -49,7 +48,7 @@ function executeManualTests() {
}

function returnToTestSelection() {
location.reload();
location.href = '/v2.0/app/index.html';
}

function toggleVersionSelector() {
Expand All @@ -73,6 +72,31 @@ function toggleBackButton() {
}
}

function executeSingleTest(testName: string, manualTest: boolean) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it's repeated code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can sort it out and make it as one function.

toggleVersionSelector();
toggleBackButton();
const action = () => manualTest? executeManualTestsInBrowser(testName): executeTestsInBrowser(testName);
if (window.fdc3) {
action();
} else {
window.addEventListener("fdc3Ready", action);
}
}

function parseQueryString(queryString) {
let queryParts = decodeURI(queryString.split('=')[1]).replace(/\\/g, "").split('_');
let testName = queryParts[0] + ' 2.0';
let manualTest = (queryParts[1] !== undefined && queryParts[1] !== '' && queryParts[1] === 'Manual') ? true: false;
return {testName, manualTest};
}

const queryString = window.location.search;
if(queryString !== undefined && queryString !== '') {
let testData = parseQueryString(queryString);
let testName = testData.testName;
let manualTest = testData.manualTest;
executeSingleTest(testName, manualTest);
}
document.getElementById("runButton").addEventListener("click", executeTests);
document.getElementById("back-button").addEventListener("click", returnToTestSelection);
document.getElementById("manualTestsRunButton").addEventListener("click", executeManualTests);
8 changes: 4 additions & 4 deletions src/test/v2.0/manual/fdc3.manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare let fdc3: DesktopAgent;
* Details on the mock apps used in these tests can be found in /mock/README.md
*/

export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("ResolveAmbiguousIntentTarget_2.0", () => {
export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("fdc3.ResolveAmbiguousIntentTarget_Manual_2.0", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
});
Expand All @@ -35,7 +35,7 @@ export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("ResolveAmbiguo
});
});

export let fdc3ResolveAmbiguousContextTarget_2_0 = () => describe("ResolveAmbiguousContextTarget_2.0", () => {
export let fdc3ResolveAmbiguousContextTarget_2_0 = () => describe("fdc3.ResolveAmbiguousContextTarget_Manual_2.0", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
});
Expand All @@ -52,7 +52,7 @@ export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("ResolveAmbiguo
});
});

export let fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousIntentTargetMultiInstance_2.0", () => {
export let fdc3ResolveAmbiguousIntentTargetMultiInstance_2_0 = () => describe("fdc3.ResolveAmbiguousIntentTargetMultiInstance_Manual_2.0", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
});
Expand All @@ -75,7 +75,7 @@ export let fdc3ResolveAmbiguousIntentTarget_2_0 = () => describe("ResolveAmbiguo
});
});

export let fdc3ResolveAmbiguousContextTargetMultiInstance_2_0 = () => describe("ResolveAmbiguousContextTargetMultiInstance_2.0", () => {
export let fdc3ResolveAmbiguousContextTargetMultiInstance_2_0 = () => describe("fdc3.ResolveAmbiguousContextTargetMultiInstance_Manual_2.0", () => {
after(async function after() {
await closeMockAppWindow(this.currentTest.title);
});
Expand Down
Loading