import XCTest @testable import CallsKit final class MeetingLinkTests: XCTestCase { @MainActor func testInvitationOpensInLobbyWithoutJoiningOrStartingAuthentication() { let model = CallsModel(store: MemorySessionStore()) model.openMeetingURL(URL(string: "oficina-calls://join?url=https%3A%2F%2Fcalls.example.com%2Fj%2Finvitation")!) XCTAssertEqual(model.pendingLink, "https://calls.example.com/j/invitation") XCTAssertEqual(model.server, CallsServer.defaultOrigin, "a link never changes the server") XCTAssertFalse(model.joining) XCTAssertFalse(model.authenticating) } @MainActor func testRejectsUntrustedURLShapesAndDoesNotInterruptCall() { let model = CallsModel(store: MemorySessionStore()) for target in ["file:///j/token", "https://user:secret@calls.example.com/j/token", "https://calls.example.com/settings"] { var link = URLComponents(string: "oficina-calls://join")! link.queryItems = [URLQueryItem(name: "url", value: target)] model.openMeetingURL(link.url!) XCTAssertEqual(model.pendingLink, "") XCTAssertFalse(model.error.isEmpty) } model.joining = true model.pendingLink = "current" model.openMeetingURL(URL(string: "oficina-calls://join?url=https%3A%2F%2Fcalls.example.com%2Fm%2Froom")!) XCTAssertEqual(model.pendingLink, "current") XCTAssertTrue(model.joining) } }