Skip to content

Commit

Permalink
Fix new functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Dec 18, 2019
1 parent be46a67 commit ce57c16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/plugin_functional/plugins/core_plugin_b/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class CorePluginBPlugin implements Plugin {

router.post(
{
path: '/core_plugin_b/:id',
path: '/core_plugin_b',
validate: {
params: schema.object({ id: schema.string() }),
query: schema.object({ id: schema.string() }),
body: ({ ok, fail }, { bar, baz } = {}) => {
if (typeof bar === 'string' && bar === baz) {
return ok({ bar, baz });
Expand All @@ -51,7 +51,7 @@ export class CorePluginBPlugin implements Plugin {
},
},
async (context, req, res) => {
return res.ok({ body: `ID: ${req.params.id} - ${req.body.bar.toUpperCase()}` });
return res.ok({ body: `ID: ${req.query.id} - ${req.body.bar.toUpperCase()}` });
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ export default function({ getService }: PluginFunctionalProviderContext) {

it('extend request handler context with validation', async () => {
await supertest
.post('/core_plugin_b/TEST')
.post('/core_plugin_b')
.set('kbn-xsrf', 'anything')
.query({ id: 'TEST' })
.send({ bar: 'hi!', baz: 'hi!' })
.expect(200)
.expect('ID: TEST - HI!');
});

it('extend request handler context with validation', async () => {
it('extend request handler context with validation (400)', async () => {
await supertest
.post('/core_plugin_b/TEST')
.post('/core_plugin_b')
.set('kbn-xsrf', 'anything')
.query({ id: 'TEST' })
.send({ bar: 'hi!', baz: 1234 })
.expect(400)
.expect({
Expand Down

0 comments on commit ce57c16

Please sign in to comment.