Skip to content
Open
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
55 changes: 55 additions & 0 deletions Alfie/Alfie.xcodeproj/xcshareddata/xcschemes/AlfieUITests.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BE8B023D2B616979007AE489"
BuildableName = "AlfieUITests.xctest"
BlueprintName = "AlfieUITests"
ReferencedContainer = "container:Alfie.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
39 changes: 34 additions & 5 deletions Alfie/AlfieUITests/AlfieUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,41 @@ final class AlfieUITests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// UI tests must launch the application that they test.
func testAddToCartFullFlow() throws {
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
app.activate()
app/*@START_MENU_TOKEN@*/.images["storefront"]/*[[".otherElements[\"shop-tab\"].images",".otherElements.images[\"storefront\"]",".images[\"storefront\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.firstMatch.tap()
app/*@START_MENU_TOKEN@*/.scrollViews.buttons["Brands"].firstMatch/*[[".buttons",".matching(identifier: \"Brands\")",".element(boundBy: 1)",".containing(.staticText, identifier: \"Brands\").firstMatch",".matching(identifier: \"category-item\").containing(.staticText, identifier: \"Brands\").firstMatch",".scrollViews.buttons[\"Brands\"].firstMatch"],[[[-1,5],[-1,0,1]],[[-1,3],[-1,4],[-1,1,2]],[[-1,3],[-1,2]]],[0]]@END_MENU_TOKEN@*/.tap()
app/*@START_MENU_TOKEN@*/.buttons["04AugPhilos"]/*[[".otherElements.buttons[\"04AugPhilos\"]",".buttons[\"04AugPhilos\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.firstMatch.tap()
app.images.matching(identifier: "product-image").element(boundBy: 0).tap()

// Wait for PDP to load and capture product name from the title header
let addToBagButton = app.buttons["Add to bag"]
XCTAssertTrue(addToBagButton.waitForExistence(timeout: 5), "Add to bag button should exist")

// The product name is shown in the title header - get the first static text in the scroll view content
// which contains the product name (displayed in titleHeader view)
let productNameOnPDP = app.scrollViews.firstMatch.staticTexts.firstMatch
XCTAssertTrue(productNameOnPDP.waitForExistence(timeout: 5), "Product name should be visible on PDP")
let expectedProductName = productNameOnPDP.label

// Tap "Add to bag" button
addToBagButton.tap()

// Navigate back from PDP - tap the first button in navigation bar
let backButton = app.navigationBars.buttons.firstMatch
XCTAssertTrue(backButton.waitForExistence(timeout: 5), "Back button should exist")
backButton.tap()

// Navigate to bag tab
let bagTab = app.otherElements["bag-tab"]
XCTAssertTrue(bagTab.waitForExistence(timeout: 5), "Bag tab should exist")
bagTab.tap()

// Verify the product in the bag matches the one we added
let productNameInBag = app.staticTexts.matching(identifier: "product-name").firstMatch
XCTAssertTrue(productNameInBag.waitForExistence(timeout: 5), "Product name should be visible in bag")
XCTAssertEqual(productNameInBag.label, expectedProductName, "Product in bag should match the product that was added")
}

func testLaunchPerformance() throws {
Expand Down