Skip to content

Commit fdfff03

Browse files
committed
fix(image_av): image accessory view now shows gifs
1 parent 202c044 commit fdfff03

File tree

9 files changed

+241
-11
lines changed

9 files changed

+241
-11
lines changed

Notification Agent Core/Controllers/HelpBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public final class HelpBuilder {
9696
"\n The payload for the accessory view:\n " +
9797
"- Text for " + "[ whitebox ]".red() + " view type;\n " +
9898
"- Text for " + "[ timer ]".red() + " view type. This will be timer's label. Use \"%@\" to define timer's position inside the label. Use " + "[ -timeout ]".yellow() + " argument to define timer's duration;\n " +
99-
"- File path/link for " + "[ image ]".red() + " view type;\n " +
99+
"- File path/link or base64 encoded string for " + "[ image ]".red() + " view type;\n " +
100100
"- Text with the format " + "\"/url TEXT /autoplay /delay INT\" ".green() + "for " + "[ video ]".red() + " view type;\n " +
101101
"- Text with the format " + "\"/percent DOUBLE /top_message TEXT /bottom_message TEXT /user_interaction_enabled BOOL /user_interruption_allowed BOOL\" ".green() + "for " + "[ progressbar ]".red() + " view type;\n " +
102102
"- Text with the format " + "\"/placeholder TEXT /title TEXT /value TEXT /required\" ".green() + "for the " + "[ input | secureinput ]".red() + " view type;\n " +

Notification Agent Onboarding UI Tests/NAOUITests.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,46 @@ class NAOUITests: XCTestCase {
1515
func testA1Onboarding() throws {
1616
let useCase = """
1717
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"pages":[{"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
18+
""" // pragma: allowlist-secret
19+
if let useCaseData = useCase.data(using: .utf8) {
20+
let app = XCUIApplication()
21+
app.launchArguments = [useCaseData.base64EncodedString()]
22+
app.launch()
23+
XCTAssert(app.staticTexts["onboarding_title"].exists)
24+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
25+
XCTAssert(app.staticTexts["onboarding_body"].exists)
26+
XCTAssert(app.buttons["main_button"].exists)
27+
XCTAssert(!app.buttons["secondary_button"].exists)
28+
XCTAssert(app.buttons["help_button"].exists)
29+
app.buttons["main_button"].tap()
30+
XCTAssert(app.staticTexts["onboarding_title"].exists)
31+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
32+
XCTAssert(app.staticTexts["onboarding_body"].exists)
33+
XCTAssert(app.buttons["main_button"].exists)
34+
XCTAssert(app.buttons["secondary_button"].exists)
35+
XCTAssert(app.buttons["tertiary_button"].exists)
36+
XCTAssert(app.buttons["help_button"].exists)
37+
app.buttons["main_button"].tap()
38+
XCTAssert(app.staticTexts["onboarding_title"].exists)
39+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
40+
XCTAssert(app.staticTexts["onboarding_body"].exists)
41+
XCTAssert(app.buttons["main_button"].exists)
42+
XCTAssert(!app.buttons["secondary_button"].exists)
43+
app.buttons["main_button"].tap()
44+
XCTAssert(app.staticTexts["onboarding_title"].exists)
45+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
46+
XCTAssert(app.staticTexts["onboarding_body"].exists)
47+
XCTAssert(app.buttons["main_button"].exists)
48+
XCTAssert(!app.buttons["secondary_button"].exists)
49+
} else {
50+
XCTAssert(false, "Failed to encode the usecase.")
51+
}
52+
}
53+
54+
/// Testing simple Onboarding UI with accessory views.
55+
func testA2Onboarding() throws {
56+
let useCase = """
57+
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"pages":[{"accessoryViews":[[{"type":"image","payload":"https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif?crop=780%2C520%2Cx0%2Cy0&width=2200"},{"type":"image","payload":"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg"}]],"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
1858
""" // pragma: allowlist-secret
1959
if let useCaseData = useCase.data(using: .utf8) {
2060
let app = XCUIApplication()

Notification Agent Popup UI Tests/NAPUITests.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,5 +1078,66 @@ class NAPUITests: XCTestCase {
10781078
XCTAssert(false, "Failed to encode the usecase.")
10791079
}
10801080
}
1081+
1082+
/// Testing Pop-up with:
1083+
/// Title: This is a title
1084+
/// Subtitle: This is a subtitle
1085+
/// Main Button: Primary
1086+
/// Secondary Button: Secondary
1087+
/// Icon: Circle SFSymbol
1088+
/// AccessoryView: image with a GIF
1089+
func testD7Popup() throws {
1090+
let useCase = """
1091+
{"notification":{"topicID":"untracked","mainButton":{"label":"Primary","callToActionType":"none","callToActionPayload":""},"secondaryButton":{"label":"Secondary","callToActionType":"none","callToActionPayload":""},"iconPath":"circle","hideTitleBarButtons":false,"retainValues":false,"alwaysOnTop":false,"type":"popup","title":"This is a title","subtitle":"This is a subtitle","silent":false,"showSuppressionButton":false,"miniaturizable":false,"barTitle":"Some","forceLightMode":false,"notificationID":"untracked","isMovable":true,"disableQuit":false,"buttonless":false, "accessoryViews":[{"type":"image","payload":"https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif?crop=780%2C520%2Cx0%2Cy0&width=2200"}]},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
1092+
""" // pragma: allowlist-secret
1093+
if let useCaseData = useCase.data(using: .utf8) {
1094+
let app = XCUIApplication()
1095+
app.launchArguments = [useCaseData.base64EncodedString()]
1096+
app.launch()
1097+
XCTAssert(app.buttons["main_button"].exists)
1098+
XCTAssertEqual(app.buttons["main_button"].title, "Primary")
1099+
XCTAssert(app.buttons["secondary_button"].exists)
1100+
XCTAssertEqual(app.buttons["secondary_button"].label, "Secondary")
1101+
XCTAssert(app.staticTexts["popup_title"].exists)
1102+
XCTAssertEqual(app.staticTexts["popup_title"].value as? String ?? "", "This is a title")
1103+
XCTAssert(app.staticTexts["popup_subtitle"].exists)
1104+
XCTAssertEqual(app.staticTexts["popup_subtitle"].value as? String ?? "", "This is a subtitle")
1105+
XCTAssert(app.images["image_accessory_view"].exists)
1106+
app.terminate()
1107+
} else {
1108+
XCTAssert(false, "Failed to encode the usecase.")
1109+
}
1110+
}
1111+
1112+
/// Testing Pop-up with:
1113+
/// Title: This is a title
1114+
/// Subtitle: This is a subtitle
1115+
/// Main Button: Primary
1116+
/// Secondary Button: Secondary
1117+
/// Icon: Circle SFSymbol
1118+
/// AccessoryView: image with a GIF
1119+
/// Secondary AccessoryView: image
1120+
func testD8Popup() throws {
1121+
let useCase = """
1122+
{"notification":{"topicID":"untracked","mainButton":{"label":"Primary","callToActionType":"none","callToActionPayload":""},"secondaryButton":{"label":"Secondary","callToActionType":"none","callToActionPayload":""},"iconPath":"circle","hideTitleBarButtons":false,"retainValues":false,"alwaysOnTop":false,"type":"popup","title":"This is a title","subtitle":"This is a subtitle","silent":false,"showSuppressionButton":false,"miniaturizable":false,"barTitle":"Some","forceLightMode":false,"notificationID":"untracked","isMovable":true,"disableQuit":false,"buttonless":false, "accessoryViews":[{"type":"image","payload":"https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif?crop=780%2C520%2Cx0%2Cy0&width=2200"},{"type":"image","payload":"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg"}]},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
1123+
""" // pragma: allowlist-secret
1124+
if let useCaseData = useCase.data(using: .utf8) {
1125+
let app = XCUIApplication()
1126+
app.launchArguments = [useCaseData.base64EncodedString()]
1127+
app.launch()
1128+
XCTAssert(app.buttons["main_button"].exists)
1129+
XCTAssertEqual(app.buttons["main_button"].title, "Primary")
1130+
XCTAssert(app.buttons["secondary_button"].exists)
1131+
XCTAssertEqual(app.buttons["secondary_button"].label, "Secondary")
1132+
XCTAssert(app.staticTexts["popup_title"].exists)
1133+
XCTAssertEqual(app.staticTexts["popup_title"].value as? String ?? "", "This is a title")
1134+
XCTAssert(app.staticTexts["popup_subtitle"].exists)
1135+
XCTAssertEqual(app.staticTexts["popup_subtitle"].value as? String ?? "", "This is a subtitle")
1136+
XCTAssert(app.images["image_accessory_view"].exists)
1137+
app.terminate()
1138+
} else {
1139+
XCTAssert(false, "Failed to encode the usecase.")
1140+
}
1141+
}
10811142
}
10821143
// swiftlint:enable type_body_length file_length

0 commit comments

Comments
 (0)