|
| 1 | +/** |
| 2 | + * Mock message payloads for in-app message testing |
| 3 | + * |
| 4 | + * These are raw InAppMessage objects used for tests that need precise control |
| 5 | + * over message structure without using the MessageFactory. |
| 6 | + */ |
| 7 | + |
| 8 | +import { InAppMessage } from '@iterable/web-sdk'; |
| 9 | + |
| 10 | +/** |
| 11 | + * Simple messages for position testing |
| 12 | + */ |
| 13 | +export const PositionTestMessages = { |
| 14 | + topRight: (): InAppMessage => ({ |
| 15 | + messageId: 'topright-test', |
| 16 | + campaignId: 70001, |
| 17 | + createdAt: Date.now(), |
| 18 | + expiresAt: Date.now() + 3600000, |
| 19 | + content: { |
| 20 | + html: ` |
| 21 | + <html> |
| 22 | + <head><style>body { margin: 0; padding: 20px; background: white; }</style></head> |
| 23 | + <body> |
| 24 | + <h3>TopRight Message</h3> |
| 25 | + <p>This should appear in top-right corner</p> |
| 26 | + <button style="position: absolute; top: 8px; right: 8px;">✕</button> |
| 27 | + </body> |
| 28 | + </html> |
| 29 | + `, |
| 30 | + payload: {}, |
| 31 | + inAppDisplaySettings: { |
| 32 | + top: { displayOption: 'AutoExpand' }, |
| 33 | + right: { percentage: 0 }, |
| 34 | + bottom: { displayOption: 'AutoExpand' }, |
| 35 | + left: { percentage: 0 }, |
| 36 | + shouldAnimate: true |
| 37 | + }, |
| 38 | + webInAppDisplaySettings: { position: 'TopRight' } |
| 39 | + }, |
| 40 | + customPayload: {}, |
| 41 | + trigger: { type: 'immediate' }, |
| 42 | + saveToInbox: true, |
| 43 | + inboxMetadata: { title: 'Test', subtitle: '', icon: '' }, |
| 44 | + priorityLevel: 350.0, |
| 45 | + read: false, |
| 46 | + jsonOnly: false, |
| 47 | + typeOfContent: 'Dynamic', |
| 48 | + messageType: 'Web' |
| 49 | + }), |
| 50 | + |
| 51 | + bottomRight: (): InAppMessage => ({ |
| 52 | + messageId: 'bottomright-test', |
| 53 | + campaignId: 70002, |
| 54 | + createdAt: Date.now(), |
| 55 | + expiresAt: Date.now() + 86400000, |
| 56 | + content: { |
| 57 | + html: ` |
| 58 | + <html> |
| 59 | + <head><style>body { margin: 0; padding: 20px; background: white; }</style></head> |
| 60 | + <body> |
| 61 | + <h3>BottomRight Message</h3> |
| 62 | + <p>This should appear in bottom-right corner</p> |
| 63 | + <button style="position: absolute; top: 8px; right: 8px;">✕</button> |
| 64 | + </body> |
| 65 | + </html> |
| 66 | + `, |
| 67 | + payload: {}, |
| 68 | + inAppDisplaySettings: { |
| 69 | + top: { displayOption: 'AutoExpand' }, |
| 70 | + right: { percentage: 0 }, |
| 71 | + bottom: { displayOption: 'AutoExpand' }, |
| 72 | + left: { percentage: 0 }, |
| 73 | + shouldAnimate: true |
| 74 | + }, |
| 75 | + webInAppDisplaySettings: { position: 'BottomRight' } |
| 76 | + }, |
| 77 | + customPayload: {}, |
| 78 | + trigger: { type: 'immediate' }, |
| 79 | + saveToInbox: true, |
| 80 | + inboxMetadata: { title: 'Test', subtitle: '', icon: '' }, |
| 81 | + priorityLevel: 300.0, |
| 82 | + read: false, |
| 83 | + jsonOnly: false, |
| 84 | + typeOfContent: 'Dynamic', |
| 85 | + messageType: 'Web' |
| 86 | + }), |
| 87 | + |
| 88 | + bottom: (): InAppMessage => ({ |
| 89 | + messageId: 'bottom-banner', |
| 90 | + campaignId: 60008, |
| 91 | + createdAt: Date.now(), |
| 92 | + expiresAt: Date.now() + 86400000 * 365, |
| 93 | + content: { |
| 94 | + html: ` |
| 95 | + <html> |
| 96 | + <head><style>body { margin: 0; padding: 15px; background: #f5f5f5; text-align: center; }</style></head> |
| 97 | + <body> |
| 98 | + <p>Bottom Banner Content</p> |
| 99 | + <button style="position: absolute; top: 5px; right: 5px;">✕</button> |
| 100 | + </body> |
| 101 | + </html> |
| 102 | + `, |
| 103 | + payload: {}, |
| 104 | + inAppDisplaySettings: { |
| 105 | + top: { displayOption: 'AutoExpand' }, |
| 106 | + right: { percentage: 0 }, |
| 107 | + bottom: { displayOption: 'AutoExpand' }, |
| 108 | + left: { percentage: 0 }, |
| 109 | + shouldAnimate: false |
| 110 | + }, |
| 111 | + webInAppDisplaySettings: { position: 'Bottom' } |
| 112 | + }, |
| 113 | + customPayload: {}, |
| 114 | + trigger: { type: 'immediate' }, |
| 115 | + saveToInbox: false, |
| 116 | + inboxMetadata: { title: '', subtitle: '', icon: '' }, |
| 117 | + priorityLevel: 500.0, |
| 118 | + read: false, |
| 119 | + jsonOnly: false, |
| 120 | + typeOfContent: 'Dynamic', |
| 121 | + messageType: 'Web' |
| 122 | + }) |
| 123 | +}; |
| 124 | + |
| 125 | +/** |
| 126 | + * Messages for URL handling tests |
| 127 | + */ |
| 128 | +export const URLHandlingMessages = { |
| 129 | + iterableDismiss: (): InAppMessage => ({ |
| 130 | + messageId: 'iterable-dismiss-url', |
| 131 | + campaignId: 70003, |
| 132 | + createdAt: Date.now(), |
| 133 | + expiresAt: Date.now() + 86400000, |
| 134 | + content: { |
| 135 | + html: ` |
| 136 | + <html> |
| 137 | + <head><style>body { margin: 0; padding: 20px; background: white; }</style></head> |
| 138 | + <body> |
| 139 | + <h2>Test Dismiss URL</h2> |
| 140 | + <a href="iterable://dismiss" class="dismiss-link" data-qa-original-link="iterable://dismiss">Dismiss</a> |
| 141 | + <button>✕</button> |
| 142 | + </body> |
| 143 | + </html> |
| 144 | + `, |
| 145 | + payload: {}, |
| 146 | + inAppDisplaySettings: { |
| 147 | + top: { displayOption: 'AutoExpand' }, |
| 148 | + right: { percentage: 0 }, |
| 149 | + bottom: { displayOption: 'AutoExpand' }, |
| 150 | + left: { percentage: 0 }, |
| 151 | + shouldAnimate: true |
| 152 | + }, |
| 153 | + webInAppDisplaySettings: { position: 'Center' } |
| 154 | + }, |
| 155 | + customPayload: {}, |
| 156 | + trigger: { type: 'immediate' }, |
| 157 | + saveToInbox: true, |
| 158 | + inboxMetadata: { title: 'Test', subtitle: '', icon: '' }, |
| 159 | + priorityLevel: 300.0, |
| 160 | + read: false, |
| 161 | + jsonOnly: false, |
| 162 | + typeOfContent: 'Dynamic', |
| 163 | + messageType: 'Web' |
| 164 | + }), |
| 165 | + |
| 166 | + actionURL: (): InAppMessage => ({ |
| 167 | + messageId: 'action-url', |
| 168 | + campaignId: 70004, |
| 169 | + createdAt: Date.now(), |
| 170 | + expiresAt: Date.now() + 86400000, |
| 171 | + content: { |
| 172 | + html: ` |
| 173 | + <html> |
| 174 | + <head><style>body { margin: 0; padding: 20px; background: white; }</style></head> |
| 175 | + <body> |
| 176 | + <h2>Test Action URL</h2> |
| 177 | + <a href="action://navigate-home" class="action-link" data-qa-original-link="action://navigate-home">Go Home</a> |
| 178 | + <button>✕</button> |
| 179 | + </body> |
| 180 | + </html> |
| 181 | + `, |
| 182 | + payload: {}, |
| 183 | + inAppDisplaySettings: { |
| 184 | + top: { displayOption: 'AutoExpand' }, |
| 185 | + right: { percentage: 0 }, |
| 186 | + bottom: { displayOption: 'AutoExpand' }, |
| 187 | + left: { percentage: 0 }, |
| 188 | + shouldAnimate: true |
| 189 | + }, |
| 190 | + webInAppDisplaySettings: { position: 'Center' } |
| 191 | + }, |
| 192 | + customPayload: { action: 'navigate-home' }, |
| 193 | + trigger: { type: 'immediate' }, |
| 194 | + saveToInbox: true, |
| 195 | + inboxMetadata: { title: 'Test', subtitle: '', icon: '' }, |
| 196 | + priorityLevel: 300.0, |
| 197 | + read: false, |
| 198 | + jsonOnly: false, |
| 199 | + typeOfContent: 'Dynamic', |
| 200 | + messageType: 'Web' |
| 201 | + }) |
| 202 | +}; |
| 203 | + |
| 204 | +/** |
| 205 | + * Messages for close button feature tests |
| 206 | + */ |
| 207 | +export const CloseButtonMessages = { |
| 208 | + requiredDismiss: (): InAppMessage => ({ |
| 209 | + messageId: 'required-dismiss', |
| 210 | + campaignId: 80002, |
| 211 | + createdAt: Date.now(), |
| 212 | + expiresAt: Date.now() + 86400000, |
| 213 | + content: { |
| 214 | + html: ` |
| 215 | + <html> |
| 216 | + <head><style>body { margin: 0; padding: 30px; background: white; text-align: center; }</style></head> |
| 217 | + <body> |
| 218 | + <h2>Important Message</h2> |
| 219 | + <p>You must click the button to dismiss this message</p> |
| 220 | + <button id="close-btn" style="position: absolute; top: 10px; right: 10px; background: #007bff; border: none; color: white; padding: 10px 20px; border-radius: 5px; cursor: pointer;">Got It</button> |
| 221 | + </body> |
| 222 | + </html> |
| 223 | + `, |
| 224 | + payload: {}, |
| 225 | + inAppDisplaySettings: { |
| 226 | + top: { displayOption: 'AutoExpand' }, |
| 227 | + right: { percentage: 0 }, |
| 228 | + bottom: { displayOption: 'AutoExpand' }, |
| 229 | + left: { percentage: 0 }, |
| 230 | + shouldAnimate: true |
| 231 | + }, |
| 232 | + webInAppDisplaySettings: { position: 'Center' } |
| 233 | + }, |
| 234 | + customPayload: { requiresDismiss: true }, |
| 235 | + trigger: { type: 'immediate' }, |
| 236 | + saveToInbox: true, |
| 237 | + inboxMetadata: { title: 'Important', subtitle: '', icon: '' }, |
| 238 | + priorityLevel: 100.0, |
| 239 | + read: false, |
| 240 | + jsonOnly: false, |
| 241 | + typeOfContent: 'Dynamic', |
| 242 | + messageType: 'Web' |
| 243 | + }), |
| 244 | + |
| 245 | + customStyling: (): InAppMessage => ({ |
| 246 | + messageId: 'custom-close-button', |
| 247 | + campaignId: 80003, |
| 248 | + createdAt: Date.now(), |
| 249 | + expiresAt: Date.now() + 86400000, |
| 250 | + content: { |
| 251 | + html: ` |
| 252 | + <html> |
| 253 | + <head><style>body { margin: 0; padding: 30px; background: white; }</style></head> |
| 254 | + <body> |
| 255 | + <h2>Custom Close Button</h2> |
| 256 | + <p>Testing custom button styling</p> |
| 257 | + <button style="position: absolute; top: 20px; right: 20px; background: #ff0000; border: none; color: white; width: 50px; height: 50px; border-radius: 50%; font-size: 24px; cursor: pointer;">✕</button> |
| 258 | + </body> |
| 259 | + </html> |
| 260 | + `, |
| 261 | + payload: {}, |
| 262 | + inAppDisplaySettings: { |
| 263 | + top: { displayOption: 'AutoExpand' }, |
| 264 | + right: { percentage: 0 }, |
| 265 | + bottom: { displayOption: 'AutoExpand' }, |
| 266 | + left: { percentage: 0 }, |
| 267 | + shouldAnimate: true |
| 268 | + }, |
| 269 | + webInAppDisplaySettings: { position: 'Center' } |
| 270 | + }, |
| 271 | + customPayload: {}, |
| 272 | + trigger: { type: 'immediate' }, |
| 273 | + saveToInbox: true, |
| 274 | + inboxMetadata: { title: 'Test', subtitle: '', icon: '' }, |
| 275 | + priorityLevel: 300.0, |
| 276 | + read: false, |
| 277 | + jsonOnly: false, |
| 278 | + typeOfContent: 'Dynamic', |
| 279 | + messageType: 'Web' |
| 280 | + }) |
| 281 | +}; |
0 commit comments