Skip to content

Commit

Permalink
update bitrise, configs, store setup and teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
cyndichin committed Sep 19, 2024
1 parent 7ea63a2 commit 05b62c7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ workflows:
mkdir DerivedData
xcodebuild -resolvePackageDependencies -onlyUsePackageVersionsFromResolvedFile
xcodebuild "-project" "/Users/vagrant/git/firefox-ios/Client.xcodeproj" "-scheme" "Fennec" -configuration "Fennec" "CODE_SIGNING_ALLOWED=NO" -sdk "iphonesimulator" "-destination" "platform=iOS Simulator,name=iPhone 15,OS=17.5" "COMPILER_INDEX_STORE_ENABLE=NO" "build-for-testing" "CODE_SIGN_IDENTITY=" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGNING_ALLOWED=NO" -derivedDataPath "/Users/vagrant/git/DerivedData" | xcpretty | tee xcodebuild_fennec.log
xcodebuild "-project" "/Users/vagrant/git/firefox-ios/Client.xcodeproj" "-scheme" "Fennec" -configuration "Fennec_Testing" "CODE_SIGNING_ALLOWED=NO" -sdk "iphonesimulator" "-destination" "platform=iOS Simulator,name=iPhone 15,OS=17.5" "COMPILER_INDEX_STORE_ENABLE=NO" "build-for-testing" "CODE_SIGN_IDENTITY=" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGNING_ALLOWED=NO" -derivedDataPath "/Users/vagrant/git/DerivedData" | xcpretty | tee xcodebuild_fennec.log
ls /Users/vagrant/git/DerivedData/Build/Products
ls /Users/vagrant/git/DerivedData
Expand Down
6 changes: 5 additions & 1 deletion firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6990,6 +6990,7 @@
8AED23C427AC1F9500DE7E97 /* BaseContentStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseContentStackView.swift; sourceTree = "<group>"; };
8AED868228CA3B3400351A50 /* BookmarkPanelViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkPanelViewModelTests.swift; sourceTree = "<group>"; };
8AEDB11429F9F00400F2A53B /* SceneContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneContainer.swift; sourceTree = "<group>"; };
8AEDFE802C9CACEC00821359 /* FennecTesting.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = FennecTesting.xcconfig; sourceTree = "<group>"; };
8AEE284A276A973400C7104D /* RatingPromptManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RatingPromptManagerTests.swift; sourceTree = "<group>"; };
8AEE62C62756BA34003207D1 /* LoginsHelper.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = LoginsHelper.js; path = AllFrames/AtDocumentStart/LoginsHelper.js; sourceTree = "<group>"; };
8AEE62C72756BA34003207D1 /* TrackingProtectionStats.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = TrackingProtectionStats.js; path = AllFrames/AtDocumentStart/TrackingProtectionStats.js; sourceTree = "<group>"; };
Expand Down Expand Up @@ -12766,6 +12767,7 @@
8A2B1A5A28216C4C0061216B /* Debug.xcconfig */,
E6DCC1ED1DCBB6AA00CEC4B7 /* Fennec.enterprise.xcconfig */,
E60961861B62B8A700DD640F /* Fennec.xcconfig */,
8AEDFE802C9CACEC00821359 /* FennecTesting.xcconfig */,
E60961891B62B8C800DD640F /* Firefox.xcconfig */,
E6FCC43C1C40565200DF6113 /* FirefoxBeta.xcconfig */,
8A2B1A5C28216C4D0061216B /* Release.xcconfig */,
Expand Down Expand Up @@ -22521,7 +22523,8 @@
"-Xlinker",
"-no_application_extension",
);
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TESTING";
OTHER_SWIFT_FLAGS = "$(OTHER_SWIFT_FLAGS_common) -DMOZ_CHANNEL_FENNEC";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = TESTING;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
VALIDATE_WORKSPACE = YES;
};
Expand All @@ -22545,6 +22548,7 @@
"-ObjC",
"-ld_classic",
);
OTHER_SWIFT_FLAGS = "$(OTHER_SWIFT_FLAGS_common) -DMOZ_CHANNEL_FENNEC -DTESTING";
PRODUCT_BUNDLE_IDENTIFIER = "$(MOZ_BUNDLE_ID)";
PRODUCT_MODULE_NAME = Client;
PRODUCT_NAME = Client;
Expand Down
10 changes: 10 additions & 0 deletions firefox-ios/Client/FennecTesting.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

#include "Fennec.xcconfig"

SWIFT_ACTIVE_COMPILATION_CONDITIONS = -DTESTING;
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ final class MicrosurveyMiddlewareTests: XCTestCase {

override func tearDown() {
DependencyHelperMock().reset()
resetTestingStore()
super.tearDown()
}

func testDismissSurveyAction() throws {
store = Store(
state: setupAppState(),
reducer: AppState.reducer,
middlewares: [MicrosurveyMiddleware().microsurveyProvider]
)
setupTestingStore()

let action = getAction(for: .closeSurvey)
store.dispatch(action)

testEventMetricRecordingSuccess(metric: GleanMetrics.Microsurvey.dismissButtonTapped)
let resultValue = try XCTUnwrap(GleanMetrics.Microsurvey.dismissButtonTapped.testGetValue())
XCTAssertEqual(resultValue[0].extra?["survey_id"], "microsurvey-id")
Expand All @@ -43,14 +41,11 @@ final class MicrosurveyMiddlewareTests: XCTestCase {
}

func testPrivacyNoticeTappedAction() throws {
store = Store(
state: setupAppState(),
reducer: AppState.reducer,
middlewares: [MicrosurveyMiddleware().microsurveyProvider]
)
setupTestingStore()

let action = getAction(for: .tapPrivacyNotice)
store.dispatch(action)

testEventMetricRecordingSuccess(metric: GleanMetrics.Microsurvey.privacyNoticeTapped)
let resultValue = try XCTUnwrap(GleanMetrics.Microsurvey.privacyNoticeTapped.testGetValue())
XCTAssertEqual(resultValue[0].extra?["survey_id"], "microsurvey-id")
Expand All @@ -65,11 +60,7 @@ final class MicrosurveyMiddlewareTests: XCTestCase {
}

func testSubmitSurveyAction() throws {
store = Store(
state: setupAppState(),
reducer: AppState.reducer,
middlewares: [MicrosurveyMiddleware().microsurveyProvider]
)
setupTestingStore()

let action = MicrosurveyAction(
surveyId: "microsurvey-id",
Expand All @@ -78,6 +69,7 @@ final class MicrosurveyMiddlewareTests: XCTestCase {
actionType: MicrosurveyActionType.submitSurvey
)
store.dispatch(action)

testEventMetricRecordingSuccess(metric: GleanMetrics.Microsurvey.submitButtonTapped)
let resultValue = try XCTUnwrap(GleanMetrics.Microsurvey.submitButtonTapped.testGetValue())
XCTAssertEqual(resultValue[0].extra?["survey_id"], "microsurvey-id")
Expand All @@ -93,14 +85,11 @@ final class MicrosurveyMiddlewareTests: XCTestCase {
}

func testConfirmationViewedAction() throws {
store = Store(
state: AppState(),
reducer: AppState.reducer,
middlewares: [MicrosurveyMiddleware().microsurveyProvider]
)
setupTestingStore()

let action = getAction(for: .confirmationViewed)
store.dispatch(action)

testEventMetricRecordingSuccess(metric: GleanMetrics.Microsurvey.confirmationShown)
let resultValue = try XCTUnwrap(GleanMetrics.Microsurvey.confirmationShown.testGetValue())
XCTAssertEqual(resultValue[0].extra?["survey_id"], "microsurvey-id")
Expand Down Expand Up @@ -132,4 +121,22 @@ final class MicrosurveyMiddlewareTests: XCTestCase {
)
)
}

private func setupTestingStore() {
store = Store(
state: setupAppState(),
reducer: AppState.reducer,
middlewares: [MicrosurveyMiddleware().microsurveyProvider]
)
}

// In order to avoid flaky tests, we should reset the store
// similar to production
private func resetTestingStore() {
store = Store(
state: AppState(),
reducer: AppState.reducer,
middlewares: middlewares
)
}
}

0 comments on commit 05b62c7

Please sign in to comment.