Skip to content

Commit

Permalink
Fix crash when calling showPreferences
Browse files Browse the repository at this point in the history
  • Loading branch information
pmerlet-at-didomi committed Jan 16, 2025
1 parent 229befe commit e69b5d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions ios/RNDidomi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class RNDidomi: RCTEventEmitter {

@objc(showPreferences:resolve:reject:)
dynamic func showPreferences(view: String?, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
if let containerController = RCTPresentedViewController() {
DispatchQueue.main.async {
DispatchQueue.main.async {
if let containerController = RCTPresentedViewController() {
if let view = view {
let preferencesView: Didomi.Views = view.lowercased() == "vendors" ? .vendors : .purposes
Didomi.shared.showPreferences(controller: containerController, view: preferencesView)
Expand Down
30 changes: 11 additions & 19 deletions test/ios/DidomiUITests/DidomiUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,13 @@ class DidomiUITests: XCTestCase {
tapButton(in: app, name: "reset")
tapButton(in: app, name: "showPreferences Purposes")

let dismissButton = app.staticTexts["Dismiss"]
dismissButton.wait()
dismissButton.tap()

// Check opening of preferences
// let preferencesButton = app.staticTexts["Agree to all"]
// preferencesButton.wait()
// testLastEvent(app: app, name:"on_show_preferences")
let preferencesButton = app.staticTexts["Agree to all"]
preferencesButton.wait()
testLastEvent(app: app, name:"on_show_preferences")

// Close notice
// preferencesButton.tap()
preferencesButton.tap()

assertResult(in: app, name: "showPreferences Purposes", expected: "showPreferences Purposes-OK")
testLastEvent(app: app, name:"on_hide_notice")
Expand All @@ -177,22 +173,18 @@ class DidomiUITests: XCTestCase {
tapButton(in: app, name: "reset")
tapButton(in: app, name: "showPreferences Vendors")

let dismissButton = app.staticTexts["Dismiss"]
dismissButton.wait()
dismissButton.tap()

// Check opening of vendors
// let vendorsButton = app.staticTexts["Save"]
// vendorsButton.wait()
// testLastEvent(app: app, name:"on_show_preferences")
let vendorsButton = app.staticTexts["Save"]
vendorsButton.wait()
testLastEvent(app: app, name:"on_show_preferences")

// Close notice
// vendorsButton.tap()
vendorsButton.tap()

// Close preferences
// let preferencesButton = app.staticTexts["Agree to all"]
// preferencesButton.wait()
// preferencesButton.tap()
let preferencesButton = app.staticTexts["Agree to all"]
preferencesButton.wait()
preferencesButton.tap()

assertResult(in: app, name: "showPreferences Vendors", expected: "showPreferences Vendors-OK")
testLastEvent(app: app, name:"on_hide_notice")
Expand Down

0 comments on commit e69b5d9

Please sign in to comment.