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