Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integration tests #8160

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/api/common/threading/Transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Transport<OutgoingCommandType, IncomingCommandType> {
/**
* Set the handler for messages coming from the other end of the transport
*/
setMessageHandler(handler: (message: Message<IncomingCommandType>) => unknown): unknown
setMessageHandler(handler: (message: Message<IncomingCommandType>) => unknown): void
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/main/EntropyCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class EntropyCollector {
}

private addPerformanceTimingValues() {
if (!this.window.performance) return
if (!this.window.performance?.getEntries) return
const entries = this.window.performance.getEntries()
let added: number[] = []
for (const entry of entries.map((e) => e.toJSON())) {
Expand Down
5 changes: 4 additions & 1 deletion src/common/api/main/WorkerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ export class WorkerClient {
const WorkerImpl = globalThis.testWorker
const workerImpl = new WorkerImpl(this, true)
await workerImpl.init(client.browserData())
workerImpl._queue._transport = {
workerImpl._dispatcher.transport = {
postMessage: (msg: any) => this._dispatcher.handleMessage(msg),
}
this._dispatcher = new MessageDispatcher(
{
postMessage: function (msg: any) {
workerImpl._queue.handleMessage(msg)
},
setMessageHandler(handler: (message: any) => unknown): void {
return
},
} as Transport<WorkerRequestType, MainRequestType>,
this.queueCommands(locator),
"main-worker",
Expand Down
3 changes: 2 additions & 1 deletion src/mail-app/mailLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,9 @@ class MailLocator {
}
}
if (this.webAuthn == null) {
const credentials: CredentialsContainer = isTest() ? ({} as CredentialsContainer) : navigator.credentials
this.webAuthn = new WebauthnClient(
new BrowserWebauthn(navigator.credentials, this.domainConfigProvider().getCurrentDomainConfig()),
new BrowserWebauthn(credentials, this.domainConfigProvider().getCurrentDomainConfig()),
this.domainConfigProvider(),
isApp(),
)
Expand Down
6 changes: 4 additions & 2 deletions src/mail-app/workerUtils/worker/WorkerLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export async function initLocator(worker: WorkerImpl, browserData: BrowserData)

const mainInterface = worker.getMainInterface()

const suspensionHandler = new SuspensionHandler(mainInterface.infoMessageHandler, self)
const contextObject = isTest() ? globalThis : self

const suspensionHandler = new SuspensionHandler(mainInterface.infoMessageHandler, contextObject)
locator.instanceMapper = new InstanceMapper()
locator.rsa = await createRsaImplementation(worker)

Expand Down Expand Up @@ -446,7 +448,7 @@ export async function initLocator(worker: WorkerImpl, browserData: BrowserData)
nonCachingEntityClient, // without cache
)
})
const scheduler = new SchedulerImpl(dateProvider, self, self)
const scheduler = new SchedulerImpl(dateProvider, contextObject, contextObject)

locator.configFacade = lazyMemoized(async () => {
const { ConfigurationDatabase } = await import("../../../common/api/worker/facades/lazy/ConfigurationDatabase.js")
Expand Down
3 changes: 2 additions & 1 deletion test/tests/IntegrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { neverNull } from "@tutao/tutanota-utils"
import { initLocator, locator } from "../../src/mail-app/workerUtils/worker/WorkerLocator.js"
import { browserDataStub, createTestEntity } from "./TestUtils.js"
import { SessionType } from "../../src/common/api/common/SessionType.js"
import { object } from "testdouble"

function loadFolders(folderListId: Id): Promise<MailFolder[]> {
return locator.cachingEntityClient.loadAll(MailFolderTypeRef, folderListId)
Expand All @@ -35,7 +36,7 @@ o.spec("integration test", function () {
o("login, read mails, update contact", async function () {
env.staticUrl = "http://localhost:9000"
env.versionNumber
initLocator(null as any, browserDataStub)
initLocator(object(), browserDataStub)
o.timeout(20000)
await locator.login.createSession("[email protected]", "map", "Linux node", SessionType.Temporary, null)
const folders = await loadMailboxSystemFolders()
Expand Down
Loading