1
0
Fork 0
mirror of synced 2024-08-15 18:11:40 +12:00

Change status codes

This commit is contained in:
Adria Navarro 2023-07-18 12:58:48 +02:00
parent 1e6a65d4e9
commit e71d883dfd
5 changed files with 7 additions and 9 deletions

View file

@ -4,7 +4,6 @@ import {
Ctx, Ctx,
FetchViewResponse, FetchViewResponse,
ViewResponse, ViewResponse,
ViewV2,
} from "@budibase/types" } from "@budibase/types"
export async function fetch(ctx: Ctx<void, FetchViewResponse>) { export async function fetch(ctx: Ctx<void, FetchViewResponse>) {
@ -34,10 +33,11 @@ export async function find(ctx: Ctx<void, ViewResponse>) {
} }
} }
export async function save(ctx: Ctx<CreateViewRequest, ViewResponse>) { export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
const view = ctx.request.body const view = ctx.request.body
const result = await sdk.views.save(view) const result = await sdk.views.create(view)
ctx.status = 201
ctx.body = { ctx.body = {
data: { data: {
...view, ...view,

View file

@ -133,9 +133,7 @@ describe("/v2/views", () => {
.send(newView) .send(newView)
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(201)
expect(res.status).toBe(200)
expect(res.body.data._id).toBeDefined()
expect(res.body).toEqual({ expect(res.body).toEqual({
data: { data: {

View file

@ -21,7 +21,7 @@ router
.post( .post(
"/api/v2/views", "/api/v2/views",
authorized(permissions.BUILDER), authorized(permissions.BUILDER),
viewController.v2.save viewController.v2.create
) )
.delete( .delete(
`/api/v2/views/:viewId`, `/api/v2/views/:viewId`,

View file

@ -47,7 +47,7 @@ export async function get(viewId: string): Promise<ViewV2 | undefined> {
} }
} }
export async function save(view: ViewV2): Promise<ViewV2> { export async function create(view: ViewV2): Promise<ViewV2> {
const db = context.getAppDB() const db = context.getAppDB()
const response = await db.put( const response = await db.put(

View file

@ -23,7 +23,7 @@ export class ViewV2API extends TestAPI {
.send(view) .send(view)
.set(this.config.defaultHeaders()) .set(this.config.defaultHeaders())
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(201)
return result.body.data as ViewV2 return result.body.data as ViewV2
} }
get = (viewId: string): supertest.Test => { get = (viewId: string): supertest.Test => {