Skip to content

Conversation

@NurhayatYurtaslan
Copy link
Contributor

📋 PR Description

🎯 Purpose

This PR introduces comprehensive unit tests for SnackbarHelper and ToastHelper, ensuring that both components are fully covered under different scenarios. These tests enhance the reliability of critical user feedback mechanisms.

✅ SnackbarHelper Test Coverage

📂 Tested Functions & Scenarios

Function Description Test Name
showSnackbar - View Addition Verifies that the snackbar view is correctly added to the parent view hierarchy. testShowSnackbarAddsViewToViewController
showSnackbar - Auto Dismiss Ensures snackbar disappears after the specified duration. testSnackbarDisappearsAfterDuration
showSnackbar - Fade-in & Fade-out Validates smooth appearance (fade-in) and disappearance (fade-out) animations. testSnackbarFadesInAndOut
showSnackbar - Text Wrapping Checks that long title and description text wrap correctly within the snackbar. testSnackbarHandlesLongText
showSnackbar - Nil Description Handling Ensures snackbar behaves correctly when description is nil (only title should be shown). testSnackbarHandlesNilDescription

📄 SnackbarHelper Test Summary

  • Focuses on lifecycle management (addition/removal).
  • Covers animation correctness (fade-in/out).
  • Tests dynamic content handling (long text, missing description).

✅ ToastHelper Test Coverage

📂 Tested Functions & Scenarios

Function Description Test Name
showToast - View Addition Verifies that the toast view is correctly added to the parent view hierarchy. testShowToastAddsViewToViewController
showToast - Auto Dismiss Ensures toast disappears after the specified duration. testToastDisappearsAfterDuration
showToast - Fade-in & Fade-out Validates smooth appearance (slide-in) and disappearance (slide-out) animations. testToastFadesInAndOut
showToast - Appearance Validation Checks background color, text color, and icon appearance based on ToastType. testToastAppearanceMatchesType
showToast - Custom Type Handling Tests custom toast types with dynamic colors, text, and icons provided via ToastType.custom. testCustomToastType

📄 ToastHelper Test Summary

  • Focuses on lifecycle management (addition/removal).
  • Covers animation correctness (slide-in/out).
  • Ensures appearance consistency across all ToastType variants.
  • Special case: ToastType.custom fully tested for icon, background, and text color.

🌐 Why It Matters

These components (SnackbarHelper and ToastHelper) are critical for communicating system feedback to users. Ensuring they work reliably under various scenarios directly improves UX consistency and robustness. This test suite acts as:

  • A safety net for future refactoring.
  • A regression guard for visual and functional issues.
  • A confidence booster for future feature extensions (like adding new ToastType or SnackbarType).

📊 Overall Test Summary

Helper Total Tests Coverage
SnackbarHelper 5 ✅ Full
ToastHelper 5 ✅ Full

🧰 Test Logging

  • All tests use LoggerHelper for structured test logs.
  • Logs indicate each phase (setup, action, assertion) to improve CI/CD observability.

📌 Notes

  • These tests are structured to be self-contained and independent.
  • Each test prepares its own view controller, ensuring no shared state pollution.
  • All animation-based assertions leverage layoutIfNeeded() to enforce layout pass.

✅ Checklist

  • Code follows the project standards and guidelines.
  • Relevant unit tests are written and all tests are passing.
  • Test coverage is adequate for the changes.
  • Any unnecessary files or debug statements have been removed.
  • Documentation is updated where necessary.
  • The PR has been reviewed by at least one team member before merging.

🛠 Steps to Test

This section explains how to manually verify the changes introduced in this PR.
Follow the steps below to ensure SnackbarHelper and ToastHelper are correctly tested and validated.

1️⃣ Setup

  • Make sure your project builds successfully.
  • Ensure that SnackbarHelperTests and ToastHelperTests are part of the active test target.
  • Open XCTestNavigator (⌘ + 6) to view all test cases.

2️⃣ Execute Tests

  • Run all tests using the shortcut:
    ⌘ + U
    
  • Alternatively, run only these specific test classes:
    • SnackbarHelperTests
    • ToastHelperTests

3️⃣ Review Logs (Optional)

  • Open the Console Output tab in Xcode to observe real-time logs produced by LoggerHelper.
  • Log messages will indicate:
    • Test start and end.
    • Validation expectations.
    • Success and failure points.

4️⃣ Validate Results

  • Ensure all tests pass.
  • In case of failure, review:
    • Test logs (from LoggerHelper)
    • Failure messages in the Xcode Test Navigator (⌘ + 5)

5️⃣ Visual Verification (Extra)

Although these are unit tests, if you want to manually observe the actual Snackbar and Toast UI:

  • Temporarily call SnackbarHelper.shared.showSnackbar() and ToastHelper.shared.showToast() inside your app’s view controller.
  • Run the app and trigger these manually to see them appear on screen.

✅ Final Check

  • All tests green? 🎉
  • Logs clean and readable? ✅
  • Ready to merge? 🚀

💻 Contributors


📷 Screenshots (Optional)

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant