import XCTest final class ChatUITests: XCTestCase { func testNativeTextChatWithoutVoiceAndAccountPrivacy() { let app = XCUIApplication() app.launchArguments = ["--ui-testing", "--reset-ui-testing", "--ui-chat"] app.launch() XCTAssertTrue(app.navigationBars["Chats"].waitForExistence(timeout: 10)) app.buttons["New chat"].tap() let field = app.textFields["chat-draft"] XCTAssertTrue(field.waitForExistence(timeout: 10)) field.tap(); field.typeText("Native offline text") app.buttons["Send message"].tap() XCTAssertTrue(app.staticTexts["Native offline text"].waitForExistence(timeout: 10)) XCTAssertTrue(app.staticTexts["Offline reply"].exists) capture(app, "Native chat") XCTAssertFalse(app.buttons["End conversation"].exists) app.navigationBars.buttons.element(boundBy: 0).tap() app.buttons["Chat options"].tap() app.buttons["Sign out"].tap() XCTAssertTrue(app.secureTextFields["Password"].waitForExistence(timeout: 10)) XCTAssertFalse(app.staticTexts["Native offline text"].exists) } func testOfflineAdvancedLibraryAndArtifactEditor() { let app = XCUIApplication() app.launchArguments = ["--ui-testing", "--reset-ui-testing", "--ui-chat"] app.launch() XCTAssertTrue(app.buttons["Chat options"].waitForExistence(timeout: 10)) app.buttons["Chat options"].tap(); app.buttons["Library and tools"].tap() XCTAssertTrue(app.buttons["New artifact"].waitForExistence(timeout: 10)) app.buttons["New artifact"].tap() XCTAssertTrue(app.textFields["Title"].waitForExistence(timeout: 10)) app.textFields["Title"].tap(); app.textFields["Title"].typeText("Local artifact") app.textViews.firstMatch.tap(); app.textViews.firstMatch.typeText("Native fixture content") app.buttons["Save"].tap() let artifact = app.buttons.matching(NSPredicate(format: "label CONTAINS 'Local artifact'")).firstMatch XCTAssertTrue(artifact.waitForExistence(timeout: 10)) artifact.tap() XCTAssertTrue(app.textViews.firstMatch.waitForExistence(timeout: 10)) XCTAssertEqual(app.textViews.firstMatch.value as? String, "Native fixture content") capture(app, "Native artifact") app.buttons["Cancel"].tap() app.buttons["Done"].tap() } private func capture(_ app: XCUIApplication, _ name: String) { let attachment = XCTAttachment(screenshot: app.screenshot()); attachment.name = name; attachment.lifetime = .keepAlways; add(attachment) } func testWorkspaceNativeFixture() { let app = XCUIApplication() app.launchArguments = ["--ui-testing", "--reset-ui-testing", "--ui-chat"] app.launch() XCTAssertTrue(app.buttons["Chat options"].waitForExistence(timeout: 10)) app.buttons["Chat options"].tap(); app.buttons["Manage workspaces"].tap() let field = app.textFields["Workspace name"] XCTAssertTrue(field.waitForExistence(timeout: 10)); field.tap(); field.typeText("Writing") app.buttons["Save workspace"].tap() XCTAssertTrue(app.buttons["Writing"].waitForExistence(timeout: 10)) capture(app, "Native workspaces") } func testChatLargeTextAndPreferences() { let app = XCUIApplication() app.launchArguments = ["--ui-testing", "--reset-ui-testing", "--ui-chat", "-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXXXL"] app.launch() XCTAssertTrue(app.buttons["New chat"].waitForExistence(timeout: 10)) app.buttons["Chat options"].tap() app.buttons["Appearance and model"].tap() XCTAssertTrue(app.navigationBars["Chat preferences"].waitForExistence(timeout: 10)) XCTAssertTrue(app.buttons["Save appearance"].exists) capture(app, "Appearance accessibility size") app.buttons["Done"].tap() app.tabBars.buttons["Talk"].tap() XCTAssertTrue(app.buttons["Start chatting"].waitForExistence(timeout: 10)) app.tabBars.buttons["Activity"].tap() XCTAssertTrue(app.staticTexts["No tasks yet"].waitForExistence(timeout: 15)) } }