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
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ class GiniBankSDKExampleUITests: XCTestCase {
var transactionSummaryScreen: TransactionSummaryScreen!
var noResultsScreen: NoResultsScreen!
var cxExtractionScreen: CXExtractionScreen!
var isSimulator = true

/**
Override in a subclass to inject extra launch arguments before the app launches.
The base argument `-StartFromCleanState YES` is always included.
*/
var additionalLaunchArguments: [String] { [] }

override func setUpWithError() throws {
Comment on lines 29 to 31

if isSimulator {
throw XCTSkip("Skipping test")
}
#if targetEnvironment(simulator)
throw XCTSkip("Skipping test on simulator")
#endif
Comment on lines +32 to +34
continueAfterFailure = false
app = XCUIApplication()
if #available(iOS 13.4, *) {
Expand Down Expand Up @@ -67,13 +59,13 @@ class GiniBankSDKExampleUITests: XCTestCase {
}

override func tearDownWithError() throws {
#if !targetEnvironment(simulator)
let screenshot = XCUIScreen.main.screenshot()
let attachment = XCTAttachment(screenshot: screenshot)
if !isSimulator {
attachment.lifetime = .deleteOnSuccess
add(attachment)
app.terminate()
}
attachment.lifetime = .deleteOnSuccess
Comment on lines 61 to +65
add(attachment)
app.terminate()
#endif
}

var galleryTitle: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
"skonto_valid" file with valid skonto
*/

func testSkonto() {
/**
Verifies the complete Skonto flow is reachable when a document is uploaded via the Files app.
This test focuses on the Files upload path — Skonto state assertions are covered by dedicated state tests.

Pre-condition: the `skonto_valid` file must be available in the Files app on the device or simulator.
*/
func testSkontoFullFlowWithDiscountViaFiles() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
//Handle Camera access pop up
Expand All @@ -25,8 +31,16 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
onboadingScreen.skipOnboardingScreens()
//Tap Files button
captureScreen.filesButton.tap()
//Tap Upload photo button
//Tap Upload files button
captureScreen.uploadFilesButton.tap()
//TODO: Check if we need this or the below implementation `tapFileFromBestAvailableSource`
// //Tap valid skonto document
// mainScreen.tapFileWithName(fileName: TestFixtures.Files.skontoValid)
// //Tap Open button
// captureScreen.openGalleryButton.tap()
// //Assert Skonto screen appeared — proves Files upload was processed successfully
// XCTAssertTrue(skontoScreen.proceedButton.waitForExistence(timeout: 10))
Comment on lines +36 to +42

//tap Skonto document
mainScreen.tapFileFromBestAvailableSource(fileName: TestFixtures.Files.skontoPast)
//Open button appears on some iOS versions/flows; safe to skip if absent.
Expand All @@ -50,6 +64,41 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
XCTAssertTrue(mainScreen.photoPaymentButton.isHittable)
}


/**
Verifies the complete Skonto flow is reachable when a document is uploaded via the photo gallery.
This test focuses on the gallery upload path — Skonto state assertions are covered by dedicated state tests.

Pre-condition: add the `skonto_valid` image (PNG or JPG) to the simulator's photo library before
running this test. The method picks the **last** photo in the library, so make sure it is the most
recently added one.
*/
func testSkontoFullFlowWithDiscountViaGallery() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
//Handle Camera access pop up
mainScreen.handleCameraPermission(answer: true)
//Skip onboarding
onboadingScreen.skipOnboardingScreens()
//Tap Files button to open the upload menu
captureScreen.filesButton.tap()
//Tap Upload photo button to open the photo library picker
captureScreen.uploadPhotoButton.tap()
//Handle photo library permission alert if it appears
mainScreen.handlePhotoPermission(answer: true)
//Select the latest photo from the gallery (skonto_valid image)
uploadLatestPhotoFromGallery()
//Wait for ReviewViewController and tap Process to trigger analysis
XCTAssertTrue(reviewScreen.processButton.waitForExistence(timeout: 10))
reviewScreen.waitForElementToBecomeEnabled(reviewScreen.processButton)
reviewScreen.processButton.tap()
//Wait for analysis screen to finish if it appears
waitForAnalysisIfNeeded()
//Assert Skonto screen appeared — proves gallery upload was processed successfully
XCTAssertTrue(skontoScreen.proceedButton.waitForExistence(timeout: 10))
}


func testSkontoBackButton() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
Expand Down Expand Up @@ -118,7 +167,7 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
}


func testSkontoInFuture() {
func testSkontoSwitchEnabledForValidDiscount() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
//Handle Camera access pop up
Expand All @@ -130,6 +179,15 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
//Tap Upload photo button
captureScreen.uploadFilesButton.tap()
//tap Skonto document

//TODO: Check if we need this or the below implementation `tapFileFromBestAvailableSource`
// mainScreen.tapFileWithName(fileName: TestFixtures.Files.skontoValid)
// //tap Open button
// captureScreen.openGalleryButton.tap()
// //Assert Skonto screen is shown (Got it button does NOT appear for valid/future skonto)
// XCTAssertTrue(skontoScreen.proceedButton.waitForExistence(timeout: 10))
// //Assert that Switch is enabled for valid skonto

Comment on lines +183 to +190
mainScreen.tapFileFromBestAvailableSource(fileName: TestFixtures.Files.skontoValid)
//Open button appears on some iOS versions/flows; safe to skip if absent.
if captureScreen.openGalleryButton.waitForExistence(timeout: 3) {
Expand All @@ -141,7 +199,7 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
XCTAssertTrue((skontoScreen.skontoSwitch.value != nil), "1")
}

func testSkontoInPast() {
func testSkontoSwitchDisabledForExpiredDiscount() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
//Handle Camera access pop up
Expand All @@ -153,18 +211,26 @@ class GiniSkontoScreenUITests: GiniBankSDKExampleUITests {
//Tap Upload photo button
captureScreen.uploadFilesButton.tap()
//tap Skonto document

//TODO: Check if we need this or the below implementation `tapFileFromBestAvailableSource`
// mainScreen.tapFileWithName(fileName: TestFixtures.Files.skontoPast)
// //tap Open button
// captureScreen.openGalleryButton.tap()
// //Assert that Got it button is displayed for expired skonto

Comment on lines +215 to +220
mainScreen.tapFileFromBestAvailableSource(fileName: TestFixtures.Files.skontoPast)
//Open button appears on some iOS versions/flows; safe to skip if absent.
if captureScreen.openGalleryButton.waitForExistence(timeout: 3) {
captureScreen.openGalleryButton.tap()
}
//Assert that Got it button is displayed

XCTAssertTrue(skontoScreen.gotItButton.waitForExistence(timeout: 10))
//Assert that Switch is disabled
//Assert that Switch is disabled for expired skonto
XCTAssertTrue((skontoScreen.skontoSwitch.value != nil), "0")
}
Comment on lines 228 to 231

func testSkontoHelpButtonbo() {
func testSkontoHelpButton() {
//Tap Photopayment button
mainScreen.photoPaymentButton.tap()
//Handle Camera access pop up
Expand Down
Loading