Merge pull request #4414 from mslourens/preview_rest_query
Fix validation for query preview endpoint
This commit is contained in:
commit
f894fe624a
3 changed files with 20 additions and 4 deletions
|
@ -31,8 +31,14 @@ exports.generateQueryValidation = () => {
|
||||||
exports.generateQueryPreviewValidation = () => {
|
exports.generateQueryPreviewValidation = () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return joiValidator.body(Joi.object({
|
return joiValidator.body(Joi.object({
|
||||||
|
_id: Joi.string().optional(),
|
||||||
|
_rev: Joi.string().optional(),
|
||||||
|
readable: Joi.boolean().optional(),
|
||||||
fields: Joi.object().required(),
|
fields: Joi.object().required(),
|
||||||
queryVerb: Joi.string().allow().required(),
|
queryVerb: Joi.string().allow().required(),
|
||||||
|
name: Joi.string().required(),
|
||||||
|
flags: Joi.object().optional(),
|
||||||
|
schema: Joi.object().optional(),
|
||||||
extra: Joi.object().optional(),
|
extra: Joi.object().optional(),
|
||||||
datasourceId: Joi.string().required(),
|
datasourceId: Joi.string().required(),
|
||||||
transformer: Joi.string().optional(),
|
transformer: Joi.string().optional(),
|
||||||
|
|
|
@ -169,6 +169,7 @@ describe("/queries", () => {
|
||||||
parameters: {},
|
parameters: {},
|
||||||
fields: {},
|
fields: {},
|
||||||
queryVerb: "read",
|
queryVerb: "read",
|
||||||
|
name: datasource.name,
|
||||||
})
|
})
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
|
@ -261,9 +262,13 @@ describe("/queries", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("check that it automatically retries on fail with cached dynamics", async () => {
|
it("check that it automatically retries on fail with cached dynamics", async () => {
|
||||||
const { datasource, query: base } = await config.dynamicVariableDatasource()
|
const { datasource, query: base } =
|
||||||
|
await config.dynamicVariableDatasource()
|
||||||
// preview once to cache
|
// preview once to cache
|
||||||
await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" })
|
await preview(datasource, {
|
||||||
|
path: "www.google.com",
|
||||||
|
queryString: "test={{ variable3 }}",
|
||||||
|
})
|
||||||
// check its in cache
|
// check its in cache
|
||||||
const contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
const contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
||||||
expect(contents.rows.length).toEqual(1)
|
expect(contents.rows.length).toEqual(1)
|
||||||
|
@ -276,9 +281,13 @@ describe("/queries", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes variables when linked query is deleted", async () => {
|
it("deletes variables when linked query is deleted", async () => {
|
||||||
const { datasource, query: base } = await config.dynamicVariableDatasource()
|
const { datasource, query: base } =
|
||||||
|
await config.dynamicVariableDatasource()
|
||||||
// preview once to cache
|
// preview once to cache
|
||||||
await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" })
|
await preview(datasource, {
|
||||||
|
path: "www.google.com",
|
||||||
|
queryString: "test={{ variable3 }}",
|
||||||
|
})
|
||||||
// check its in cache
|
// check its in cache
|
||||||
let contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
let contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
||||||
expect(contents.rows.length).toEqual(1)
|
expect(contents.rows.length).toEqual(1)
|
||||||
|
|
|
@ -393,6 +393,7 @@ class TestConfiguration {
|
||||||
parameters: {},
|
parameters: {},
|
||||||
fields,
|
fields,
|
||||||
queryVerb: "read",
|
queryVerb: "read",
|
||||||
|
name: datasource.name,
|
||||||
})
|
})
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
|
|
Loading…
Reference in a new issue