Fix tests

This commit is contained in:
Adria Navarro 2023-09-13 12:23:59 +02:00
parent ceb3129e22
commit 6bae382d81
2 changed files with 11 additions and 2 deletions

View File

@ -78,9 +78,9 @@ export async function save(ctx: UserCtx<SaveTableRequest, SaveTableResponse>) {
ctx.status = 200 ctx.status = 200
ctx.message = `Table ${table.name} saved successfully.` ctx.message = `Table ${table.name} saved successfully.`
ctx.eventEmitter && ctx.eventEmitter &&
ctx.eventEmitter.emitTable(`table:save`, appId, savedTable) ctx.eventEmitter.emitTable(`table:save`, appId, { ...savedTable })
ctx.body = savedTable ctx.body = savedTable
builderSocket?.emitTableUpdate(ctx, savedTable) builderSocket?.emitTableUpdate(ctx, { ...savedTable })
} }
export async function destroy(ctx: UserCtx) { export async function destroy(ctx: UserCtx) {

View File

@ -557,6 +557,11 @@ class TestConfiguration {
return this.updateTable(config, options) return this.updateTable(config, options)
} }
async getTable(tableId?: string) {
tableId = tableId || this.table!._id!
return this._req(null, { tableId }, controllers.table.find)
}
async createLinkedTable( async createLinkedTable(
config?: Table, config?: Table,
relationshipType = RelationshipType.ONE_TO_MANY, relationshipType = RelationshipType.ONE_TO_MANY,
@ -607,6 +612,10 @@ class TestConfiguration {
return this.api.row.save(tableId!, config) return this.api.row.save(tableId!, config)
} }
async getRow(tableId: string, rowId: string): Promise<Row> {
return this._req(null, { tableId, rowId }, controllers.row.find)
}
async getRows(tableId: string) { async getRows(tableId: string) {
if (!tableId && this.table) { if (!tableId && this.table) {
tableId = this.table._id! tableId = this.table._id!