Skip to content

Commit

Permalink
updated guided tour view tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimet-livefront committed Jan 28, 2025
1 parent 1c3e01d commit ac24665
Show file tree
Hide file tree
Showing 27 changed files with 6 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

@testable import BitwardenShared

// MARK: - GuidedTourViewGeneratorTests
// MARK: - GuidedTourView+GeneratorTests

class GuidedTourViewGeneratorTests: BitwardenTestCase {
// MARK: Properties
Expand All @@ -17,25 +17,6 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {

override func setUp() {
super.setUp()
processor = MockProcessor(
state: GuidedTourViewState(currentIndex: 0, guidedTourStepStates: [
.loginStep1,
.loginStep2,
.loginStep3,
])
)
let store = Store(processor: processor)
subject = GuidedTourView(store: store)
}

override func tearDown() {
super.tearDown()
processor = nil
subject = nil
}

@MainActor
func setupSubjectForGenerator() {
processor = MockProcessor(
state: GuidedTourViewState(currentIndex: 0, guidedTourStepStates: [
.generatorStep1,
Expand All @@ -50,49 +31,17 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
subject = GuidedTourView(store: store)
}

// MARK: Tests

/// Tap the `back` button should dispatch the `backTapped` action.
@MainActor
func test_backButton_tap() async throws {
processor.state.currentIndex = 1
let button = try subject.inspect().find(button: Localizations.back)
try button.tap()
XCTAssertEqual(processor.dispatchedActions, [.backTapped])
}

/// Tapping the `done` button should dispatch the `doneTapped` action.
@MainActor
func test_doneButton_tap() async throws {
processor.state.currentIndex = 2
let button = try subject.inspect().find(button: Localizations.done)
try button.tap()
XCTAssertEqual(processor.dispatchedActions, [.doneTapped])
}

/// Tapping the dismiss button dispatches the `.dismissTapped` action.
@MainActor
func test_dismissButton_tap() async throws {
processor.state.currentIndex = 2
let button = try subject.inspect().find(button: Localizations.dismiss)
try button.tap()
XCTAssertEqual(processor.dispatchedActions, [.dismissTapped])
}

/// Tapping the `next` button should dispatch the `nextTapped` action.
@MainActor
func test_nextButton_tap() async throws {
let button = try subject.inspect().find(button: Localizations.next)
try button.tap()
XCTAssertEqual(processor.dispatchedActions, [.nextTapped])
override func tearDown() {
super.tearDown()
processor = nil
subject = nil
}

// MARK: Snapshot tests

/// Test the snapshot of the step 1 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep1() {
setupSubjectForGenerator()
processor.state.currentIndex = 0
processor.state.guidedTourStepStates[0].spotlightRegion = CGRect(x: 25, y: 80, width: 340, height: 40)
assertSnapshots(
Expand All @@ -104,7 +53,6 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
/// Test the snapshot of the step 2 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep2() {
setupSubjectForGenerator()
processor.state.currentIndex = 1
processor.state.guidedTourStepStates[1].spotlightRegion = CGRect(x: 25, y: 80, width: 340, height: 40)
assertSnapshots(
Expand All @@ -116,7 +64,6 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
/// Test the snapshot of the step 3 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep3() {
setupSubjectForGenerator()
processor.state.currentIndex = 2
processor.state.guidedTourStepStates[2].spotlightRegion = CGRect(x: 25, y: 80, width: 340, height: 40)
assertSnapshots(
Expand All @@ -128,7 +75,6 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
/// Test the snapshot of the step 4 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep4() {
setupSubjectForGenerator()
processor.state.currentIndex = 3
processor.state.guidedTourStepStates[3].spotlightRegion = CGRect(x: 25, y: 300, width: 340, height: 400)
assertSnapshots(
Expand All @@ -140,7 +86,6 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
/// Test the snapshot of the step 5 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep5() {
setupSubjectForGenerator()
processor.state.currentIndex = 4
processor.state.guidedTourStepStates[4].spotlightRegion = CGRect(x: 300, y: 160, width: 40, height: 40)
assertSnapshots(
Expand All @@ -152,78 +97,11 @@ class GuidedTourViewGeneratorTests: BitwardenTestCase {
/// Test the snapshot of the step 6 of the learn generator guided tour.
@MainActor
func test_snapshot_generatorStep6() {
setupSubjectForGenerator()
processor.state.currentIndex = 5
processor.state.guidedTourStepStates[5].spotlightRegion = CGRect(x: 25, y: 160, width: 340, height: 60)
assertSnapshots(
of: subject,
as: [.defaultPortrait]
)
}

/// Test the snapshot of the step 1 of the learn new login guided tour.
@MainActor
func test_snapshot_loginStep1() {
processor.state.currentIndex = 0
processor.state.guidedTourStepStates[0].spotlightRegion = CGRect(x: 320, y: 470, width: 40, height: 40)
assertSnapshots(
of: subject,
as: [.defaultPortrait, .defaultPortraitDark]
)
}

/// Test the snapshot of the step 1 of the learn new login guided tour in landscape.
@MainActor
func test_snapshot_loginStep1_landscape() {
processor.state.currentIndex = 0
processor.state.guidedTourStepStates[0].spotlightRegion = CGRect(x: 650, y: 150, width: 40, height: 40)
assertSnapshots(
of: subject,
as: [.defaultLandscape]
)
}

/// Test the snapshot of the step 2 of the learn new login guided tour.
@MainActor
func test_snapshot_loginStep2() {
processor.state.currentIndex = 1
processor.state.guidedTourStepStates[1].spotlightRegion = CGRect(x: 40, y: 470, width: 320, height: 95)
assertSnapshots(
of: subject,
as: [.defaultPortrait, .defaultPortraitDark]
)
}

/// Test the snapshot of the step 2 of the learn new login guided tour in landscape.
@MainActor
func test_snapshot_loginStep2_landscape() {
processor.state.currentIndex = 1
processor.state.guidedTourStepStates[1].spotlightRegion = CGRect(x: 40, y: 60, width: 460, height: 95)
assertSnapshots(
of: subject,
as: [.defaultLandscape]
)
}

/// Test the snapshot of the step 3 of the learn new login guided tour.
@MainActor
func test_snapshot_loginStep3() {
processor.state.currentIndex = 2
processor.state.guidedTourStepStates[2].spotlightRegion = CGRect(x: 40, y: 500, width: 320, height: 90)
assertSnapshots(
of: subject,
as: [.defaultPortrait, .defaultPortraitDark]
)
}

/// Test the snapshot of the step 3 of the learn new login guided tour in landscape.
@MainActor
func test_snapshot_loginStep3_landscape() {
processor.state.currentIndex = 2
processor.state.guidedTourStepStates[2].spotlightRegion = CGRect(x: 40, y: 60, width: 460, height: 90)
assertSnapshots(
of: subject,
as: [.defaultLandscape]
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,3 @@ class GuidedTourViewLoginTests: BitwardenTestCase {
)
}
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct GeneratorView: View {
let generatorViewFrame = geometryProxy.frame(in: .global)
if globalFrame.maxY > generatorViewFrame.maxY {
visibleFrame.size.height = generatorViewFrame.maxY
- globalFrame.origin.y
- globalFrame.origin.y
}
store.send(
.guidedTourViewAction(.didRenderViewToSpotlight(
Expand Down

0 comments on commit ac24665

Please sign in to comment.