This commit is contained in:
Adria Navarro 2024-02-21 10:36:17 +01:00
parent f6e968efe8
commit 0b5226413b
1 changed files with 16 additions and 5 deletions

View File

@ -91,7 +91,6 @@ export default class TestConfiguration {
prodApp: any
prodAppId: any
user: any
globalUserId: any
userMetadataId: any
table?: Table
automation: any
@ -100,6 +99,10 @@ export default class TestConfiguration {
api: API
csrfToken?: string
private get globalUserId() {
return this.user._id
}
constructor(openServer = true) {
if (openServer) {
// use a random port because it doesn't matter
@ -141,6 +144,15 @@ export default class TestConfiguration {
return this.prodAppId
}
getUserDetails() {
return {
globalId: this.globalUserId,
email: this.user.email,
firstName: this.user.firstName,
lastName: this.user.lastName,
}
}
async doInContext<T>(
appId: string | null,
task: () => Promise<T>
@ -432,7 +444,7 @@ export default class TestConfiguration {
defaultHeaders(extras = {}, prodApp = false) {
const tenantId = this.getTenantId()
const authObj: AuthToken = {
userId: this.user.globalUserId,
userId: this.globalUserId,
sessionId: "sessionid",
tenantId,
}
@ -505,8 +517,7 @@ export default class TestConfiguration {
async newTenant(appName = newid()): Promise<App> {
this.tenantId = structures.tenant.id()
this.user = await this.globalUser()
this.globalUserId = this.user._id
this.userMetadataId = generateUserMetadataID(this.globalUserId)
this.userMetadataId = generateUserMetadataID(this.user._id)
this.csrfToken = generator.hash()
return this.createApp(appName)
@ -518,7 +529,7 @@ export default class TestConfiguration {
// API
async generateApiKey(userId = this.user.globalUserId) {
async generateApiKey(userId = this.user._id) {
const db = tenancy.getTenantDB(this.getTenantId())
const id = dbCore.generateDevInfoID(userId)
let devInfo: any