From d18514e67d3af0e2f0e713f3694ed6dbf4eab5a5 Mon Sep 17 00:00:00 2001 From: Build Pipeline Date: Tue, 4 Apr 2023 18:19:26 +0200 Subject: [PATCH] test: tes a complete OpenAI flow #18 --- PlantUMLApp.xcodeproj/project.pbxproj | 2 + .../xcshareddata/xcschemes/PlantUML.xcscheme | 14 +--- PlantUMLAppUITests/PlantUMLAppUITests.swift | 76 ++++++++++++++----- 3 files changed, 61 insertions(+), 31 deletions(-) diff --git a/PlantUMLApp.xcodeproj/project.pbxproj b/PlantUMLApp.xcodeproj/project.pbxproj index 67d03a7..aa68fce 100644 --- a/PlantUMLApp.xcodeproj/project.pbxproj +++ b/PlantUMLApp.xcodeproj/project.pbxproj @@ -641,6 +641,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 48J595L9BX; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.5; MARKETING_VERSION = 1.0; @@ -663,6 +664,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 48J595L9BX; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.5; MARKETING_VERSION = 1.0; diff --git a/PlantUMLApp.xcodeproj/xcshareddata/xcschemes/PlantUML.xcscheme b/PlantUMLApp.xcodeproj/xcshareddata/xcschemes/PlantUML.xcscheme index 538e9e3..dcf10a9 100644 --- a/PlantUMLApp.xcodeproj/xcshareddata/xcschemes/PlantUML.xcscheme +++ b/PlantUMLApp.xcodeproj/xcshareddata/xcschemes/PlantUML.xcscheme @@ -26,7 +26,9 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + language = "en" + region = "IT"> @@ -38,16 +40,6 @@ ReferencedContainer = "container:PlantUMLApp.xcodeproj"> - - - - diff --git a/PlantUMLAppUITests/PlantUMLAppUITests.swift b/PlantUMLAppUITests/PlantUMLAppUITests.swift index fba6bdc..11dc8cf 100644 --- a/PlantUMLAppUITests/PlantUMLAppUITests.swift +++ b/PlantUMLAppUITests/PlantUMLAppUITests.swift @@ -11,11 +11,6 @@ import XCTest // table extension extension XCUIElement { - // [UI Testing swipe-to-delete table view cell](https://stackoverflow.com/a/40199269/521197) - func deleteRow() { - XCTAssertEqual( self.elementType, XCUIElement.ElementType.cell) - self.longSwipeLeft() - } // [Perform a full swipe left action in UI Tests?](https://stackoverflow.com/a/51639973) func longSwipeLeft() { @@ -34,14 +29,6 @@ extension XCUIElement { extension XCUIElementQuery { - func deleteRows() { - for _ in 0.. 0) + + let e = query.element(boundBy: 0) + XCTAssertEqual( e.elementType, XCUIElement.ElementType.cell) + e.press(forDuration: 2.0 ) + + // [iOS UI testing: element descendants](https://pgu.dev/2020/12/20/ios-ui-tests-element-descendants.html) + print( "delete: \(app.collectionViews.buttons["Delete"].exists)" ) + print( "elimina: \(app.collectionViews.buttons["Elimina"].exists)" ) + + } func testOpenAI() throws { // UI tests must launch the application that they test. let app = XCUIApplication() @@ -93,6 +111,8 @@ final class PlantUMLAppUITests: XCTestCase { XCTAssertTrue(cell.exists) + wait( reason: "wait before open diagram", timeout: 3.0 ) + cell.tap() XCTAssertTrue( app.tables.element.waitForExistence(timeout: 10) ) @@ -119,16 +139,25 @@ final class PlantUMLAppUITests: XCTestCase { app.buttons["openai_submit"].tap() - self.waitUntilEnabled(element: app.buttons["openai_submit"], timeout: 30.0) + self.waitUntilEnabled(element: app.buttons["openai_submit"], timeout: 30.0) } - openaiSubmit( "set title UML meets AI" ) + openaiSubmit( "set title PlantUML meets OpenAI" ) openaiSubmit( "make simple sequence diagram" ) openaiSubmit( "sequence representing a microservice invoked using an api key" ) openaiSubmit( "put in evidence participants" ) openaiSubmit( "add validation api key" ) openaiSubmit( "grouping api key validation as security" ) + openaiSubmit( "remove useless (JWT) comment" ) + + app.buttons["openai"].tap() + + wait( reason: "wait before exit", timeout: 5.0 ) + + app.buttons["editor"].tap() + + wait( reason: "wait before exit", timeout: 5.0 ) // [How to access back bar button item in universal way under UITests in Xcode?](https://stackoverflow.com/a/38595332/521197) app.navigationBars.buttons.element(boundBy: 0).tap() @@ -139,8 +168,15 @@ final class PlantUMLAppUITests: XCTestCase { XCTAssertTrue(query.element.exists) - query.deleteRows() - + for _ in 0..