1
0
Fork 0
mirror of synced 2024-09-12 23:43:09 +12:00

Refactored out config changes and now excluding on the affected SQS/Multiuser tests

This commit is contained in:
Dean 2024-05-07 09:13:43 +01:00
parent c4807a8861
commit 04588711e2
7 changed files with 193 additions and 206 deletions

View file

@ -68,7 +68,7 @@ describe("check the applications endpoints", () => {
describe("check the tables endpoints", () => {
it("should allow retrieving tables through search", async () => {
await config.createApp({ appName: "new app 1" })
await config.createApp("new app 1")
table = await config.upsertTable()
const res = await makeRequest("post", "/tables/search")
expect(res).toSatisfyApiSpec()

View file

@ -179,7 +179,6 @@ describe.each([
}
// Ensure all bindings resolve and perform as expected
!isSqs &&
describe("bindings", () => {
let globalUsers: any = []
@ -335,17 +334,23 @@ describe.each([
])
})
!isSqs &&
it("should match the session user id in a multi user field", async () => {
const allUsers = [...globalUsers, config.getUser()].map((user: any) => {
return { _id: user._id }
})
await expectQuery({
contains: { multi_user: ["{{ [user]._id }}"] },
}).toContainExactly([
{
name: "multi user with session user",
multi_user: [{ _id: config.getUser()._id }],
multi_user: allUsers,
},
])
})
!isSqs &&
it("should not match the session user id in a multi user field", async () => {
await expectQuery({
notContains: { multi_user: ["{{ [user]._id }}"] },

View file

@ -13,7 +13,7 @@ describe("run", () => {
afterAll(config.end)
it("runs successfully", async () => {
const app = await config.createApp({ appName: "testApp" })
const app = await config.createApp("testApp")
const metadata = await dbCore.doWithDB(app.appId, async db => {
const metadataDoc = await db.get(dbCore.DocumentType.APP_METADATA)
delete metadataDoc.url

View file

@ -11,7 +11,7 @@ describe("run", () => {
beforeAll(async () => {
await config.init()
app = await config.createApp({ appName: "testApp" })
app = await config.createApp("testApp")
screen = await config.createScreen()
})

View file

@ -22,7 +22,7 @@ describe("syncApps", () => {
expect(usageDoc.usageQuota.apps).toEqual(3)
// create an extra app to test the migration
await config.createApp({ appName: "quota-test" })
await config.createApp("quota-test")
// migrate
await syncApps.run()

View file

@ -29,7 +29,7 @@ describe("syncRows", () => {
await config.createRow()
})
// app 2
const app2 = await config.createApp({ appName: "second-app" })
const app2 = await config.createApp("second-app")
await context.doInAppContext(app2.appId, async () => {
await config.createTable()
await config.createRow()

View file

@ -224,14 +224,11 @@ export default class TestConfiguration {
// SETUP / TEARDOWN
// use a new id as the name to avoid name collisions
async init(opts = {}) {
async init(appName = newid()) {
if (!this.started) {
await startup()
}
return this.newTenant({
appName: newid(),
...opts,
})
return this.newTenant(appName)
}
end() {
@ -551,14 +548,14 @@ export default class TestConfiguration {
return this.tenantId
}
async newTenant(opts: {}): Promise<App> {
async newTenant(appName = newid()): Promise<App> {
this.csrfToken = generator.hash()
this.tenantId = structures.tenant.id()
this.user = await this.globalUser()
this.userMetadataId = generateUserMetadataID(this.user._id!)
return this.createApp({ appName: newid(), ...opts })
return this.createApp(appName)
}
doInTenant<T>(task: () => T) {
@ -588,9 +585,7 @@ export default class TestConfiguration {
}
// APP
async createApp(opts: CreateAppRequest): Promise<App> {
const { appName, url, snippets } = opts
async createApp(appName: string, url?: string): Promise<App> {
this.appId = undefined
this.app = await context.doInTenant(
this.tenantId!,
@ -602,19 +597,6 @@ export default class TestConfiguration {
)
this.appId = this.app.appId
if (snippets) {
this.app = await this._req(
appController.update,
{
...this.app,
snippets,
},
{
appId: this.appId,
}
)
}
return await context.doInAppContext(this.app.appId!, async () => {
// create production app
this.prodApp = await this.publish()