浏览代码

Add an integration test

dev_h
ophir 5 年前
父节点
当前提交
2b64897733
共有 3 个文件被更改,包括 48 次插入1 次删除
  1. 5
    1
      .gitignore
  2. 1
    0
      server/server.js
  3. 42
    0
      tests/integration.js

+ 5
- 1
.gitignore 查看文件

@@ -22,4 +22,8 @@ npm-debug.log
22 22
 wbo-backup.zip
23 23
 
24 24
 # Jetbrains
25
-.idea/
25
+.idea/
26
+
27
+# Nightwatch test results
28
+tests_output/
29
+nightwatch.conf.js

+ 1
- 0
server/server.js 查看文件

@@ -132,3 +132,4 @@ function handleRequest(request, response) {
132 132
 }
133 133
 
134 134
 
135
+module.exports = app;

+ 42
- 0
tests/integration.js 查看文件

@@ -0,0 +1,42 @@
1
+const fs = require("../server/fs_promises.js");
2
+const os = require("os");
3
+const path = require("path");
4
+
5
+let wbo, data_path;
6
+
7
+async function beforeEach(browser, done) {
8
+    data_path = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'wbo-test-data-'));
9
+    process.env["PORT"] = 8487;
10
+    process.env["WBO_HISTORY_DIR"] = data_path;
11
+    console.log("Launching WBO in " + data_path);
12
+    wbo = require("../server/server.js");
13
+    done();
14
+}
15
+
16
+async function afterEach(browser, done) {
17
+    wbo.close();
18
+    done();
19
+}
20
+
21
+function testBoard(browser) {
22
+    browser
23
+        .url('http://localhost:8487/boards/anonymous?lang=fr')
24
+        .waitForElementVisible('.tool[title ~= Crayon]') // pencil
25
+        .assert.titleContains('WBO')
26
+        .click('.tool[title ~= Crayon]')
27
+        .assert.cssClassPresent('.tool[title ~= Crayon]', ['curTool'])
28
+        .executeAsync(function (done) {
29
+            Tools.setColor('#123456');
30
+            Tools.curTool.listeners.press(100, 200, new Event("mousedown"));
31
+            setTimeout(() => {
32
+                Tools.curTool.listeners.move(300, 400, new Event("mousemove"));
33
+                done();
34
+            }, 100);
35
+        })
36
+        .assert.visible("path[d='M 100 200 C 100 200 300 400 300 400'][stroke='#123456']")
37
+        .refresh()
38
+        .assert.visible("path[d='M 100 200 C 100 200 300 400 300 400'][stroke='#123456']")
39
+        .end();
40
+}
41
+
42
+module.exports = { beforeEach, testBoard, afterEach };

正在加载...
取消
保存