From 3648a4d08dc1d3c7b254868a10a8216a2b741483 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 25 Oct 2023 10:36:11 -0700 Subject: [PATCH 01/37] added mocks for external action and pubsub --- plugins/external-action/mocks/BUILD | 25 +++++++++++++++++ plugins/external-action/mocks/build.bzl | 27 ++++++++++++++++++ .../mocks/external-action.json | 28 +++++++++++++++++++ plugins/external-action/mocks/index.ts | 7 +++++ plugins/pubsub/mocks/BUILD | 25 +++++++++++++++++ plugins/pubsub/mocks/build.bzl | 27 ++++++++++++++++++ plugins/pubsub/mocks/index.ts | 7 +++++ plugins/pubsub/mocks/pub-sub-basic.json | 25 +++++++++++++++++ 8 files changed, 171 insertions(+) create mode 100644 plugins/external-action/mocks/BUILD create mode 100644 plugins/external-action/mocks/build.bzl create mode 100644 plugins/external-action/mocks/external-action.json create mode 100644 plugins/external-action/mocks/index.ts create mode 100644 plugins/pubsub/mocks/BUILD create mode 100644 plugins/pubsub/mocks/build.bzl create mode 100644 plugins/pubsub/mocks/index.ts create mode 100644 plugins/pubsub/mocks/pub-sub-basic.json diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD new file mode 100644 index 000000000..4fb388567 --- /dev/null +++ b/plugins/external-action/mocks/BUILD @@ -0,0 +1,25 @@ +load(":build.bzl", "generate_manifest") +load("//:index.bzl", "javascript_pipeline") + +generate_manifest( + name = "mocks", + mocks = glob(["**/*.json"]), + visibility = ["//visibility:public"], +) + +javascript_pipeline( + name = "@player-ui/external-action-plugin-mocks", + entry = "index.ts", + other_srcs = [ + "index.ts", + ":mocks", + ], + out_dir = "", +) + +java_library( + name = "jar", + resources = [":mocks"], + resource_strip_prefix = "plugins/external-action/mocks", + visibility = ["//visibility:public"], +) diff --git a/plugins/external-action/mocks/build.bzl b/plugins/external-action/mocks/build.bzl new file mode 100644 index 000000000..3515d96e1 --- /dev/null +++ b/plugins/external-action/mocks/build.bzl @@ -0,0 +1,27 @@ +def _generate_manifest(context): + manifest = context.actions.declare_file("manifest.json") + context.actions.write( + output = manifest, + content = json.encode([ + { + "group": group, + "name": name.replace(".json", ""), + "path": "./%s/%s" % (group, name), + } + for group, name in [ + mock.label.name.split("/")[-2:] + for mock in context.attr.mocks + ] + ]), + ) + return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] + +generate_manifest = rule( + attrs = { + "mocks": attr.label_list( + mandatory = True, + allow_files = [".json"], + ), + }, + implementation = _generate_manifest, +) diff --git a/plugins/external-action/mocks/external-action.json b/plugins/external-action/mocks/external-action.json new file mode 100644 index 000000000..348556413 --- /dev/null +++ b/plugins/external-action/mocks/external-action.json @@ -0,0 +1,28 @@ +{ + "id": "test-flow", + "data": { + "transitionValue": "Next" + }, + "navigation": { + "BEGIN": "FLOW_1", + "FLOW_1": { + "startState": "EXT_1", + "EXT_1": { + "state_type": "EXTERNAL", + "ref": "test-1", + "transitions": { + "Next": "END_FWD", + "Prev": "END_BCK" + } + }, + "END_FWD": { + "state_type": "END", + "outcome": "FWD" + }, + "END_BCK": { + "state_type": "END", + "outcome": "BCK" + } + } + } +} \ No newline at end of file diff --git a/plugins/external-action/mocks/index.ts b/plugins/external-action/mocks/index.ts new file mode 100644 index 000000000..727120cf6 --- /dev/null +++ b/plugins/external-action/mocks/index.ts @@ -0,0 +1,7 @@ +export interface Mock { + group: string; + name: string; + path: string; +} + +export type Manifest = Array; diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD new file mode 100644 index 000000000..34c8d09c3 --- /dev/null +++ b/plugins/pubsub/mocks/BUILD @@ -0,0 +1,25 @@ +load(":build.bzl", "generate_manifest") +load("//:index.bzl", "javascript_pipeline") + +generate_manifest( + name = "mocks", + mocks = glob(["**/*.json"]), + visibility = ["//visibility:public"], +) + +javascript_pipeline( + name = "@player-ui/pubsub-plugin-mocks", + entry = "index.ts", + other_srcs = [ + "index.ts", + ":mocks", + ], + out_dir = "", +) + +java_library( + name = "jar", + resources = [":mocks"], + resource_strip_prefix = "plugins/pubsub/mocks", + visibility = ["//visibility:public"], +) diff --git a/plugins/pubsub/mocks/build.bzl b/plugins/pubsub/mocks/build.bzl new file mode 100644 index 000000000..3515d96e1 --- /dev/null +++ b/plugins/pubsub/mocks/build.bzl @@ -0,0 +1,27 @@ +def _generate_manifest(context): + manifest = context.actions.declare_file("manifest.json") + context.actions.write( + output = manifest, + content = json.encode([ + { + "group": group, + "name": name.replace(".json", ""), + "path": "./%s/%s" % (group, name), + } + for group, name in [ + mock.label.name.split("/")[-2:] + for mock in context.attr.mocks + ] + ]), + ) + return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] + +generate_manifest = rule( + attrs = { + "mocks": attr.label_list( + mandatory = True, + allow_files = [".json"], + ), + }, + implementation = _generate_manifest, +) diff --git a/plugins/pubsub/mocks/index.ts b/plugins/pubsub/mocks/index.ts new file mode 100644 index 000000000..727120cf6 --- /dev/null +++ b/plugins/pubsub/mocks/index.ts @@ -0,0 +1,7 @@ +export interface Mock { + group: string; + name: string; + path: string; +} + +export type Manifest = Array; diff --git a/plugins/pubsub/mocks/pub-sub-basic.json b/plugins/pubsub/mocks/pub-sub-basic.json new file mode 100644 index 000000000..fa680c133 --- /dev/null +++ b/plugins/pubsub/mocks/pub-sub-basic.json @@ -0,0 +1,25 @@ + +{ + "id": "minimal", + "views": [ + { + "id": "view-1", + "type": "info" + } + ], + "navigation": { + "BEGIN": "FLOW_1", + "FLOW_1": { + "onStart": "publish('pet.names', ['ginger', 'daisy'])", + "startState": "VIEW_1", + "VIEW_1": { + "ref": "view-1", + "state_type": "VIEW", + "transitions": { + "Next": "VIEW_2", + "'*'": "END_Done" + } + } + } + } +} \ No newline at end of file From 0d148f0b3f73f5b628445eef359277653dff087a Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 25 Oct 2023 12:02:20 -0700 Subject: [PATCH 02/37] modified build --- plugins/external-action/mocks/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD index 4fb388567..4a3d67564 100644 --- a/plugins/external-action/mocks/BUILD +++ b/plugins/external-action/mocks/BUILD @@ -3,7 +3,7 @@ load("//:index.bzl", "javascript_pipeline") generate_manifest( name = "mocks", - mocks = glob(["**/*.json"]), + mocks = glob(["*/*.json"]), visibility = ["//visibility:public"], ) From d03b5f37dc0f3f0ce00135e938faf43756005456 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 25 Oct 2023 15:27:04 -0700 Subject: [PATCH 03/37] pubsub build modified --- plugins/pubsub/mocks/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD index 34c8d09c3..d6a2e9d00 100644 --- a/plugins/pubsub/mocks/BUILD +++ b/plugins/pubsub/mocks/BUILD @@ -3,7 +3,7 @@ load("//:index.bzl", "javascript_pipeline") generate_manifest( name = "mocks", - mocks = glob(["**/*.json"]), + mocks = glob(["*/*.json"]), visibility = ["//visibility:public"], ) From a12cd1efd6b78ad5ae9d810970b220c44f233fd2 Mon Sep 17 00:00:00 2001 From: mercillo Date: Mon, 30 Oct 2023 08:58:56 -0700 Subject: [PATCH 04/37] updated pubsub flow --- plugins/pubsub/mocks/pub-sub-basic.json | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/plugins/pubsub/mocks/pub-sub-basic.json b/plugins/pubsub/mocks/pub-sub-basic.json index fa680c133..c87a91691 100644 --- a/plugins/pubsub/mocks/pub-sub-basic.json +++ b/plugins/pubsub/mocks/pub-sub-basic.json @@ -1,24 +1,36 @@ - { - "id": "minimal", + "id": "generated-flow", "views": [ { - "id": "view-1", - "type": "info" + "id": "action", + "type": "action", + "exp": "@[ publish('some-event', 'event published message') ]@", + "label": { + "asset": { + "id": "action-label", + "type": "text", + "value": "Clicked to publish event" + } + } } ], + "data": { + "count": 0 + }, "navigation": { "BEGIN": "FLOW_1", "FLOW_1": { - "onStart": "publish('pet.names', ['ginger', 'daisy'])", "startState": "VIEW_1", "VIEW_1": { - "ref": "view-1", "state_type": "VIEW", + "ref": "action", "transitions": { - "Next": "VIEW_2", - "'*'": "END_Done" + "*": "END_Done" } + }, + "END_Done": { + "state_type": "END", + "outcome": "done" } } } From 7e28e3e35e6341ee6af3fae8c7ceaa9812cf584c Mon Sep 17 00:00:00 2001 From: zwu01 Date: Tue, 24 Oct 2023 16:11:09 -0400 Subject: [PATCH 05/37] add user info to assetViewModel --- .../reference-assets/Sources/SwiftUI/InputAsset.swift | 5 +++-- .../swiftui/Sources/types/assets/ControlledAsset.swift | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift index a709735d2..c94a01370 100644 --- a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift +++ b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift @@ -47,9 +47,10 @@ open class InputAssetViewModel: AssetViewModel { Constructs the `InputAssetViewModel` - parameters: - data: The `InputData` decoded from the core player + - userInfo: The `userInfo` from the decoder */ - public required init(_ data: InputData) { - super.init(data) + public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]? = nil) { + super.init(data, userInfo: userInfo) $data.sink { [weak self] (newData) in (newData.value?.stringValue).map { self?.text = $0 } }.store(in: &bag) diff --git a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift index 2267a2d99..19ec9699a 100644 --- a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift +++ b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift @@ -15,6 +15,9 @@ open class AssetViewModel: ObservableObject { /// The decoded data @Published public var data: T + /// Any contextual information set by the user + public var userInfo: [CodingUserInfoKey: Any]? + /// Set to store subscriptions in for cancellation public var bag = Set() @@ -22,9 +25,11 @@ open class AssetViewModel: ObservableObject { Constructs an instance of this ViewModel with the given data - parameters: - data: The data to publish from this ViewModel + - userInfo: Any contextual information set by the user */ - public required init(_ data: T) { + public required init(_ data: T, userInfo: [CodingUserInfoKey: Any]? = nil) { self._data = Published(initialValue: data) + self.userInfo = userInfo } } @@ -75,7 +80,7 @@ open class ControlledAsset: SwiftUIAsset where M decoder.logger?.t("Updating model for \(data.id)") model.data = data } else { - self.model = ModelType(data) + self.model = ModelType(data, userInfo: decoder.userInfo) decoder.logger?.t("Creating model for \(data.id)") modelCache?.set(model, forKey: data.id, codingPath: decoder.codingPath) } From 8152b9f2d0976a2bb53e10e9986b334b7132d7b7 Mon Sep 17 00:00:00 2001 From: zwu01 Date: Wed, 25 Oct 2023 11:11:38 -0400 Subject: [PATCH 06/37] address comments --- .../reference-assets/Sources/SwiftUI/InputAsset.swift | 2 +- .../swiftui/Sources/types/assets/ControlledAsset.swift | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift index c94a01370..e1c1406b3 100644 --- a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift +++ b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift @@ -49,7 +49,7 @@ open class InputAssetViewModel: AssetViewModel { - data: The `InputData` decoded from the core player - userInfo: The `userInfo` from the decoder */ - public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]? = nil) { + public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]) { super.init(data, userInfo: userInfo) $data.sink { [weak self] (newData) in (newData.value?.stringValue).map { self?.text = $0 } diff --git a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift index 19ec9699a..b6c1e3f7f 100644 --- a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift +++ b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift @@ -16,7 +16,7 @@ open class AssetViewModel: ObservableObject { @Published public var data: T /// Any contextual information set by the user - public var userInfo: [CodingUserInfoKey: Any]? + public var userInfo: [CodingUserInfoKey: Any] /// Set to store subscriptions in for cancellation public var bag = Set() @@ -25,9 +25,9 @@ open class AssetViewModel: ObservableObject { Constructs an instance of this ViewModel with the given data - parameters: - data: The data to publish from this ViewModel - - userInfo: Any contextual information set by the user + - userInfo: Any contextual information set by the user */ - public required init(_ data: T, userInfo: [CodingUserInfoKey: Any]? = nil) { + public required init(_ data: T, userInfo: [CodingUserInfoKey: Any] = [:]) { self._data = Published(initialValue: data) self.userInfo = userInfo } @@ -79,6 +79,7 @@ open class ControlledAsset: SwiftUIAsset where M self.model = model decoder.logger?.t("Updating model for \(data.id)") model.data = data + model.userInfo = decoder.userInfo } else { self.model = ModelType(data, userInfo: decoder.userInfo) decoder.logger?.t("Creating model for \(data.id)") From afddeaeb28da1e6e39d45d7d19bebaf49eabcbd3 Mon Sep 17 00:00:00 2001 From: zwu01 Date: Wed, 25 Oct 2023 13:05:46 -0400 Subject: [PATCH 07/37] update tests --- .../ViewInspector/SwiftUI/InputAssetTests.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/packages/reference-assets/ViewInspector/SwiftUI/InputAssetTests.swift b/ios/packages/reference-assets/ViewInspector/SwiftUI/InputAssetTests.swift index 0d483a5e6..69dde7542 100644 --- a/ios/packages/reference-assets/ViewInspector/SwiftUI/InputAssetTests.swift +++ b/ios/packages/reference-assets/ViewInspector/SwiftUI/InputAssetTests.swift @@ -67,7 +67,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { validation: nil ) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let update1expect = expectation(description: "Initial value") model.$data.sink { (data) in guard data.value?.stringValue == "a" else { return } @@ -110,7 +110,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { let modelRef = ModelReference(rawValue: val) let data = InputData(id: "input", type: "input", placeholder: nil, value: modelRef, label: nil, set: nil, dataType: nil, validation: nil) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let view = InputAssetView(model: model) @@ -140,7 +140,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { validation: nil ) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let view = await InputAssetView(model: model) @@ -176,7 +176,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { validation: validation ) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let view = InputAssetView(model: model) @@ -204,7 +204,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { let data = InputData(id: "input", type: "input", placeholder: nil, value: nil, label: nil, set: wrapper, dataType: nil, validation: nil) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let view = InputAssetView(model: model) @@ -226,7 +226,7 @@ class InputAssetTests: SwiftUIAssetUnitTestCase { let data = InputData(id: "input", type: "input", placeholder: nil, value: nil, label: nil, set: wrapper, dataType: nil, validation: nil) - let model = InputAssetViewModel(data) + let model = InputAssetViewModel(data, userInfo: [:]) let view = InputAssetView(model: model) From fca39330914eb6a2f09d72eefc72bf91b71b965e Mon Sep 17 00:00:00 2001 From: zwu01 Date: Wed, 25 Oct 2023 18:35:51 -0400 Subject: [PATCH 08/37] update doc --- docs/site/pages/assets/custom.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/site/pages/assets/custom.mdx b/docs/site/pages/assets/custom.mdx index 197d7599e..0beb94484 100644 --- a/docs/site/pages/assets/custom.mdx +++ b/docs/site/pages/assets/custom.mdx @@ -170,12 +170,12 @@ class ActionAsset: UncontrolledAsset { #### ControlledAsset -The `ControlledAsset` lets you define the viewModel type, as long as it subclasses `AssetViewModel`, this way you still receive updated data whenever Player changes state, but you can add other functionality to the `viewModel`. +The `ControlledAsset` lets you define the viewModel type, as long as it subclasses `AssetViewModel`, this way you still receive updated data and user info whenever Player changes state, but you can add other functionality to the `viewModel`. ```swift class ActionViewModel: AssetViewModel { - public required init(_ data: ActionData) { - super.init(data) + public required init(_ data: ActionData, userInfo: [CodingUserInfoKey: Any]) { + super.init(data, userInfo: userInfo) } } class ActionAsset: ControlledAsset { From 00939afaedd3bc0ad3b0b0a97719c3b3925f91f9 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Fri, 27 Oct 2023 13:07:02 -0700 Subject: [PATCH 09/37] apply swift 6 warning fix to flaky iOS tests (#207) --- .../Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift index 91bff45f6..bfd0c8069 100644 --- a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift +++ b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift @@ -45,7 +45,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) try await Task.sleep(nanoseconds: 1_000_000_000) - wait(for: [completed], timeout: 2) + await fulfillment(of: [completed], timeout: 2) } func testViewModelSuccessMultiFlow() async throws { @@ -223,7 +223,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .failure(.jsConversionFailure) - wait(for: [completed], timeout: 2) + await fulfillment(of: [completed], timeout: 2) cancellable.cancel() } From 68df800c4ce1402dcdd7301e46ee7f8de470ae54 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Fri, 27 Oct 2023 14:38:42 -0700 Subject: [PATCH 10/37] update Gemfile.lock (#208) --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 543886431..ea6c46258 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,10 +14,10 @@ GIT GIT remote: https://github.com/hborawski/starlark_compiler.git - revision: be2f8a7422a9f26ee50d4548d50dcb0286341573 + revision: 544f76ebb29241e36aab75d2a5b6467eebdad856 branch: build-file-path specs: - starlark_compiler (0.4.0) + starlark_compiler (0.5.0) GEM remote: https://rubygems.org/ @@ -317,4 +317,4 @@ DEPENDENCIES xcov BUNDLED WITH - 2.3.10 + 2.3.19 From a51c1601f68885b06e66fdcd72a01a7509dc151a Mon Sep 17 00:00:00 2001 From: mercillo Date: Fri, 3 Nov 2023 08:08:50 -0700 Subject: [PATCH 11/37] renamed folder structure for plugin mocks --- .../beacon/mocks/beacon/beacon-action.json | 37 +++++++++++++++++++ .../external-action.json | 0 .../mocks/{ => pubsub}/pub-sub-basic.json | 0 3 files changed, 37 insertions(+) create mode 100644 plugins/beacon/mocks/beacon/beacon-action.json rename plugins/external-action/mocks/{ => external-action}/external-action.json (100%) rename plugins/pubsub/mocks/{ => pubsub}/pub-sub-basic.json (100%) diff --git a/plugins/beacon/mocks/beacon/beacon-action.json b/plugins/beacon/mocks/beacon/beacon-action.json new file mode 100644 index 000000000..087fb269b --- /dev/null +++ b/plugins/beacon/mocks/beacon/beacon-action.json @@ -0,0 +1,37 @@ +{ + "id": "action-with-custom-beacon", + "views": [ + { + "id": "action", + "type": "action", + "exp": "beacon('action', 'some-data')", + "metaData": { + "beacon": "Click count: {{count}}" + }, + "label": { + "asset": { + "id": "action-label-text", + "type": "text", + "value": "Clicked {{count}} times" + } + } + } + ], + "navigation": { + "BEGIN": "FLOW_1", + "FLOW_1": { + "startState": "VIEW_1", + "VIEW_1": { + "state_type": "VIEW", + "ref": "action", + "transitions": { + "*": "END_Done" + } + }, + "END_Done": { + "state_type": "END", + "outcome": "done" + } + } + } + } \ No newline at end of file diff --git a/plugins/external-action/mocks/external-action.json b/plugins/external-action/mocks/external-action/external-action.json similarity index 100% rename from plugins/external-action/mocks/external-action.json rename to plugins/external-action/mocks/external-action/external-action.json diff --git a/plugins/pubsub/mocks/pub-sub-basic.json b/plugins/pubsub/mocks/pubsub/pub-sub-basic.json similarity index 100% rename from plugins/pubsub/mocks/pub-sub-basic.json rename to plugins/pubsub/mocks/pubsub/pub-sub-basic.json From 7a99386e42c980020e8870004bb49a108efe40b2 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Tue, 31 Oct 2023 10:11:44 -0700 Subject: [PATCH 12/37] store cancellables in ManagedPlayerViewModelTests (#210) --- .../ManagedPlayerViewModelTests.swift | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift index bfd0c8069..16e37c4ae 100644 --- a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift +++ b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift @@ -17,6 +17,13 @@ class ManagedPlayerViewModelTests: XCTestCase { let flow1 = FlowData.COUNTER let flow2 = FlowData.COUNTER.replacingOccurrences(of: "counter-flow", with: "counter-flow-2") + var bag = Set() + + override func tearDown() { + bag.forEach { $0.cancel() } + bag.removeAll() + } + func testViewModelSuccessFlow() async throws { let flowManager = ConstantFlowManager([flow1], delay: 0) @@ -27,7 +34,7 @@ class ManagedPlayerViewModelTests: XCTestCase { await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -55,7 +62,7 @@ class ManagedPlayerViewModelTests: XCTestCase { await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -74,7 +81,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) try await Task.sleep(nanoseconds: 1_000_000_000) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) } func testViewModelManagerError() async { @@ -109,7 +116,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) let result = """ { @@ -128,7 +135,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) try await Task.sleep(nanoseconds: 1_000_000_000) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -137,7 +144,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) viewModel.retry() try await Task.sleep(nanoseconds: 1_000_000_000) @@ -147,11 +154,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) await viewModel.next(state) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) } func testViewModelReset() async throws { @@ -161,7 +168,7 @@ class ManagedPlayerViewModelTests: XCTestCase { await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -180,7 +187,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) try await Task.sleep(nanoseconds: 1_000_000_000) - waitOnChange(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 }.store(in: &bag) viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -189,7 +196,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) viewModel.reset() try await Task.sleep(nanoseconds: 1_000_000_000) @@ -199,11 +206,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) } func testViewModelErrorFlow() async { @@ -219,7 +226,7 @@ class ManagedPlayerViewModelTests: XCTestCase { completed.fulfill() } - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 != nil } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 != nil }.store(in: &bag) viewModel.result = .failure(.jsConversionFailure) From 43b0396cbe89902f041abc6a2f172428ba6bfea5 Mon Sep 17 00:00:00 2001 From: brocollie08 Date: Thu, 2 Nov 2023 16:38:59 -0400 Subject: [PATCH 13/37] Singular workflow for CI (#214) * merge trunk and fork workflows * reference correct test * hyphen * separate deps for trunk and fork jobs * add names to jobs called twice * filters on jobs called twice * re-order params * fix config.yml --------- Co-authored-by: brocollie08 --- .circleci/config.yml | 129 ++++++++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 37 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fb4fa362d..0f90d52be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ commands: at: ~/player - restore_cache: - keys: + keys: - v1-bazel-cache-core-{{ .Branch }}-{{ .Revision }} - v1-bazel-cache-core-{{ .Branch }} - v1-bazel-cache-core-main @@ -112,7 +112,7 @@ jobs: - attach_workspace: at: ~/player - - run: + - run: name: Homebrew Dependencies command: | HOMEBREW_NO_AUTO_UPDATE=1 brew install bazelisk maven openjdk@8 @@ -180,7 +180,7 @@ jobs: # TODO: the timeout should be added to the test itself - run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=1200 --jobs=1 --verbose_failures --config=ci -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests - - run: + - run: when: always command: | RESULTS_DIR=_test_results @@ -309,90 +309,145 @@ workflows: ignore: - main - /version-.*/ - - /pull\/.*/ tags: ignore: /.*/ - bazelrc: + filters: + branches: + ignore: + - /pull\/.*/ context: - Build requires: - setup - applitools_init: + filters: + branches: + ignore: + - /pull\/.*/ context: - applitools requires: - bazelrc - build: + name: build-trunk + filters: + branches: + ignore: + - /pull\/.*/ requires: - bazelrc + - build: + name: build-fork + filters: + branches: + only: + - /pull\/.*/ + requires: + - setup + - build_ios: + name: build-ios-trunk + filters: + branches: + ignore: + - /pull\/.*/ context: - applitools requires: - applitools_init - bazelrc + - build_ios: + name: build-ios-fork + filters: + branches: + only: + - /pull\/.*/ + requires: + - setup + - maybe_release: + filters: + branches: + ignore: + - /pull\/.*/ context: - Publish requires: - - build - - build_ios + - build-trunk + - build-ios-trunk - test: + name: test-trunk + filters: + branches: + ignore: + - /pull\/.*/ requires: - - build + - build-trunk - - android_test: - context: - - applitools - requires: - - applitools_init - - build - - - coverage: + - test: + name: test-fork + filters: + branches: + only: + - /pull\/.*/ requires: - - build + - build-fork - - applitools_cleanup: + - android_test: + name: android-test-trunk + filters: + branches: + ignore: + - /pull\/.*/ context: - applitools requires: - - android_test - - build_ios + - applitools_init + - build-trunk - build_and_test_pr_fork: - jobs: - - setup: + - android_test: + name: android-test-fork filters: branches: only: - /pull\/.*/ - tags: - ignore: /.*/ - - - build: - requires: - - setup - - - build_ios: requires: - - setup + - build-fork - - test: + - coverage: + name: coverage-trunk + filters: + branches: + ignore: + - /pull\/.*/ requires: - - build + - build-trunk - - android_test: + - coverage: + name: coverage-fork + filters: + branches: + only: + - /pull\/.*/ requires: - - build + - build-fork - - coverage: + - applitools_cleanup: + filters: + branches: + ignore: + - /pull\/.*/ + context: + - applitools requires: - - build + - android-test-trunk + - build-ios-trunk build_and_test_main: when: From 9c0735116937476ab13ba3ab868f755facc112fe Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 7 Nov 2023 07:56:14 -0800 Subject: [PATCH 14/37] WIP, plugin demo app --- android/demo/deps.bzl | 2 +- index.bzl | 29 +++++++ .../beacon/mocks/beacon/beacon-action.json | 83 ++++++++++++------- plugins/external-action/mocks/BUILD | 16 ++-- plugins/external-action/mocks/build.bzl | 27 ------ plugins/mocks/BUILD | 20 +++++ plugins/pubsub/mocks/BUILD | 29 +++++-- plugins/pubsub/mocks/build.bzl | 27 ------ .../pubsub/mocks/pubsub/pub-sub-basic.json | 42 +++++++--- plugins/reference-assets/mocks/BUILD | 16 ++-- plugins/reference-assets/mocks/build.bzl | 27 ------ 11 files changed, 179 insertions(+), 139 deletions(-) delete mode 100644 plugins/external-action/mocks/build.bzl create mode 100644 plugins/mocks/BUILD delete mode 100644 plugins/pubsub/mocks/build.bzl delete mode 100644 plugins/reference-assets/mocks/build.bzl diff --git a/android/demo/deps.bzl b/android/demo/deps.bzl index e9bc946fa..9678d1f9f 100644 --- a/android/demo/deps.bzl +++ b/android/demo/deps.bzl @@ -24,7 +24,7 @@ main_deps = parse_coordinates(maven_main) + [ "//plugins/reference-assets/android:assets", "//plugins/common-types/jvm:common-types", "//plugins/pending-transaction/jvm:pending-transaction", - "//plugins/reference-assets/mocks:jar", + "//plugins/mocks:jar", ] test_deps = parse_coordinates(maven_test) + [ diff --git a/index.bzl b/index.bzl index 1ebe6ae15..887e146ef 100644 --- a/index.bzl +++ b/index.bzl @@ -175,3 +175,32 @@ def javascript_pipeline( srcs = srcs, mode = xlr_mode ) + +def _generate_manifest(context): + manifest = context.actions.declare_file("manifest.json") + context.actions.write( + output = manifest, + content = json.encode([ + { + "group": group, + "name": file.replace(".json", ""), + "path": "../%s/%s/%s/%s" % (group, name,action,file), + } + for group, name, action, file in [ + mock.path.split("/")[-4:] + for filegroup in context.attr.mocks + for mock in filegroup[DefaultInfo].files.to_list() + ] + ]), + ) + return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] + +generate_manifest = rule( + attrs = { + "mocks": attr.label_list( + mandatory = True, + allow_files = [".json"], + ), + }, + implementation = _generate_manifest, +) \ No newline at end of file diff --git a/plugins/beacon/mocks/beacon/beacon-action.json b/plugins/beacon/mocks/beacon/beacon-action.json index 087fb269b..7231fad23 100644 --- a/plugins/beacon/mocks/beacon/beacon-action.json +++ b/plugins/beacon/mocks/beacon/beacon-action.json @@ -1,37 +1,62 @@ { - "id": "action-with-custom-beacon", - "views": [ - { - "id": "action", - "type": "action", - "exp": "beacon('action', 'some-data')", - "metaData": { - "beacon": "Click count: {{count}}" - }, - "label": { + "id": "generated-flow", + "views": [ + { + "id": "collection", + "type": "collection", + "values": [ + { "asset": { - "id": "action-label-text", - "type": "text", - "value": "Clicked {{count}} times" + "id": "action", + "type": "action", + "exp": ["{{count}} = {{count}} + 1" , "beacon('action', 'some-data')"], + "metaData": { + "beacon": "Click count: {{count}}" + }, + "label": { + "asset": { + "id": "action-label-text", + "type": "text", + "value": "Clicked {{count}} times" + } } } - } - ], - "navigation": { - "BEGIN": "FLOW_1", - "FLOW_1": { - "startState": "VIEW_1", - "VIEW_1": { - "state_type": "VIEW", - "ref": "action", - "transitions": { - "*": "END_Done" - } }, - "END_Done": { - "state_type": "END", - "outcome": "done" + { + "asset": { + "id": "action-end", + "type": "action", + "value": "Next", + "label": { + "asset": { + "id": "action-end-label", + "type": "text", + "value": "End the flow (View Beacons)" + } + } + } + } + ] + } + ], + "data": { + "count": 0 + }, + "navigation": { + "BEGIN": "FLOW_1", + "FLOW_1": { + "startState": "VIEW_1", + "VIEW_1": { + "state_type": "VIEW", + "ref": "collection", + "transitions": { + "*": "END_Done" } + }, + "END_Done": { + "state_type": "END", + "outcome": "done" } } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD index 4a3d67564..c3734add4 100644 --- a/plugins/external-action/mocks/BUILD +++ b/plugins/external-action/mocks/BUILD @@ -1,9 +1,15 @@ -load(":build.bzl", "generate_manifest") +load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") +filegroup( + name = "mock", + srcs = glob(["**/*.json"]), + visibility = ["//visibility:public"], +) + generate_manifest( - name = "mocks", - mocks = glob(["*/*.json"]), + name = "manifst", + mocks = [":mock"], visibility = ["//visibility:public"], ) @@ -12,14 +18,14 @@ javascript_pipeline( entry = "index.ts", other_srcs = [ "index.ts", - ":mocks", + ":manifest", ], out_dir = "", ) java_library( name = "jar", - resources = [":mocks"], + resources = [":mock"], resource_strip_prefix = "plugins/external-action/mocks", visibility = ["//visibility:public"], ) diff --git a/plugins/external-action/mocks/build.bzl b/plugins/external-action/mocks/build.bzl deleted file mode 100644 index 3515d96e1..000000000 --- a/plugins/external-action/mocks/build.bzl +++ /dev/null @@ -1,27 +0,0 @@ -def _generate_manifest(context): - manifest = context.actions.declare_file("manifest.json") - context.actions.write( - output = manifest, - content = json.encode([ - { - "group": group, - "name": name.replace(".json", ""), - "path": "./%s/%s" % (group, name), - } - for group, name in [ - mock.label.name.split("/")[-2:] - for mock in context.attr.mocks - ] - ]), - ) - return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] - -generate_manifest = rule( - attrs = { - "mocks": attr.label_list( - mandatory = True, - allow_files = [".json"], - ), - }, - implementation = _generate_manifest, -) diff --git a/plugins/mocks/BUILD b/plugins/mocks/BUILD new file mode 100644 index 000000000..e75742067 --- /dev/null +++ b/plugins/mocks/BUILD @@ -0,0 +1,20 @@ +load("//:index.bzl", "generate_manifest") +load("//:index.bzl", "javascript_pipeline") + +# testing this build file +# pubsub/mocks:mock calls a filegroup +# generate manifest from //:index.bzl calls with filegroups +generate_manifest( + name = "mocks", + mocks = ["//plugins/reference-assets/mocks:mock"], + visibility = ["//visibility:public"], +) + +java_library( + name = "jar", + resources = [":mocks"], + resource_strip_prefix = "plugins/", + visibility = ["//visibility:public"], +) + + diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD index d6a2e9d00..52819557c 100644 --- a/plugins/pubsub/mocks/BUILD +++ b/plugins/pubsub/mocks/BUILD @@ -1,25 +1,38 @@ -load(":build.bzl", "generate_manifest") +load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") +# filegroup is used to create a larger manifest +filegroup( + name = "mock", + srcs = glob(["**/*.json"]), + visibility = ["//visibility:public"], +) + +# change load to :build.bzl to use generate manifest for non filegorup generate_manifest( - name = "mocks", - mocks = glob(["*/*.json"]), + name = "manifest", + mocks = [":mock"], visibility = ["//visibility:public"], ) javascript_pipeline( name = "@player-ui/pubsub-plugin-mocks", entry = "index.ts", + dependencies = [ + "@npm//@player-tools/dsl", + ], other_srcs = [ "index.ts", - ":mocks", - ], + ":manifest", + ] + glob(["**/*.tsx"]), out_dir = "", ) +#need to figure out how to consolidate jars remove resource strip +# resource_strip_prefix = "plugins/reference-assets/mocks", adding this works with filegroups java_library( name = "jar", - resources = [":mocks"], - resource_strip_prefix = "plugins/pubsub/mocks", + resources = [":mock"], + resource_strip_prefix = "plugins/pubsub/mocks/", visibility = ["//visibility:public"], -) +) \ No newline at end of file diff --git a/plugins/pubsub/mocks/build.bzl b/plugins/pubsub/mocks/build.bzl deleted file mode 100644 index 3515d96e1..000000000 --- a/plugins/pubsub/mocks/build.bzl +++ /dev/null @@ -1,27 +0,0 @@ -def _generate_manifest(context): - manifest = context.actions.declare_file("manifest.json") - context.actions.write( - output = manifest, - content = json.encode([ - { - "group": group, - "name": name.replace(".json", ""), - "path": "./%s/%s" % (group, name), - } - for group, name in [ - mock.label.name.split("/")[-2:] - for mock in context.attr.mocks - ] - ]), - ) - return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] - -generate_manifest = rule( - attrs = { - "mocks": attr.label_list( - mandatory = True, - allow_files = [".json"], - ), - }, - implementation = _generate_manifest, -) diff --git a/plugins/pubsub/mocks/pubsub/pub-sub-basic.json b/plugins/pubsub/mocks/pubsub/pub-sub-basic.json index c87a91691..28c774ac0 100644 --- a/plugins/pubsub/mocks/pubsub/pub-sub-basic.json +++ b/plugins/pubsub/mocks/pubsub/pub-sub-basic.json @@ -2,16 +2,38 @@ "id": "generated-flow", "views": [ { - "id": "action", - "type": "action", - "exp": "@[ publish('some-event', 'event published message') ]@", - "label": { - "asset": { - "id": "action-label", - "type": "text", - "value": "Clicked to publish event" + "id": "collection", + "type": "collection", + "values": [ + { + "asset": { + "id": "action", + "type": "action", + "exp": "@[ publish('some-event', 'event published message') ]@", + "label": { + "asset": { + "id": "action-label", + "type": "text", + "value": "Clicked to publish event" + } + } + } + }, + { + "asset": { + "id": "action-end", + "type": "action", + "value": "Next", + "label": { + "asset": { + "id": "action-end-label", + "type": "text", + "value": "End the flow (View pubsub events)" + } + } + } } - } + ] } ], "data": { @@ -23,7 +45,7 @@ "startState": "VIEW_1", "VIEW_1": { "state_type": "VIEW", - "ref": "action", + "ref": "collection", "transitions": { "*": "END_Done" } diff --git a/plugins/reference-assets/mocks/BUILD b/plugins/reference-assets/mocks/BUILD index 4b0cf81bf..46ebcbc03 100644 --- a/plugins/reference-assets/mocks/BUILD +++ b/plugins/reference-assets/mocks/BUILD @@ -1,9 +1,15 @@ load(":build.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") +filegroup( + name = "mock", + srcs = glob(["**/*.json"]), + visibility = ["//visibility:public"], +) + generate_manifest( - name = "mocks", - mocks = glob(["**/*.json"]), + name = "manifest", + mocks = [":mock"], visibility = ["//visibility:public"], ) @@ -16,14 +22,14 @@ javascript_pipeline( ], other_srcs = [ "index.ts", - ":mocks", + ":manifest", ] + glob(["**/*.tsx"]), out_dir = "", ) java_library( name = "jar", - resources = [":mocks"], + resources = [":mock"], resource_strip_prefix = "plugins/reference-assets/mocks", visibility = ["//visibility:public"], -) +) \ No newline at end of file diff --git a/plugins/reference-assets/mocks/build.bzl b/plugins/reference-assets/mocks/build.bzl deleted file mode 100644 index 3515d96e1..000000000 --- a/plugins/reference-assets/mocks/build.bzl +++ /dev/null @@ -1,27 +0,0 @@ -def _generate_manifest(context): - manifest = context.actions.declare_file("manifest.json") - context.actions.write( - output = manifest, - content = json.encode([ - { - "group": group, - "name": name.replace(".json", ""), - "path": "./%s/%s" % (group, name), - } - for group, name in [ - mock.label.name.split("/")[-2:] - for mock in context.attr.mocks - ] - ]), - ) - return [DefaultInfo(files = depset([manifest], transitive = [mock[DefaultInfo].files for mock in context.attr.mocks]))] - -generate_manifest = rule( - attrs = { - "mocks": attr.label_list( - mandatory = True, - allow_files = [".json"], - ), - }, - implementation = _generate_manifest, -) From 0f9637fc41ec827476c3648f0794e7197f77a4a7 Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 7 Nov 2023 09:47:16 -0800 Subject: [PATCH 15/37] generate manifest for mocks --- index.bzl | 2 +- plugins/external-action/mocks/BUILD | 6 +++--- plugins/mocks/BUILD | 5 +---- plugins/pubsub/mocks/BUILD | 10 +++------- plugins/reference-assets/mocks/BUILD | 8 ++++---- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/index.bzl b/index.bzl index 887e146ef..414177123 100644 --- a/index.bzl +++ b/index.bzl @@ -184,7 +184,7 @@ def _generate_manifest(context): { "group": group, "name": file.replace(".json", ""), - "path": "../%s/%s/%s/%s" % (group, name,action,file), + "path": "./%s/%s/%s/%s" % (group, name,action,file), } for group, name, action, file in [ mock.path.split("/")[-4:] diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD index c3734add4..f60d45954 100644 --- a/plugins/external-action/mocks/BUILD +++ b/plugins/external-action/mocks/BUILD @@ -2,14 +2,14 @@ load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") filegroup( - name = "mock", + name = "mocks", srcs = glob(["**/*.json"]), visibility = ["//visibility:public"], ) generate_manifest( name = "manifst", - mocks = [":mock"], + mocks = [":mocks"], visibility = ["//visibility:public"], ) @@ -25,7 +25,7 @@ javascript_pipeline( java_library( name = "jar", - resources = [":mock"], + resources = [":mocks"], resource_strip_prefix = "plugins/external-action/mocks", visibility = ["//visibility:public"], ) diff --git a/plugins/mocks/BUILD b/plugins/mocks/BUILD index e75742067..7dd1c424b 100644 --- a/plugins/mocks/BUILD +++ b/plugins/mocks/BUILD @@ -1,12 +1,9 @@ load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") -# testing this build file -# pubsub/mocks:mock calls a filegroup -# generate manifest from //:index.bzl calls with filegroups generate_manifest( name = "mocks", - mocks = ["//plugins/reference-assets/mocks:mock"], + mocks = ["//plugins/reference-assets/mocks","//plugins/pubsub/mocks", "//plugins/external-action/mocks"], visibility = ["//visibility:public"], ) diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD index 52819557c..28b86a1fc 100644 --- a/plugins/pubsub/mocks/BUILD +++ b/plugins/pubsub/mocks/BUILD @@ -1,17 +1,15 @@ load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") -# filegroup is used to create a larger manifest filegroup( - name = "mock", + name = "mocks", srcs = glob(["**/*.json"]), visibility = ["//visibility:public"], ) -# change load to :build.bzl to use generate manifest for non filegorup generate_manifest( name = "manifest", - mocks = [":mock"], + mocks = [":mocks"], visibility = ["//visibility:public"], ) @@ -28,11 +26,9 @@ javascript_pipeline( out_dir = "", ) -#need to figure out how to consolidate jars remove resource strip -# resource_strip_prefix = "plugins/reference-assets/mocks", adding this works with filegroups java_library( name = "jar", - resources = [":mock"], + resources = [":mocks"], resource_strip_prefix = "plugins/pubsub/mocks/", visibility = ["//visibility:public"], ) \ No newline at end of file diff --git a/plugins/reference-assets/mocks/BUILD b/plugins/reference-assets/mocks/BUILD index 46ebcbc03..e761bad75 100644 --- a/plugins/reference-assets/mocks/BUILD +++ b/plugins/reference-assets/mocks/BUILD @@ -1,15 +1,15 @@ -load(":build.bzl", "generate_manifest") +load("//:index.bzl", "generate_manifest") load("//:index.bzl", "javascript_pipeline") filegroup( - name = "mock", + name = "mocks", srcs = glob(["**/*.json"]), visibility = ["//visibility:public"], ) generate_manifest( name = "manifest", - mocks = [":mock"], + mocks = [":mocks"], visibility = ["//visibility:public"], ) @@ -29,7 +29,7 @@ javascript_pipeline( java_library( name = "jar", - resources = [":mock"], + resources = [":manifest"], resource_strip_prefix = "plugins/reference-assets/mocks", visibility = ["//visibility:public"], ) \ No newline at end of file From 21edcdbed67be1a236a88a2e68682a69c990550e Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 7 Nov 2023 12:14:15 -0800 Subject: [PATCH 16/37] fixed typo in build file --- plugins/external-action/mocks/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD index f60d45954..88b41a935 100644 --- a/plugins/external-action/mocks/BUILD +++ b/plugins/external-action/mocks/BUILD @@ -8,7 +8,7 @@ filegroup( ) generate_manifest( - name = "manifst", + name = "manifest", mocks = [":mocks"], visibility = ["//visibility:public"], ) From 99ae380e09d08dfd838c951306bca3e67b57e548 Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 7 Nov 2023 14:56:23 -0800 Subject: [PATCH 17/37] modified mocks reader --- .../com/intuit/player/jvm/utils/mocks/ClassLoaderMocksReader.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm/utils/src/main/kotlin/com/intuit/player/jvm/utils/mocks/ClassLoaderMocksReader.kt b/jvm/utils/src/main/kotlin/com/intuit/player/jvm/utils/mocks/ClassLoaderMocksReader.kt index a56dc2049..cb7f25033 100644 --- a/jvm/utils/src/main/kotlin/com/intuit/player/jvm/utils/mocks/ClassLoaderMocksReader.kt +++ b/jvm/utils/src/main/kotlin/com/intuit/player/jvm/utils/mocks/ClassLoaderMocksReader.kt @@ -12,7 +12,7 @@ public class ClassLoaderMocksReader(private val classLoader: ClassLoader = Class * will read the manifest on demand and default to an empty list if not found. */ public val manifest: String by lazy { - classLoader.getResource("manifest.json")?.readText() ?: "[]" + classLoader.getResource("mocks/manifest.json")?.readText() ?: "[]" } /** From 605df1b9c3f92693a7ee1daa8cce3971fc8037e6 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 08:59:06 -0800 Subject: [PATCH 18/37] updated test dependencies --- jvm/core/deps.bzl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jvm/core/deps.bzl b/jvm/core/deps.bzl index aac4a82f9..9c21372b5 100644 --- a/jvm/core/deps.bzl +++ b/jvm/core/deps.bzl @@ -15,5 +15,7 @@ main_deps = main_exports + [ main_runtime_deps = [] # Test dependencies -test_deps = [] +test_deps = [ + "//plugins/mocks:jar", +] test_runtime_deps = [] From 206cfc7b488981ad0f409fec5222a596601abccd Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 09:17:36 -0800 Subject: [PATCH 19/37] added dependency for all plugin tests to work with simpleFlow --- jvm/testutils/BUILD | 1 - jvm/testutils/deps.bzl | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jvm/testutils/BUILD b/jvm/testutils/BUILD index 54d2b7368..f72a1d117 100644 --- a/jvm/testutils/BUILD +++ b/jvm/testutils/BUILD @@ -5,6 +5,5 @@ kt_player_module( name = "testutils", main_deps = main_deps, main_exports = main_exports, - main_resource_strip_prefix = "plugins/reference-assets/mocks", main_resources = main_resources, ) diff --git a/jvm/testutils/deps.bzl b/jvm/testutils/deps.bzl index d793d524f..dafa8df54 100644 --- a/jvm/testutils/deps.bzl +++ b/jvm/testutils/deps.bzl @@ -11,11 +11,11 @@ main_exports = [ "//jvm/j2v8:j2v8-all", "//jvm/graaljs", "//plugins/common-types/jvm:common-types", - "//plugins/reference-assets/jvm:reference-assets", + "//plugins/mocks:jar", ] main_deps = main_exports main_resources = [ - "//plugins/reference-assets/mocks", + "//plugins/mocks:jar", ] From be4fe4aae98d6b6a30a0e1fc474b3ba9e019e5f7 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 09:38:20 -0800 Subject: [PATCH 20/37] reference assets needed --- jvm/core/deps.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/jvm/core/deps.bzl b/jvm/core/deps.bzl index 9c21372b5..1f2ff1e82 100644 --- a/jvm/core/deps.bzl +++ b/jvm/core/deps.bzl @@ -17,5 +17,6 @@ main_runtime_deps = [] # Test dependencies test_deps = [ "//plugins/mocks:jar", + "//plugins/reference-assets/jvm:reference-assets", ] test_runtime_deps = [] From 7e87a0fa30e46c4a9120ef230dc4dd1ed15e819d Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 10:09:02 -0800 Subject: [PATCH 21/37] more dependencies for tests --- plugins/reference-assets/android/build.bzl | 1 + plugins/reference-assets/android/deps.bzl | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/reference-assets/android/build.bzl b/plugins/reference-assets/android/build.bzl index f2ab8b5c4..ab54af29a 100644 --- a/plugins/reference-assets/android/build.bzl +++ b/plugins/reference-assets/android/build.bzl @@ -17,6 +17,7 @@ def kt_asset_test( "//jvm/j2v8:j2v8-all", ], resources = [ + "//plugins/mocks:jar", "//plugins/reference-assets/mocks", ], manifest_values = { diff --git a/plugins/reference-assets/android/deps.bzl b/plugins/reference-assets/android/deps.bzl index 57a819c4b..d8f1c8c0b 100644 --- a/plugins/reference-assets/android/deps.bzl +++ b/plugins/reference-assets/android/deps.bzl @@ -10,6 +10,7 @@ main_exports = [ main_deps = main_exports + parse_coordinates(maven_main) + [ "//jvm:kotlin_serialization", + "//plugins/mocks:jar", "//plugins/reference-assets/jvm:reference-assets", "//plugins/pending-transaction/jvm:pending-transaction", ] From bd337203d8886604e5204d034972013100090668 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 13:25:30 -0800 Subject: [PATCH 22/37] modified test names --- .../player/android/reference/assets/action/ActionTest.kt | 6 +++--- .../intuit/player/android/reference/assets/info/InfoTest.kt | 2 +- .../player/android/reference/assets/input/InputTest.kt | 2 +- .../intuit/player/android/reference/assets/test/deps.bzl | 2 +- .../intuit/player/android/reference/assets/text/TextTest.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt index b92665430..30e8bbd43 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt @@ -19,7 +19,7 @@ class ActionTest : AssetTest("action") { @Test fun actionExpression() { - launchMock("basic") + launchMock("action-basic") currentAssetTree.shouldBeAsset { data.label.shouldBeAsset { @@ -41,7 +41,7 @@ class ActionTest : AssetTest("action") { @Test fun transitionToEndSuccess() { - launchMock("transition-to-end") + launchMock("action-transition-to-end") currentView.shouldBeView { assertEquals(2, childCount) @@ -58,7 +58,7 @@ class ActionTest : AssetTest("action") { @Test fun transitionToEndError() { - launchMock("transition-to-end") + launchMock("action-transition-to-end") currentView.shouldBeView { assertEquals(2, childCount) diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt index 6a1c256ab..ade7b34b7 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt @@ -37,7 +37,7 @@ class InfoTest : AssetTest("info") { @Test fun infoBasic() { - launchMock("modal-flow") + launchMock("info-modal-flow") verifyAndProceed(1, PlayerAction.Next) verifyAndProceed(2, PlayerAction.Dismiss) diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt index 1768943db..e5277f4d6 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt @@ -13,7 +13,7 @@ import com.intuit.player.jvm.core.player.state.dataModel import org.junit.Assert.assertEquals import org.junit.Test -class InputTest : AssetTest("input") { +class InputTest : AssetTest("input-basic") { private fun FormattedEditText.type(text: String) { requestFocus() diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl index 536c48fd5..4a02aafad 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl @@ -14,5 +14,5 @@ main_deps = parse_coordinates(maven) + [ "//plugins/common-types/jvm:common-types", "//plugins/pending-transaction/jvm:pending-transaction", "//plugins/reference-assets/android:assets", - "//plugins/reference-assets/mocks:jar", + "//plugins/mocks:jar", ] diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt index ad180915a..34fcb2013 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt @@ -8,7 +8,7 @@ import com.intuit.player.android.reference.assets.test.shouldBeView import org.junit.Assert.assertEquals import org.junit.Test -class TextTest : AssetTest("text") { +class TextTest : AssetTest("text-basic") { @Test fun basic() { From 451adaf3c7c4cc8d4ba548625ee2397155aa25ce Mon Sep 17 00:00:00 2001 From: mercillo Date: Thu, 9 Nov 2023 09:38:08 -0800 Subject: [PATCH 23/37] modified test names --- plugins/reference-assets/android/build.bzl | 3 ++- .../player/android/reference/assets/action/ActionTest.kt | 2 +- .../android/reference/assets/collection/CollectionTest.kt | 4 ++-- .../intuit/player/android/reference/assets/info/InfoTest.kt | 2 +- .../player/android/reference/assets/input/InputTest.kt | 6 +++--- .../intuit/player/android/reference/assets/test/deps.bzl | 3 ++- .../intuit/player/android/reference/assets/text/TextTest.kt | 6 +++--- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/reference-assets/android/build.bzl b/plugins/reference-assets/android/build.bzl index ab54af29a..7f3a234e1 100644 --- a/plugins/reference-assets/android/build.bzl +++ b/plugins/reference-assets/android/build.bzl @@ -13,12 +13,13 @@ def kt_asset_test( custom_package = "com.intuit.player.android.reference.assets", test_class = test_class, deps = deps + [ + "//plugins/mocks:jar", "//plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test", "//jvm/j2v8:j2v8-all", + ], resources = [ "//plugins/mocks:jar", - "//plugins/reference-assets/mocks", ], manifest_values = { "minSdkVersion": "14", diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt index 43b30d204..bc1245eef 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/action/ActionTest.kt @@ -16,7 +16,7 @@ import com.intuit.player.jvm.core.player.state.dataModel import org.junit.Assert.assertEquals import org.junit.Test -class ActionTest : AssetTest("action") { +class ActionTest : AssetTest("reference-assets") { @Test fun actionExpression() { diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/collection/CollectionTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/collection/CollectionTest.kt index afc317cc4..bc0dade0f 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/collection/CollectionTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/collection/CollectionTest.kt @@ -12,11 +12,11 @@ import com.intuit.player.jvm.core.player.state.InProgressState import org.junit.Assert.assertEquals import org.junit.Test -class CollectionTest : AssetTest("collection") { +class CollectionTest : AssetTest("reference-assets") { @Test fun basic() { - launchMock() + launchMock("collection-basic") val collectionLabel = currentView?.findViewById(R.id.collection_label) ?: throw AssertionError("current view is null") val collectionValues = currentView?.findViewById(R.id.collection_values) ?: throw AssertionError("current view is null") diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt index ade7b34b7..36c910068 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/info/InfoTest.kt @@ -13,7 +13,7 @@ import com.intuit.player.jvm.core.player.state.InProgressState import org.junit.Assert.assertEquals import org.junit.Test -class InfoTest : AssetTest("info") { +class InfoTest : AssetTest("reference-assets") { enum class PlayerAction { Next, Dismiss diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt index e5277f4d6..998821f3f 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/input/InputTest.kt @@ -13,7 +13,7 @@ import com.intuit.player.jvm.core.player.state.dataModel import org.junit.Assert.assertEquals import org.junit.Test -class InputTest : AssetTest("input-basic") { +class InputTest : AssetTest("reference-assets") { private fun FormattedEditText.type(text: String) { requestFocus() @@ -23,7 +23,7 @@ class InputTest : AssetTest("input-basic") { @Test fun basic() { - launchMock() + launchMock("input-basic") val inputLabelContainer = currentView?.findViewById(R.id.input_label_container) ?: throw AssertionError("current view is null") val inputField = currentView?.findViewById(R.id.input_field) ?: throw AssertionError("current view is null") @@ -50,7 +50,7 @@ class InputTest : AssetTest("input-basic") { @Test fun validation() { - launchMock() + launchMock("input-validation") val view = currentView.shouldBeView() val inputLabelContainer = view.findViewById(R.id.input_label_container) diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl index 4a02aafad..f16df1ac7 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl @@ -9,10 +9,11 @@ maven = [ ] main_deps = parse_coordinates(maven) + [ + "//plugins/mocks:jar", "@robolectric//bazel:android-all", "//jvm/utils", "//plugins/common-types/jvm:common-types", "//plugins/pending-transaction/jvm:pending-transaction", "//plugins/reference-assets/android:assets", - "//plugins/mocks:jar", + ] diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt index 5dcb9e094..09ae61800 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/text/TextTest.kt @@ -9,11 +9,11 @@ import com.intuit.player.android.reference.assets.test.shouldBeView import org.junit.Assert.assertEquals import org.junit.Test -class TextTest : AssetTest("text-basic") { +class TextTest : AssetTest("reference-assets") { @Test fun basic() { - launchMock() + launchMock("text-basic") val collectionValues = currentView?.findViewById(R.id.collection_values) ?: throw AssertionError("current view is null") collectionValues[0].shouldBeView { @@ -27,7 +27,7 @@ class TextTest : AssetTest("text-basic") { @Test fun link() { - launchMock("with-link") + launchMock("text-with-link") currentView.shouldBeView { assertEquals("A Link", text.toString()) From caf618ad707ba6327aa6d9d0e63eec49fa1317c1 Mon Sep 17 00:00:00 2001 From: mercillo Date: Thu, 16 Nov 2023 11:24:25 -0800 Subject: [PATCH 24/37] removed unneeded dependencies --- jvm/core/deps.bzl | 1 - jvm/testutils/deps.bzl | 1 - plugins/pubsub/mocks/BUILD | 2 +- plugins/reference-assets/android/build.bzl | 1 - plugins/reference-assets/android/deps.bzl | 1 - plugins/reference-assets/mocks/BUILD | 5 ++--- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/jvm/core/deps.bzl b/jvm/core/deps.bzl index 1f2ff1e82..c3ebaabc0 100644 --- a/jvm/core/deps.bzl +++ b/jvm/core/deps.bzl @@ -16,7 +16,6 @@ main_runtime_deps = [] # Test dependencies test_deps = [ - "//plugins/mocks:jar", "//plugins/reference-assets/jvm:reference-assets", ] test_runtime_deps = [] diff --git a/jvm/testutils/deps.bzl b/jvm/testutils/deps.bzl index dafa8df54..35be018fb 100644 --- a/jvm/testutils/deps.bzl +++ b/jvm/testutils/deps.bzl @@ -17,5 +17,4 @@ main_exports = [ main_deps = main_exports main_resources = [ - "//plugins/mocks:jar", ] diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD index 28b86a1fc..70954c290 100644 --- a/plugins/pubsub/mocks/BUILD +++ b/plugins/pubsub/mocks/BUILD @@ -16,7 +16,7 @@ generate_manifest( javascript_pipeline( name = "@player-ui/pubsub-plugin-mocks", entry = "index.ts", - dependencies = [ + dependencies = [ "@npm//@player-tools/dsl", ], other_srcs = [ diff --git a/plugins/reference-assets/android/build.bzl b/plugins/reference-assets/android/build.bzl index 7f3a234e1..7b1605620 100644 --- a/plugins/reference-assets/android/build.bzl +++ b/plugins/reference-assets/android/build.bzl @@ -19,7 +19,6 @@ def kt_asset_test( ], resources = [ - "//plugins/mocks:jar", ], manifest_values = { "minSdkVersion": "14", diff --git a/plugins/reference-assets/android/deps.bzl b/plugins/reference-assets/android/deps.bzl index d8f1c8c0b..57a819c4b 100644 --- a/plugins/reference-assets/android/deps.bzl +++ b/plugins/reference-assets/android/deps.bzl @@ -10,7 +10,6 @@ main_exports = [ main_deps = main_exports + parse_coordinates(maven_main) + [ "//jvm:kotlin_serialization", - "//plugins/mocks:jar", "//plugins/reference-assets/jvm:reference-assets", "//plugins/pending-transaction/jvm:pending-transaction", ] diff --git a/plugins/reference-assets/mocks/BUILD b/plugins/reference-assets/mocks/BUILD index e761bad75..05fcbfd62 100644 --- a/plugins/reference-assets/mocks/BUILD +++ b/plugins/reference-assets/mocks/BUILD @@ -1,5 +1,4 @@ -load("//:index.bzl", "generate_manifest") -load("//:index.bzl", "javascript_pipeline") +load("//:index.bzl", "generate_manifest", "javascript_pipeline") filegroup( name = "mocks", @@ -16,7 +15,7 @@ generate_manifest( javascript_pipeline( name = "@player-ui/reference-assets-plugin-mocks", entry = "index.ts", - dependencies = [ + dependencies = [ "@npm//@player-tools/dsl", "//plugins/reference-assets/components:@player-ui/reference-assets-components" ], From 2b14916415cf496dd0360a09e74935a45620de2e Mon Sep 17 00:00:00 2001 From: mercillo Date: Fri, 17 Nov 2023 15:25:19 -0800 Subject: [PATCH 25/37] cleaned up BUILD and index fiels --- docs/storybook/BUILD | 2 + .../beacon/mocks/beacon/beacon-action.json | 53 ++++++------------- plugins/external-action/mocks/BUILD | 4 +- plugins/external-action/mocks/index.ts | 7 --- plugins/pubsub/mocks/BUILD | 6 ++- plugins/pubsub/mocks/index.ts | 7 --- .../pubsub/mocks/pubsub/pub-sub-basic.json | 42 ++++----------- 7 files changed, 34 insertions(+), 87 deletions(-) diff --git a/docs/storybook/BUILD b/docs/storybook/BUILD index 4d1ab747e..5e37bbe8e 100644 --- a/docs/storybook/BUILD +++ b/docs/storybook/BUILD @@ -6,6 +6,8 @@ data = [ "//core/make-flow:@player-ui/make-flow", "//plugins/reference-assets/react:@player-ui/reference-assets-plugin-react", "//plugins/reference-assets/mocks:@player-ui/reference-assets-plugin-mocks", + "//plugins/pubsub/core:@player-ui/pubsub-plugin", + "//plugins/pubsub/mocks:@player-ui/pubsub-plugin-mocks", "//plugins/data-change-listener/core:@player-ui/data-change-listener-plugin", "//plugins/computed-properties/core:@player-ui/computed-properties-plugin", "//plugins/reference-assets/components:@player-ui/reference-assets-components", diff --git a/plugins/beacon/mocks/beacon/beacon-action.json b/plugins/beacon/mocks/beacon/beacon-action.json index 7231fad23..e69eb4830 100644 --- a/plugins/beacon/mocks/beacon/beacon-action.json +++ b/plugins/beacon/mocks/beacon/beacon-action.json @@ -2,45 +2,26 @@ "id": "generated-flow", "views": [ { - "id": "collection", - "type": "collection", - "values": [ - { - "asset": { - "id": "action", - "type": "action", - "exp": ["{{count}} = {{count}} + 1" , "beacon('action', 'some-data')"], - "metaData": { - "beacon": "Click count: {{count}}" - }, - "label": { - "asset": { - "id": "action-label-text", - "type": "text", - "value": "Clicked {{count}} times" - } - } - } - }, - { - "asset": { - "id": "action-end", - "type": "action", - "value": "Next", - "label": { - "asset": { - "id": "action-end-label", - "type": "text", - "value": "End the flow (View Beacons)" - } - } - } + "id": "action", + "type": "action", + "exp": [ + "{{count}} = {{count}} + 1", + "beacon('action', 'some-data')" + ], + "metaData": { + "beacon": "Click count: {{count}}" + }, + "label": { + "asset": { + "id": "action-label-text", + "type": "text", + "value": "Clicked {{count}} times" } - ] + } } ], "data": { - "count": 0 + "count": 0 }, "navigation": { "BEGIN": "FLOW_1", @@ -48,7 +29,7 @@ "startState": "VIEW_1", "VIEW_1": { "state_type": "VIEW", - "ref": "collection", + "ref": "action", "transitions": { "*": "END_Done" } diff --git a/plugins/external-action/mocks/BUILD b/plugins/external-action/mocks/BUILD index 88b41a935..f7313fbec 100644 --- a/plugins/external-action/mocks/BUILD +++ b/plugins/external-action/mocks/BUILD @@ -1,5 +1,4 @@ -load("//:index.bzl", "generate_manifest") -load("//:index.bzl", "javascript_pipeline") +load("//:index.bzl", "generate_manifest","javascript_pipeline") filegroup( name = "mocks", @@ -12,7 +11,6 @@ generate_manifest( mocks = [":mocks"], visibility = ["//visibility:public"], ) - javascript_pipeline( name = "@player-ui/external-action-plugin-mocks", entry = "index.ts", diff --git a/plugins/external-action/mocks/index.ts b/plugins/external-action/mocks/index.ts index 727120cf6..e69de29bb 100644 --- a/plugins/external-action/mocks/index.ts +++ b/plugins/external-action/mocks/index.ts @@ -1,7 +0,0 @@ -export interface Mock { - group: string; - name: string; - path: string; -} - -export type Manifest = Array; diff --git a/plugins/pubsub/mocks/BUILD b/plugins/pubsub/mocks/BUILD index 70954c290..b4d010e02 100644 --- a/plugins/pubsub/mocks/BUILD +++ b/plugins/pubsub/mocks/BUILD @@ -1,5 +1,7 @@ -load("//:index.bzl", "generate_manifest") -load("//:index.bzl", "javascript_pipeline") +load("//:index.bzl", "generate_manifest","javascript_pipeline") + + + filegroup( name = "mocks", diff --git a/plugins/pubsub/mocks/index.ts b/plugins/pubsub/mocks/index.ts index 727120cf6..e69de29bb 100644 --- a/plugins/pubsub/mocks/index.ts +++ b/plugins/pubsub/mocks/index.ts @@ -1,7 +0,0 @@ -export interface Mock { - group: string; - name: string; - path: string; -} - -export type Manifest = Array; diff --git a/plugins/pubsub/mocks/pubsub/pub-sub-basic.json b/plugins/pubsub/mocks/pubsub/pub-sub-basic.json index 28c774ac0..c87a91691 100644 --- a/plugins/pubsub/mocks/pubsub/pub-sub-basic.json +++ b/plugins/pubsub/mocks/pubsub/pub-sub-basic.json @@ -2,38 +2,16 @@ "id": "generated-flow", "views": [ { - "id": "collection", - "type": "collection", - "values": [ - { - "asset": { - "id": "action", - "type": "action", - "exp": "@[ publish('some-event', 'event published message') ]@", - "label": { - "asset": { - "id": "action-label", - "type": "text", - "value": "Clicked to publish event" - } - } - } - }, - { - "asset": { - "id": "action-end", - "type": "action", - "value": "Next", - "label": { - "asset": { - "id": "action-end-label", - "type": "text", - "value": "End the flow (View pubsub events)" - } - } - } + "id": "action", + "type": "action", + "exp": "@[ publish('some-event', 'event published message') ]@", + "label": { + "asset": { + "id": "action-label", + "type": "text", + "value": "Clicked to publish event" } - ] + } } ], "data": { @@ -45,7 +23,7 @@ "startState": "VIEW_1", "VIEW_1": { "state_type": "VIEW", - "ref": "collection", + "ref": "action", "transitions": { "*": "END_Done" } From d429b2b37227efb511ecb90643c6d7fc12b183c2 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Fri, 17 Nov 2023 17:14:27 -0800 Subject: [PATCH 26/37] iOS: make AssetBeacon equatable and add public init for metadata (#248) make AssetBeacon equatable and add public init for metadata --- ios/packages/core/Sources/Types/Assets/Wrappers.swift | 5 +++++ ios/packages/core/Sources/Types/Beacon.swift | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ios/packages/core/Sources/Types/Assets/Wrappers.swift b/ios/packages/core/Sources/Types/Assets/Wrappers.swift index a965a9792..e32fdfd37 100644 --- a/ios/packages/core/Sources/Types/Assets/Wrappers.swift +++ b/ios/packages/core/Sources/Types/Assets/Wrappers.swift @@ -90,4 +90,9 @@ public struct MetaData: Codable, Hashable { /// The role of this asset public var role: String? + + public init(beacon: AnyType?, role: String? = nil) { + self.beacon = beacon + self.role = role + } } diff --git a/ios/packages/core/Sources/Types/Beacon.swift b/ios/packages/core/Sources/Types/Beacon.swift index 2dda5e956..bc49c443f 100644 --- a/ios/packages/core/Sources/Types/Beacon.swift +++ b/ios/packages/core/Sources/Types/Beacon.swift @@ -10,7 +10,7 @@ import Foundation /** An object representing a beacon fired from an `Asset` */ -public struct AssetBeacon: Codable { +public struct AssetBeacon: Codable, Equatable { /// The action that caused the beacon public var action: String @@ -49,7 +49,7 @@ public protocol BeaconableMetaData { } /// Container Object for matching the data type for the JS Beacon Plugin -public struct BeaconableAsset: Codable { +public struct BeaconableAsset: Codable, Equatable { /// The ID of the asset that fired the beacon public var id: String From af597a9e1dd58759a55e84a262e04cd28b4e5ed8 Mon Sep 17 00:00:00 2001 From: Adam Dierkens Date: Sat, 18 Nov 2023 17:56:22 -0500 Subject: [PATCH 27/37] Update ruby version in build (#246) The version used is EOL and adds to the ios build time to install --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f90d52be..2e089597a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -120,8 +120,7 @@ jobs: - run: name: Set Ruby Version command: | - rbenv install 2.6.10 - rbenv global 2.6.10 + rbenv global 2.7.8 rbenv rehash - restore_cache: @@ -161,7 +160,7 @@ jobs: - save_cache: key: gem-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }} paths: - - ~/.gem/ruby/2.7.5 + - ~/.gem/ruby/2.7.8 - macos/preboot-simulator: version: "15.5" From b818ef2f27e9c6cf982bc742e21a923c1c61ef22 Mon Sep 17 00:00:00 2001 From: intuit-svc Date: Mon, 20 Nov 2023 16:59:47 +0000 Subject: [PATCH 28/37] Release main From bd414d89f65cbf9e31ae6a899f0f61a1e15b2323 Mon Sep 17 00:00:00 2001 From: intuit-svc Date: Mon, 20 Nov 2023 09:38:44 -0800 Subject: [PATCH 29/37] Update CHANGELOG.md [skip ci] --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc1ba360..c4539e80a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +# 0.4.4 (Mon Nov 20 2023) + +#### 🐛 Bug Fix + +- Release main [#249](https://github.com/player-ui/player/pull/249) ([@intuit-svc](https://github.com/intuit-svc)) +- iOS: make AssetBeacon equatable and add public init for metadata [#248](https://github.com/player-ui/player/pull/248) ([@hborawski](https://github.com/hborawski)) + +#### 🏠 Internal + +- Update ruby version in build [#246](https://github.com/player-ui/player/pull/246) ([@adierkens](https://github.com/adierkens)) + +#### Authors: 3 + +- [@intuit-svc](https://github.com/intuit-svc) +- Adam Dierkens ([@adierkens](https://github.com/adierkens)) +- Harris Borawski ([@hborawski](https://github.com/hborawski)) + +--- + # 0.4.3 (Fri Nov 17 2023) ### Release Notes From 627a8d08e141f434bed3857261d4746556185e4c Mon Sep 17 00:00:00 2001 From: intuit-svc Date: Mon, 20 Nov 2023 09:38:44 -0800 Subject: [PATCH 30/37] Bump version to: v0.4.4 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 70d5b25fa..b300caa32 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.3 \ No newline at end of file +0.4.4 \ No newline at end of file From 99bb00a146d2c5cd9ff5ab9ab317e550393d32f8 Mon Sep 17 00:00:00 2001 From: zwu01 Date: Tue, 24 Oct 2023 16:11:09 -0400 Subject: [PATCH 31/37] add user info to assetViewModel --- .../reference-assets/Sources/SwiftUI/InputAsset.swift | 2 +- .../swiftui/Sources/types/assets/ControlledAsset.swift | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift index 7603a4ec9..c62c7f613 100644 --- a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift +++ b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift @@ -49,7 +49,7 @@ open class InputAssetViewModel: AssetViewModel { - data: The `InputData` decoded from the core player - userInfo: The `userInfo` from the decoder */ - public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]) { + public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]? = nil) { super.init(data, userInfo: userInfo) $data.sink { [weak self] (newData) in (newData.value?.stringValue).map { self?.text = $0 } diff --git a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift index b6c1e3f7f..f11be8a6c 100644 --- a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift +++ b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift @@ -16,7 +16,7 @@ open class AssetViewModel: ObservableObject { @Published public var data: T /// Any contextual information set by the user - public var userInfo: [CodingUserInfoKey: Any] + public var userInfo: [CodingUserInfoKey: Any]? /// Set to store subscriptions in for cancellation public var bag = Set() @@ -25,9 +25,9 @@ open class AssetViewModel: ObservableObject { Constructs an instance of this ViewModel with the given data - parameters: - data: The data to publish from this ViewModel - - userInfo: Any contextual information set by the user + - userInfo: Any contextual information set by the user */ - public required init(_ data: T, userInfo: [CodingUserInfoKey: Any] = [:]) { + public required init(_ data: T, userInfo: [CodingUserInfoKey: Any]? = nil) { self._data = Published(initialValue: data) self.userInfo = userInfo } From 262a1b7cf0367706e39d862109d97636827d7716 Mon Sep 17 00:00:00 2001 From: zwu01 Date: Wed, 25 Oct 2023 11:11:38 -0400 Subject: [PATCH 32/37] address comments --- .../reference-assets/Sources/SwiftUI/InputAsset.swift | 2 +- .../swiftui/Sources/types/assets/ControlledAsset.swift | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift index c62c7f613..7603a4ec9 100644 --- a/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift +++ b/ios/packages/reference-assets/Sources/SwiftUI/InputAsset.swift @@ -49,7 +49,7 @@ open class InputAssetViewModel: AssetViewModel { - data: The `InputData` decoded from the core player - userInfo: The `userInfo` from the decoder */ - public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]? = nil) { + public required init(_ data: InputData, userInfo: [CodingUserInfoKey: Any]) { super.init(data, userInfo: userInfo) $data.sink { [weak self] (newData) in (newData.value?.stringValue).map { self?.text = $0 } diff --git a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift index f11be8a6c..b6c1e3f7f 100644 --- a/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift +++ b/ios/packages/swiftui/Sources/types/assets/ControlledAsset.swift @@ -16,7 +16,7 @@ open class AssetViewModel: ObservableObject { @Published public var data: T /// Any contextual information set by the user - public var userInfo: [CodingUserInfoKey: Any]? + public var userInfo: [CodingUserInfoKey: Any] /// Set to store subscriptions in for cancellation public var bag = Set() @@ -25,9 +25,9 @@ open class AssetViewModel: ObservableObject { Constructs an instance of this ViewModel with the given data - parameters: - data: The data to publish from this ViewModel - - userInfo: Any contextual information set by the user + - userInfo: Any contextual information set by the user */ - public required init(_ data: T, userInfo: [CodingUserInfoKey: Any]? = nil) { + public required init(_ data: T, userInfo: [CodingUserInfoKey: Any] = [:]) { self._data = Published(initialValue: data) self.userInfo = userInfo } From 1e55527785b0c4a6a9a4617c69093553d45388a9 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Fri, 27 Oct 2023 13:07:02 -0700 Subject: [PATCH 33/37] apply swift 6 warning fix to flaky iOS tests (#207) --- .../Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift index 14e1d84f2..f9e81bd9c 100644 --- a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift +++ b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift @@ -44,6 +44,7 @@ class ManagedPlayerViewModelTests: XCTestCase { let state = CompletedState.createInstance(from: stateObj)! viewModel.result = .success(state) + try await Task.sleep(nanoseconds: 1_000_000_000) await fulfillment(of: [completed], timeout: 2) } From 6543efa8f559e5a32da4c82920087a7d6cb2d60b Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Tue, 31 Oct 2023 10:11:44 -0700 Subject: [PATCH 34/37] store cancellables in ManagedPlayerViewModelTests (#210) --- .../ManagedPlayerViewModelTests.swift | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift index f9e81bd9c..081f2919e 100644 --- a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift +++ b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift @@ -17,6 +17,13 @@ class ManagedPlayerViewModelTests: XCTestCase { let flow1 = FlowData.COUNTER let flow2 = FlowData.COUNTER.replacingOccurrences(of: "counter-flow", with: "counter-flow-2") + var bag = Set() + + override func tearDown() { + bag.forEach { $0.cancel() } + bag.removeAll() + } + func testViewModelSuccessFlow() async throws { let flowManager = ConstantFlowManager([flow1], delay: 0) @@ -27,7 +34,7 @@ class ManagedPlayerViewModelTests: XCTestCase { Task { await viewModel.next() } - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -55,7 +62,7 @@ class ManagedPlayerViewModelTests: XCTestCase { Task { await viewModel.next() } - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -73,7 +80,8 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + try await Task.sleep(nanoseconds: 1_000_000_000) + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) } func testViewModelManagerError() async { @@ -108,7 +116,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) let result = """ { @@ -126,7 +134,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -135,7 +143,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) viewModel.retry() @@ -144,11 +152,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) await viewModel.next(state) - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) } func testViewModelReset() async throws { @@ -158,7 +166,7 @@ class ManagedPlayerViewModelTests: XCTestCase { await viewModel.next() - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) let result = """ { @@ -176,7 +184,8 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - await assertPublished(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 } + try await Task.sleep(nanoseconds: 1_000_000_000) + waitOnChange(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 }.store(in: &bag) viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -185,7 +194,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) viewModel.reset() @@ -194,11 +203,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - } + }.store(in: &bag) await viewModel.next() - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) } func testViewModelErrorFlow() async { @@ -214,7 +223,7 @@ class ManagedPlayerViewModelTests: XCTestCase { completed.fulfill() } - await assertPublished(AnyPublisher(viewModel.$flow)) { $0 != nil } + waitOnChange(AnyPublisher(viewModel.$flow)) { $0 != nil }.store(in: &bag) viewModel.result = .failure(.jsConversionFailure) From b4c2f79c81a328fcf91d09a9e38957d37d014647 Mon Sep 17 00:00:00 2001 From: mercillo Date: Wed, 8 Nov 2023 13:25:30 -0800 Subject: [PATCH 35/37] modified test names --- .../com/intuit/player/android/reference/assets/test/deps.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl index f16df1ac7..a4a2208d9 100644 --- a/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl +++ b/plugins/reference-assets/android/src/androidTest/java/com/intuit/player/android/reference/assets/test/deps.bzl @@ -15,5 +15,4 @@ main_deps = parse_coordinates(maven) + [ "//plugins/common-types/jvm:common-types", "//plugins/pending-transaction/jvm:pending-transaction", "//plugins/reference-assets/android:assets", - ] From 9286c3802464fb1aee0474be4fc6472bb49641e9 Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 21 Nov 2023 09:54:10 -0800 Subject: [PATCH 36/37] mandatory not needed --- index.bzl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.bzl b/index.bzl index 414177123..229a4d78d 100644 --- a/index.bzl +++ b/index.bzl @@ -197,8 +197,7 @@ def _generate_manifest(context): generate_manifest = rule( attrs = { - "mocks": attr.label_list( - mandatory = True, + "mocks": attr.label_list( allow_files = [".json"], ), }, From f630cce94c37d8fe5cb21473c5e10fcccbeaece1 Mon Sep 17 00:00:00 2001 From: mercillo Date: Tue, 21 Nov 2023 10:21:05 -0800 Subject: [PATCH 37/37] rebase picked up wrong file changes --- .../ManagedPlayerViewModelTests.swift | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift index 081f2919e..f20e17806 100644 --- a/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift +++ b/ios/packages/swiftui/Tests/ManagedPlayer/ManagedPlayerViewModelTests.swift @@ -17,13 +17,6 @@ class ManagedPlayerViewModelTests: XCTestCase { let flow1 = FlowData.COUNTER let flow2 = FlowData.COUNTER.replacingOccurrences(of: "counter-flow", with: "counter-flow-2") - var bag = Set() - - override func tearDown() { - bag.forEach { $0.cancel() } - bag.removeAll() - } - func testViewModelSuccessFlow() async throws { let flowManager = ConstantFlowManager([flow1], delay: 0) @@ -34,7 +27,7 @@ class ManagedPlayerViewModelTests: XCTestCase { Task { await viewModel.next() } - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } let result = """ { @@ -51,7 +44,6 @@ class ManagedPlayerViewModelTests: XCTestCase { let state = CompletedState.createInstance(from: stateObj)! viewModel.result = .success(state) - try await Task.sleep(nanoseconds: 1_000_000_000) await fulfillment(of: [completed], timeout: 2) } @@ -62,7 +54,7 @@ class ManagedPlayerViewModelTests: XCTestCase { Task { await viewModel.next() } - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } let result = """ { @@ -80,8 +72,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - try await Task.sleep(nanoseconds: 1_000_000_000) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } } func testViewModelManagerError() async { @@ -116,7 +107,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - }.store(in: &bag) + } let result = """ { @@ -134,7 +125,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -143,7 +134,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - }.store(in: &bag) + } viewModel.retry() @@ -152,11 +143,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - }.store(in: &bag) + } await viewModel.next(state) - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow2 } } func testViewModelReset() async throws { @@ -166,7 +157,7 @@ class ManagedPlayerViewModelTests: XCTestCase { await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } let result = """ { @@ -184,8 +175,7 @@ class ManagedPlayerViewModelTests: XCTestCase { viewModel.result = .success(state) - try await Task.sleep(nanoseconds: 1_000_000_000) - waitOnChange(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow), timeout: 10) { $0 == self.flow2 } viewModel.result = .failure(PlayerError.jsConversionFailure) @@ -194,7 +184,7 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - }.store(in: &bag) + } viewModel.reset() @@ -203,11 +193,11 @@ class ManagedPlayerViewModelTests: XCTestCase { return true } return false - }.store(in: &bag) + } await viewModel.next() - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 == self.flow1 } } func testViewModelErrorFlow() async { @@ -223,7 +213,7 @@ class ManagedPlayerViewModelTests: XCTestCase { completed.fulfill() } - waitOnChange(AnyPublisher(viewModel.$flow)) { $0 != nil }.store(in: &bag) + await assertPublished(AnyPublisher(viewModel.$flow)) { $0 != nil } viewModel.result = .failure(.jsConversionFailure) @@ -323,4 +313,4 @@ internal extension XCTestCase { await fulfillment(of: [expectation], timeout: timeout) return cancel } -} +} \ No newline at end of file