Undoing change.

This commit is contained in:
mike12345567 2024-02-28 15:19:55 +00:00
parent 56b1855f6a
commit d471a2bf0f
1 changed files with 1972 additions and 1989 deletions

View File

@ -39,9 +39,10 @@ tk.freeze(timestamp)
const { basicRow } = setup.structures const { basicRow } = setup.structures
describe.each([["postgres", databaseTestProviders.postgres]])( describe.each([
"/rows (%s)", ["internal", undefined],
(__, dsProvider) => { ["postgres", databaseTestProviders.postgres],
])("/rows (%s)", (__, dsProvider) => {
const isInternal = !dsProvider const isInternal = !dsProvider
const request = setup.getRequest() const request = setup.getRequest()
@ -110,10 +111,7 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
const getRowUsage = async () => { const getRowUsage = async () => {
const { total } = await config.doInContext(null, () => const { total } = await config.doInContext(null, () =>
quotas.getCurrentUsageValues( quotas.getCurrentUsageValues(QuotaUsageType.STATIC, StaticQuotaName.ROWS)
QuotaUsageType.STATIC,
StaticQuotaName.ROWS
)
) )
return total return total
} }
@ -857,9 +855,7 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
expect(resEnriched.body.link.length).toBe(1) expect(resEnriched.body.link.length).toBe(1)
expect(resEnriched.body.link[0]._id).toBe(firstRow._id) expect(resEnriched.body.link[0]._id).toBe(firstRow._id)
expect(resEnriched.body.link[0].name).toBe("Test Contact") expect(resEnriched.body.link[0].name).toBe("Test Contact")
expect(resEnriched.body.link[0].description).toBe( expect(resEnriched.body.link[0].description).toBe("original description")
"original description"
)
await assertRowUsage(rowUsage) await assertRowUsage(rowUsage)
}) })
}) })
@ -1411,34 +1407,26 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
it("respects the limit parameter", async () => { it("respects the limit parameter", async () => {
await createTable(await userTable()) await createTable(await userTable())
await Promise.all( await Promise.all(Array.from({ length: 10 }, () => config.createRow()))
Array.from({ length: 10 }, () => config.createRow())
)
const limit = generator.integer({ min: 1, max: 8 }) const limit = generator.integer({ min: 1, max: 8 })
const createViewResponse = await config.createView() const createViewResponse = await config.createView()
const response = await config.api.viewV2.search( const response = await config.api.viewV2.search(createViewResponse.id, {
createViewResponse.id,
{
limit, limit,
query: {}, query: {},
} })
)
expect(response.body.rows).toHaveLength(limit) expect(response.body.rows).toHaveLength(limit)
}) })
it("can handle pagination", async () => { it("can handle pagination", async () => {
await createTable(await userTable()) await createTable(await userTable())
await Promise.all( await Promise.all(Array.from({ length: 10 }, () => config.createRow()))
Array.from({ length: 10 }, () => config.createRow())
)
const createViewResponse = await config.createView() const createViewResponse = await config.createView()
const allRows = ( const allRows = (await config.api.viewV2.search(createViewResponse.id))
await config.api.viewV2.search(createViewResponse.id) .body.rows
).body.rows
const firstPageResponse = await config.api.viewV2.search( const firstPageResponse = await config.api.viewV2.search(
createViewResponse.id, createViewResponse.id,
@ -1750,9 +1738,7 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
name: rowData.name, name: rowData.name,
description: rowData.description, description: rowData.description,
tableId, tableId,
users: expect.arrayContaining( users: expect.arrayContaining(selectedUsers.map(u => resultMapper(u))),
selectedUsers.map(u => resultMapper(u))
),
_id: expect.any(String), _id: expect.any(String),
_rev: expect.any(String), _rev: expect.any(String),
id: isInternal ? undefined : expect.any(Number), id: isInternal ? undefined : expect.any(Number),
@ -1801,9 +1787,7 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
description: rowData.description, description: rowData.description,
tableId, tableId,
user: expect.arrayContaining([user1].map(u => resultMapper(u))), user: expect.arrayContaining([user1].map(u => resultMapper(u))),
users: expect.arrayContaining( users: expect.arrayContaining([user2, user3].map(u => resultMapper(u))),
[user2, user3].map(u => resultMapper(u))
),
_id: row._id, _id: row._id,
_rev: expect.any(String), _rev: expect.any(String),
id: isInternal ? undefined : expect.any(Number), id: isInternal ? undefined : expect.any(Number),
@ -2195,5 +2179,4 @@ describe.each([["postgres", databaseTestProviders.postgres]])(
) )
}) })
}) })
} })
)