This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add webhook-configure-session-parameter-enable-agent-response sample and test Change-Id: Ia8593160ed33060eb497a15723b21c1221ce55c9 * add webhook-configure-session-parameter-trigger-transition sample and test Change-Id: I118abb59182879b6969018da97d04eea0b8daeb0 * add webhook-configure-optional-or-required-form-parameters sample and test Change-Id: I7cbfeb11cece7ccf873dbc7a6dd7cff9ae264ffe * add configure-session-parameters sample and test Change-Id: Ib9f1a110473751508b50259c4696593580c64a91 * fix form parameter path Change-Id: I6411000a7d0240d7552d725c2fd1049be781a9ab * add webhook-validate-form-parameter sample and test Change-Id: I82097be3fc3f91651c88b99c7431ebb602c42c66 * add cx to region tag Change-Id: I6640604512c27a341ab8e26238bf8c3fbd1e77ef * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix test Change-Id: Icc70e18b40d8684c7909e8383b4c226fa94a162b * fix region tag Change-Id: I0fe3849c0eaf12eaf247088993898cbb47dace44 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
39f1d1c
commit 709dc6d
Showing
12 changed files
with
842 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
samples/test/webhook-configure-optional-or-required-form-parameters-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
const {assert} = require('chai'); | ||
const {describe, it} = require('mocha'); | ||
const webhook = require('../webhook-configure-optional-or-required-form-parameters'); | ||
const number = 100; | ||
|
||
describe('configure optional or required form parameter', () => { | ||
it('should test that webhook sets parameter as required', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'required', | ||
}, | ||
pageInfo: { | ||
formInfo: { | ||
parameterInfo: [ | ||
{ | ||
displayName: 'number', | ||
value: number, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.configureOptionalFormParam(JSON.parse(temp), res); | ||
assert.include(response, 'This parameter is required.'); | ||
}); | ||
|
||
it('should test that webhook sets parameter as optional', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'optional', | ||
}, | ||
pageInfo: { | ||
formInfo: { | ||
parameterInfo: [ | ||
{ | ||
displayName: 'number', | ||
value: number, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.configureOptionalFormParam(JSON.parse(temp), res); | ||
assert.include(response, 'This parameter is optional.'); | ||
}); | ||
}); |
90 changes: 90 additions & 0 deletions
90
samples/test/webhook-configure-session-parameters-enable-agent-response-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
const {assert} = require('chai'); | ||
const {describe, it} = require('mocha'); | ||
const webhook = require('../webhook-configure-session-parameters-enable-agent-response'); | ||
const number = 100; | ||
|
||
describe('enable agent response', () => { | ||
it('should test webhook increases value of session parameter', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'increase number', | ||
}, | ||
sessionInfo: { | ||
parameters: { | ||
number: number, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.enableAgentResponse(JSON.parse(temp), res); | ||
assert.include(response, 'increased value'); | ||
}); | ||
|
||
it('should test webhook decreases value of session parameter', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'decrease number', | ||
}, | ||
sessionInfo: { | ||
parameters: { | ||
number: number, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.enableAgentResponse(JSON.parse(temp), res); | ||
assert.include(response, 'decreased value'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
const {assert} = require('chai'); | ||
const {describe, it} = require('mocha'); | ||
const webhook = require('../webhook-configure-session-parameters'); | ||
|
||
describe('configure session parameters', () => { | ||
it('should test that webhook adds new session parameter', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'month', | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.configureSessionParams(JSON.parse(temp), res); | ||
assert.include(response, 'January'); | ||
}); | ||
|
||
it('should test that webhook configures session parameter', async () => { | ||
const request = { | ||
body: { | ||
fulfillmentInfo: { | ||
tag: 'year', | ||
}, | ||
}, | ||
}; | ||
const temp = JSON.stringify(request); | ||
let response = ''; | ||
|
||
const res = { | ||
send: function (s) { | ||
response = JSON.stringify(s); | ||
}, | ||
}; | ||
|
||
webhook.configureSessionParams(JSON.parse(temp), res); | ||
assert.include(response, '1999'); | ||
}); | ||
}); |
Oops, something went wrong.