Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 4c16985

Browse files
myan9starpit
authored andcommitted
feat: client test
Fixes #3130
1 parent 50d73c9 commit 4c16985

File tree

14 files changed

+191
-3
lines changed

14 files changed

+191
-3
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ env:
1818
KUI_USE_PROXY=true
1919
NEEDS_IBMCLOUD_CLI=true # see plugins/plugin-bash-like/src/test/bash-like/bash-like.ts
2020

21+
- LAYERS="response"
22+
MOCHA_TARGETS="electron"
23+
KUI_USE_CLIENT=test
24+
2125
- LAYERS="core"
2226
MOCHA_TARGETS="electron"
2327
KUI_USE_CLIENT=base
@@ -89,6 +93,8 @@ matrix:
8993
env: LAYERS="core" MOCHA_TARGETS="electron" KUI_USE_CLIENT=base LINUX_BASE_BUILD="${TRAVIS_BUILD_DIR}/clients/electron/dist/electron/Kui-base-linux-x64/Kui" OSX_BASE_BUILD="${TRAVIS_BUILD_DIR}/clients/electron/dist/electron/Kui-base-darwin-x64/Kui.app/Contents/MacOS/Kui" TEST_FROM_BUILD=`[ "$TRAVIS_OS_NAME" == linux ] && echo "$LINUX_BASE_BUILD" || echo "$OSX_BASE_BUILD"`
9094
- os: osx
9195
env: SCRIPTS="build-webpack-client.sh lint.sh typecov.sh" WAIT_LAYERS="manager" LAYERS="openwhisk1 openwhisk3 openwhisk-editor grid" MOCHA_TARGETS="webpack electron" KUI_USE_PROXY=false NEEDS_OPENWHISK=true
96+
- os: osx
97+
env: LAYERS="response" MOCHA_TARGETS="electron" KUI_USE_CLIENT=test
9298
- os: osx
9399
env: LAYERS="openwhisk2 openwhisk4 composer1 composer2" MOCHA_TARGETS="electron" NEEDS_OPENWHISK=true NEEDS_OPENWHISK_API_GATEWAY=true NEEDS_OPENWHISK_NODEJS8=true NEEDS_OPENWHISK_JAVA8=true NEEDS_SECOND_OPENWHISK_AUTH=true
94100
- os: osx

clients/test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.npmrc
2+
dist
3+
package-lock.json

clients/test/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "client-test",
3+
"version": "1.0.0",
4+
"description": "A test client for the Kui",
5+
"main": "node_modules/@kui-shell/core/main/main.js",
6+
"scripts": {
7+
"preinstall": "rm -rf node_modules package-lock.json; (cd ../../ && npm ci && npm run pack)",
8+
"build:electron": "build() { npx --no-install kui-build-electron /tmp $1; }; build",
9+
"compile": "kui-compile",
10+
"postinstall": "kui-compile",
11+
"test": "kui-test",
12+
"watch": "tsc --build . --watch",
13+
"pty:rebuild": "if [ -d node_modules/node-pty-prebuilt-multiarch ]; then cd node_modules/node-pty-prebuilt-multiarch && npm run install; fi",
14+
"pty:electron": "if [ -d node_modules/node-pty-prebuilt-multiarch ]; then if [ ! -e node_modules/node-pty-prebuilt-multiarch/.npmrc ]; then cp node_modules/@kui-shell/builder/npmrc node_modules/node-pty-prebuilt-multiarch/.npmrc && npm run pty:rebuild; fi; fi",
15+
"pty:nodejs": "if [ -e node_modules/node-pty-prebuilt-multiarch/.npmrc ]; then rm -f node_modules/node-pty-prebuilt-multiarch/.npmrc; npm run pty:rebuild; fi",
16+
"start": "npm run -s compile && npm run -s pty:electron && electron . shell"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git@github.com:kui-shell/plugin-sample.git"
21+
},
22+
"keywords": [],
23+
"author": "Mengting Yan",
24+
"license": "Apache-2.0",
25+
"devDependencies": {
26+
"@kui-shell/builder": "file:/tmp/kui-packs/kui-shell-builder.tgz",
27+
"@kui-shell/core": "file:/tmp/kui-packs/kui-shell-core.tgz",
28+
"@kui-shell/test": "file:/tmp/kui-packs/kui-shell-test.tgz",
29+
"@types/mocha": "5.2.7",
30+
"@types/node": "12.7.12",
31+
"@types/uuid": "^3.4.5",
32+
"@types/webdriverio": "^4.13.3",
33+
"electron": "6.0.12",
34+
"mocha": "6.2.1",
35+
"spectron": "8.0.0",
36+
"typescript": "3.6.4"
37+
},
38+
"dependencies": {
39+
"@kui-shell/plugin-test": "file:plugins/plugin-test"
40+
}
41+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
tsconfig.tsbuildinfo
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@kui-shell/plugin-test",
3+
"version": "0.0.1",
4+
"description": "A test plugin for the Kui",
5+
"author": "Mengting Yan",
6+
"license": "Apache-2.0",
7+
"keywords": [
8+
"kui",
9+
"plugin",
10+
"sample",
11+
"example"
12+
],
13+
"main": "dist/plugin.js",
14+
"dependencies": {
15+
"@kui-shell/core": "file:/tmp/kui-packs/kui-shell-core.tgz"
16+
},
17+
"publishConfig": {
18+
"access": "public"
19+
}
20+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2019 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { CommandRegistrar } from '@kui-shell/core/models/command'
18+
19+
const usage = (command: string) => ({
20+
command,
21+
docs: 'Say hello!'
22+
})
23+
24+
const options = (cmd: string) => ({ usage: usage(cmd), noAuthOk: true })
25+
26+
const stringResponse = () => {
27+
return 'hello world'
28+
}
29+
30+
export default async (commandTree: CommandRegistrar) => {
31+
commandTree.listen('/test/string', stringResponse, options('test string'))
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import { TestStringResponse } from '@kui-shell/test'
17+
18+
/* eslint-disable no-new */
19+
new TestStringResponse({
20+
command: 'test string',
21+
expect: 'hello world',
22+
exact: true
23+
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../node_modules/@kui-shell/builder/tsconfig-base.json",
3+
"include": ["src/**/*"],
4+
"compilerOptions": {
5+
"composite": true,
6+
"noImplicitAny": true,
7+
"outDir": "dist",
8+
"rootDir": "src"
9+
}
10+
}

clients/test/theme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/theme

clients/test/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./node_modules/@kui-shell/builder/tsconfig-base.json",
3+
"references": [{ "path": "./plugins/plugin-test" }]
4+
}

0 commit comments

Comments
 (0)