|
| 1 | +/* |
| 2 | + * Copyright 2018 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 | +// |
| 18 | +// tests that create an action and test that it shows up in the list UI |
| 19 | +// this test also covers toggling the sidecar |
| 20 | +// |
| 21 | +const common = require('../../../lib/common'), |
| 22 | + openwhisk = require('../../../lib/openwhisk'), |
| 23 | + ui = require('../../../lib/ui'), |
| 24 | + assert = require('assert'), |
| 25 | + keys = ui.keys, |
| 26 | + cli = ui.cli, |
| 27 | + sidecar = ui.sidecar, |
| 28 | + actionName1 = `foo1-${new Date().getTime()}`, |
| 29 | + actionName2 = `foo2-${new Date().getTime()}` |
| 30 | + |
| 31 | +describe('wsk activation get --last', function() { |
| 32 | + before(common.before(this)) |
| 33 | + after(common.after(this)) |
| 34 | + |
| 35 | + it('should have an active repl', () => cli.waitForRepl(this.app)) |
| 36 | + |
| 37 | + // create an action |
| 38 | + it(`should create an action ${actionName1}`, () => cli.do(`create ${actionName1} ./data/foo.js`, this.app) |
| 39 | + .then(cli.expectOK) |
| 40 | + .then(sidecar.expectOpen) |
| 41 | + .then(sidecar.expectShowing(actionName1)) |
| 42 | + .catch(common.oops(this))) |
| 43 | + |
| 44 | + it(`should invoke it ${actionName1}`, () => cli.do(`invoke -p name lastTestIPromise`, this.app) |
| 45 | + .then(cli.expectOK) |
| 46 | + .then(sidecar.expectOpen) |
| 47 | + .then(sidecar.expectShowing(actionName1)) |
| 48 | + .catch(common.oops(this))) |
| 49 | + |
| 50 | + // create another action |
| 51 | + it(`should create an action ${actionName2}`, () => cli.do(`create ${actionName2} ./data/foo.js`, this.app) |
| 52 | + .then(cli.expectOK) |
| 53 | + .then(sidecar.expectOpen) |
| 54 | + .then(sidecar.expectShowing(actionName2)) |
| 55 | + .catch(common.oops(this))) |
| 56 | + |
| 57 | + it(`should show ${actionName1} with wsk activation get --last`, () => this.app.client.waitUntil(() => { |
| 58 | + return cli.do(`wsk activation get --last`, this.app) |
| 59 | + .then(cli.expectOK) |
| 60 | + .then(sidecar.expectOpen) |
| 61 | + .then(sidecar.expectShowing(actionName1, undefined, undefined, undefined, undefined, 500)) |
| 62 | + .then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT)) |
| 63 | + .then(ui.expectStruct({name:'Step1 lastTestIPromise'})) |
| 64 | + .catch(common.oops(this)) |
| 65 | + })) |
| 66 | + |
| 67 | + it(`should invoke it ${actionName2}`, () => cli.do(`invoke ${actionName2} -p name lastTestIPromise`, this.app) |
| 68 | + .then(cli.expectOK) |
| 69 | + .then(sidecar.expectOpen) |
| 70 | + .then(sidecar.expectShowing(actionName2)) |
| 71 | + .catch(common.oops(this))) |
| 72 | + |
| 73 | + it(`should show ${actionName1} with wsk activation get --last ${actionName1}`, () => this.app.client.waitUntil(() => { |
| 74 | + return cli.do(`wsk activation get --last ${actionName1}`, this.app) |
| 75 | + .then(cli.expectOK) |
| 76 | + .then(sidecar.expectOpen) |
| 77 | + .then(sidecar.expectShowing(actionName1, undefined, undefined, undefined, undefined, 500)) |
| 78 | + .then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT)) |
| 79 | + .then(ui.expectStruct({name:'Step1 lastTestIPromise'})) |
| 80 | + .catch(common.oops(this)) |
| 81 | + })) |
| 82 | + |
| 83 | + it(`should show ${actionName2} with wsk activation get --last ${actionName2}`, () => this.app.client.waitUntil(() => { |
| 84 | + return cli.do(`wsk activation get --last ${actionName2}`, this.app) |
| 85 | + .then(cli.expectOK) |
| 86 | + .then(sidecar.expectOpen) |
| 87 | + .then(sidecar.expectShowing(actionName2, undefined, undefined, undefined, undefined, 500)) |
| 88 | + .then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT)) |
| 89 | + .then(ui.expectStruct({name:'Step1 lastTestIPromise'})) |
| 90 | + .catch(common.oops(this)) |
| 91 | + })) |
| 92 | +}) |
0 commit comments