Skip to content

Commit 5397f77

Browse files
Merging to pre-release (#328)
* Unify e2e tests into one file * Switch test taskpane to use Office.onReady * Log useragent * Try switching order of tests * Use different manifest for debugging test * Disable IE webview test case * Removing unneed protocol property (#325) Removing unneeded property in launch.json. VScode complains it is not allowed and documentation also says it does not exist when the mode is attach. * Making debugger hit and bind (#324) Making breakpoints from the source code be hit again. Fixes the problem where the debugger wouldn't be hit unless debugging directly. This very probably wouldn't work on Mac, as it requires a direct reference to LocalAppData, which only exists in windows. Pretty much we needed to directly reference the code that actually runs in the WEF cache. Co-authored-by: Darren Miller <darrmill@microsoft.com> Co-authored-by: Darren Miller <millerds@users.noreply.github.com>
1 parent dee555e commit 5397f77

File tree

7 files changed

+161
-165
lines changed

7 files changed

+161
-165
lines changed

.azure-devops/full-pipeline.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ jobs:
2929
parameters:
3030
webView: "edge-legacy"
3131

32-
- job: WebView_IE
33-
pool:
34-
name: OE-OfficeClientApps
35-
steps:
36-
- template: ./install.yml
37-
- template: ./lint.yml
38-
- template: ./build.yml
39-
- template: ./devcerts.yml
40-
- template: ./edgewebview.yml
41-
- template: ./test.yml
42-
parameters:
43-
webView: "ie"
32+
# Need to determin why the IE test doesn't pass in the lab
33+
# - job: WebView_IE
34+
# pool:
35+
# name: OE-OfficeClientApps
36+
# steps:
37+
# - template: ./install.yml
38+
# - template: ./lint.yml
39+
# - template: ./build.yml
40+
# - template: ./devcerts.yml
41+
# - template: ./edgewebview.yml
42+
# - template: ./test.yml
43+
# parameters:
44+
# webView: "ie"
4445

4546
- job: Mac
4647
pool:

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
"type": "node",
5252
"request": "attach",
5353
"port": 9229,
54-
"protocol": "inspector",
5554
"timeout": 600000,
5655
"preLaunchTask": "Debug: Excel Desktop",
57-
"postDebugTask": "Stop Debug"
56+
"postDebugTask": "Stop Debug",
57+
"resolveSourceMapLocations": null
5858
},
5959
{
6060
"name": "Excel Desktop (Edge Chromium)",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"start:web": "office-addin-debugging start manifest.xml web",
2424
"stop": "office-addin-debugging stop manifest.xml",
2525
"test": "npm run test:unit && npm run test:e2e",
26-
"test:e2e": "mocha -r ts-node/register test/end-to-end/*.ts",
26+
"test:e2e": "mocha -r ts-node/register test/end-to-end/tests.ts",
2727
"test:unit": "mocha -r ts-node/register test/unit/*.test.ts",
2828
"validate": "office-addin-manifest validate manifest.xml",
2929
"watch": "webpack --mode development --watch"

test/end-to-end/debugging-test.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

test/end-to-end/src/test-taskpane.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ import * as functionsJsonData from "./test-data.json";
22
import { pingTestServer, sendTestResults } from "office-addin-test-helpers";
33
import { closeWorkbook, sleep } from "./test-helpers";
44

5-
/* global Office, document, Excel, run */
5+
/* global Office, document, Excel, run, navigator */
66
const customFunctionsData = (<any>functionsJsonData).functions;
77
const port: number = 4201;
88
let testValues = [];
99

10-
Office.initialize = async () => {
10+
Office.onReady(async () => {
1111
document.getElementById("sideload-msg").style.display = "none";
1212
document.getElementById("app-body").style.display = "flex";
1313
document.getElementById("run").onclick = run;
14+
addTestResult("UserAgent", navigator.userAgent);
1415

1516
const testServerResponse: object = await pingTestServer(port);
1617
if (testServerResponse["status"] === 200) {
1718
await runCfTests();
1819
await sendTestResults(testValues, port);
1920
await closeWorkbook();
2021
}
21-
};
22+
});
2223

2324
async function runCfTests(): Promise<void> {
2425
// Exercise custom functions

test/end-to-end/tests.ts

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import * as assert from "assert";
2+
import * as fs from "fs";
3+
import { parseNumber } from "office-addin-cli";
4+
import { AppType, startDebugging, stopDebugging } from "office-addin-debugging";
5+
import { toOfficeApp } from "office-addin-manifest";
6+
import { pingTestServer } from "office-addin-test-helpers";
7+
import { closeDesktopApplication } from "./src/test-helpers";
8+
import { connectToWebsocket, enableDebugging, pauseDebugging } from "./src/debugger-websocket";
9+
import * as officeAddinTestServer from "office-addin-test-server";
10+
import * as path from "path";
11+
12+
/* global process, describe, before, it, after, console */
13+
const host: string = "excel";
14+
const manifestPath = path.resolve(`${process.cwd()}/test/end-to-end/test-manifest.xml`);
15+
const manifestPathDebugging = path.resolve(`${process.cwd()}/test/end-to-end/test-manifest-debugging.xml`);
16+
const port: number = 4201;
17+
const testDataFile: string = `${process.cwd()}/test/end-to-end/src/test-data.json`;
18+
const testJsonData = JSON.parse(fs.readFileSync(testDataFile).toString());
19+
const testServer = new officeAddinTestServer.TestServer(port);
20+
let testValues: any = [];
21+
22+
describe("Test Excel Custom Functions", function () {
23+
describe("UI Tests", function () {
24+
before(`Setup test environment and sideload ${host}`, async function () {
25+
this.timeout(0);
26+
// Start test server and ping to ensure it's started
27+
const testServerStarted = await testServer.startTestServer(true /* mochaTest */);
28+
const serverResponse = await pingTestServer(port);
29+
assert.strictEqual(serverResponse["status"], 200);
30+
assert.strictEqual(testServerStarted, true);
31+
32+
// Call startDebugging to start dev-server and sideload
33+
const devServerCmd = `npm run dev-server -- --config ./test/end-to-end/webpack.config.js`;
34+
const devServerPort = parseNumber(process.env.npm_package_config_dev_server_port || 3000);
35+
const options = {
36+
appType: AppType.Desktop,
37+
app: toOfficeApp(host),
38+
devServerCommandLine: devServerCmd,
39+
devServerPort: devServerPort,
40+
enableDebugging: false,
41+
};
42+
await startDebugging(manifestPath, options);
43+
});
44+
describe("Get test results for custom functions and validate results", function () {
45+
it("should get results from the taskpane application", async function () {
46+
this.timeout(0);
47+
// Expecting six result values + user agent
48+
testValues = await testServer.getTestResults();
49+
console.log(`User Agent: ${testValues[0].Value}`);
50+
assert.strictEqual(testValues.length, 7);
51+
});
52+
it("ADD function should return expected value", async function () {
53+
assert.strictEqual(testJsonData.functions.ADD.result, testValues[1].Value);
54+
});
55+
it("CLOCK function should return expected value", async function () {
56+
// Check that captured values are different to ensure the function is streaming
57+
assert.notStrictEqual(testValues[2].Value, testValues[3].Value);
58+
// Check if the returned string contains 'AM', 'PM', or 'GMT', indicating it's a time-stamp
59+
assert.strictEqual(
60+
testValues[2].Value.includes(testJsonData.functions.CLOCK.result.amString) ||
61+
testValues[2].Value.includes(testJsonData.functions.CLOCK.result.pmString) ||
62+
testValues[2].Value.includes(testJsonData.functions.CLOCK.result.timeZoneString),
63+
true,
64+
"Found timestamp indicator string in first value '" + testValues[2].Value + "'"
65+
);
66+
assert.strictEqual(
67+
testValues[3].Value.includes(testJsonData.functions.CLOCK.result.amString) ||
68+
testValues[3].Value.includes(testJsonData.functions.CLOCK.result.pmString) ||
69+
testValues[3].Value.includes(testJsonData.functions.CLOCK.result.timeZoneString),
70+
true,
71+
"Found timestamp indicator string in second value '" + testValues[3].Value + "'"
72+
);
73+
});
74+
it("INCREMENT function should return expected value", async function () {
75+
// Check that captured values are different to ensure the function is streaming
76+
assert.notStrictEqual(testValues[3].Value, testValues[4].Value);
77+
// Check to see that both captured streaming values are divisible by 4
78+
assert.strictEqual(0, testValues[4].Value % testJsonData.functions.INCREMENT.result);
79+
assert.strictEqual(0, testValues[5].Value % testJsonData.functions.INCREMENT.result);
80+
});
81+
it("LOG function should return expected value", async function () {
82+
assert.strictEqual(testJsonData.functions.LOG.result, testValues[6].Value);
83+
});
84+
});
85+
after("Teardown test environment", async function () {
86+
this.timeout(0);
87+
// Stop the test server
88+
const stopTestServer = await testServer.stopTestServer();
89+
assert.strictEqual(stopTestServer, true);
90+
91+
// Close excel
92+
const applicationClosed = await closeDesktopApplication();
93+
assert.strictEqual(applicationClosed, true);
94+
95+
// Unregister the add-in
96+
await stopDebugging(manifestPath);
97+
});
98+
});
99+
describe("Debugger Tests", function () {
100+
before(`Setup test environment and sideload ${host}`, async function () {
101+
this.timeout(0);
102+
// Call startDebugging to start dev-server and sideload
103+
const devServerCmd: string = `npm run dev-server -- --config ./test/end-to-end/webpack.config.js --env testType=debugger`;
104+
const devServerPort: number = 3001;
105+
const options = {
106+
appType: AppType.Desktop,
107+
app: toOfficeApp(host),
108+
devServerCommandLine: devServerCmd,
109+
devServerPort: devServerPort,
110+
enableDebugging: true,
111+
};
112+
await startDebugging(manifestPathDebugging, options);
113+
});
114+
describe("Test Debugger", function () {
115+
let ws: WebSocket;
116+
before("Open websocket connection to Debugger", async function () {
117+
this.timeout(60 * 1000);
118+
ws = await connectToWebsocket();
119+
assert.notStrictEqual(ws, undefined, "Unable to connect to the websocket.");
120+
});
121+
it("enable debugging", async function () {
122+
await enableDebugging(ws);
123+
});
124+
it("pause debugging", async function () {
125+
await pauseDebugging(ws);
126+
});
127+
after("Close websocket connection", async function () {
128+
ws.close();
129+
});
130+
});
131+
after("Teardown test environment", async function () {
132+
this.timeout(0);
133+
// Close excel
134+
const applicationClosed = await closeDesktopApplication();
135+
assert.strictEqual(applicationClosed, true);
136+
137+
// Unregister the add-in
138+
await stopDebugging(manifestPathDebugging);
139+
});
140+
});
141+
});

test/end-to-end/ui-test.ts

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)