|
9 | 9 | searchSessionSavedObjectMigrations, |
10 | 10 | SearchSessionSavedObjectAttributesPre$7$13$0, |
11 | 11 | SearchSessionSavedObjectAttributesPre$7$14$0, |
| 12 | + SearchSessionSavedObjectAttributesPre$8$0$0, |
12 | 13 | } from './search_session_migration'; |
13 | 14 | import { SavedObject } from '../../../../../src/core/types'; |
14 | 15 | import { SEARCH_SESSION_TYPE, SearchSessionStatus } from '../../../../../src/plugins/data/common'; |
@@ -164,3 +165,193 @@ describe('7.13.0 -> 7.14.0', () => { |
164 | 165 | `); |
165 | 166 | }); |
166 | 167 | }); |
| 168 | + |
| 169 | +describe('7.14.0 -> 7.18.0', () => { |
| 170 | + const migration = searchSessionSavedObjectMigrations['8.0.0']; |
| 171 | + |
| 172 | + test('Discover app URL generator migrates to locator', () => { |
| 173 | + const mockSessionSavedObject: SavedObject<SearchSessionSavedObjectAttributesPre$8$0$0> = { |
| 174 | + id: 'id', |
| 175 | + type: SEARCH_SESSION_TYPE, |
| 176 | + attributes: { |
| 177 | + name: 'my_name', |
| 178 | + appId: 'my_app_id', |
| 179 | + sessionId: 'sessionId', |
| 180 | + urlGeneratorId: 'DISCOVER_APP_URL_GENERATOR', |
| 181 | + initialState: {}, |
| 182 | + restoreState: {}, |
| 183 | + persisted: true, |
| 184 | + idMapping: {}, |
| 185 | + realmType: 'realmType', |
| 186 | + realmName: 'realmName', |
| 187 | + username: 'username', |
| 188 | + created: '2021-03-26T00:00:00.000Z', |
| 189 | + expires: '2021-03-30T00:00:00.000Z', |
| 190 | + touched: '2021-03-29T00:00:00.000Z', |
| 191 | + completed: '2021-03-29T00:00:00.000Z', |
| 192 | + status: SearchSessionStatus.COMPLETE, |
| 193 | + version: '7.14.0', |
| 194 | + }, |
| 195 | + references: [], |
| 196 | + }; |
| 197 | + |
| 198 | + const migratedSession = migration(mockSessionSavedObject, {} as SavedObjectMigrationContext); |
| 199 | + |
| 200 | + expect(migratedSession.attributes).toMatchInlineSnapshot(` |
| 201 | + Object { |
| 202 | + "appId": "my_app_id", |
| 203 | + "completed": "2021-03-29T00:00:00.000Z", |
| 204 | + "created": "2021-03-26T00:00:00.000Z", |
| 205 | + "expires": "2021-03-30T00:00:00.000Z", |
| 206 | + "idMapping": Object {}, |
| 207 | + "initialState": Object {}, |
| 208 | + "locatorId": "DISCOVER_APP_LOCATOR", |
| 209 | + "name": "my_name", |
| 210 | + "persisted": true, |
| 211 | + "realmName": "realmName", |
| 212 | + "realmType": "realmType", |
| 213 | + "restoreState": Object {}, |
| 214 | + "sessionId": "sessionId", |
| 215 | + "status": "complete", |
| 216 | + "touched": "2021-03-29T00:00:00.000Z", |
| 217 | + "username": "username", |
| 218 | + "version": "7.14.0", |
| 219 | + } |
| 220 | + `); |
| 221 | + }); |
| 222 | + |
| 223 | + test('Dashboard app URL generator migrates to locator', () => { |
| 224 | + const mockSessionSavedObject: SavedObject<SearchSessionSavedObjectAttributesPre$8$0$0> = { |
| 225 | + id: 'id', |
| 226 | + type: SEARCH_SESSION_TYPE, |
| 227 | + attributes: { |
| 228 | + name: 'my_name', |
| 229 | + appId: 'my_app_id', |
| 230 | + sessionId: 'sessionId', |
| 231 | + urlGeneratorId: 'DASHBOARD_APP_URL_GENERATOR', |
| 232 | + initialState: {}, |
| 233 | + restoreState: {}, |
| 234 | + persisted: true, |
| 235 | + idMapping: {}, |
| 236 | + realmType: 'realmType', |
| 237 | + realmName: 'realmName', |
| 238 | + username: 'username', |
| 239 | + created: '2021-03-26T00:00:00.000Z', |
| 240 | + expires: '2021-03-30T00:00:00.000Z', |
| 241 | + touched: '2021-03-29T00:00:00.000Z', |
| 242 | + completed: '2021-03-29T00:00:00.000Z', |
| 243 | + status: SearchSessionStatus.COMPLETE, |
| 244 | + version: '7.14.0', |
| 245 | + }, |
| 246 | + references: [], |
| 247 | + }; |
| 248 | + |
| 249 | + const migratedSession = migration(mockSessionSavedObject, {} as SavedObjectMigrationContext); |
| 250 | + |
| 251 | + expect(migratedSession.attributes).toMatchInlineSnapshot(` |
| 252 | + Object { |
| 253 | + "appId": "my_app_id", |
| 254 | + "completed": "2021-03-29T00:00:00.000Z", |
| 255 | + "created": "2021-03-26T00:00:00.000Z", |
| 256 | + "expires": "2021-03-30T00:00:00.000Z", |
| 257 | + "idMapping": Object {}, |
| 258 | + "initialState": Object {}, |
| 259 | + "locatorId": "DASHBOARD_APP_LOCATOR", |
| 260 | + "name": "my_name", |
| 261 | + "persisted": true, |
| 262 | + "realmName": "realmName", |
| 263 | + "realmType": "realmType", |
| 264 | + "restoreState": Object {}, |
| 265 | + "sessionId": "sessionId", |
| 266 | + "status": "complete", |
| 267 | + "touched": "2021-03-29T00:00:00.000Z", |
| 268 | + "username": "username", |
| 269 | + "version": "7.14.0", |
| 270 | + } |
| 271 | + `); |
| 272 | + }); |
| 273 | + |
| 274 | + test('Undefined URL generator returns undefined locator', () => { |
| 275 | + const mockSessionSavedObject: SavedObject<SearchSessionSavedObjectAttributesPre$8$0$0> = { |
| 276 | + id: 'id', |
| 277 | + type: SEARCH_SESSION_TYPE, |
| 278 | + attributes: { |
| 279 | + name: 'my_name', |
| 280 | + appId: 'my_app_id', |
| 281 | + sessionId: 'sessionId', |
| 282 | + urlGeneratorId: undefined, |
| 283 | + initialState: {}, |
| 284 | + restoreState: {}, |
| 285 | + persisted: true, |
| 286 | + idMapping: {}, |
| 287 | + realmType: 'realmType', |
| 288 | + realmName: 'realmName', |
| 289 | + username: 'username', |
| 290 | + created: '2021-03-26T00:00:00.000Z', |
| 291 | + expires: '2021-03-30T00:00:00.000Z', |
| 292 | + touched: '2021-03-29T00:00:00.000Z', |
| 293 | + completed: '2021-03-29T00:00:00.000Z', |
| 294 | + status: SearchSessionStatus.COMPLETE, |
| 295 | + version: '7.14.0', |
| 296 | + }, |
| 297 | + references: [], |
| 298 | + }; |
| 299 | + |
| 300 | + const migratedSession = migration(mockSessionSavedObject, {} as SavedObjectMigrationContext); |
| 301 | + |
| 302 | + expect(migratedSession.attributes).toMatchInlineSnapshot(` |
| 303 | + Object { |
| 304 | + "appId": "my_app_id", |
| 305 | + "completed": "2021-03-29T00:00:00.000Z", |
| 306 | + "created": "2021-03-26T00:00:00.000Z", |
| 307 | + "expires": "2021-03-30T00:00:00.000Z", |
| 308 | + "idMapping": Object {}, |
| 309 | + "initialState": Object {}, |
| 310 | + "locatorId": undefined, |
| 311 | + "name": "my_name", |
| 312 | + "persisted": true, |
| 313 | + "realmName": "realmName", |
| 314 | + "realmType": "realmType", |
| 315 | + "restoreState": Object {}, |
| 316 | + "sessionId": "sessionId", |
| 317 | + "status": "complete", |
| 318 | + "touched": "2021-03-29T00:00:00.000Z", |
| 319 | + "username": "username", |
| 320 | + "version": "7.14.0", |
| 321 | + } |
| 322 | + `); |
| 323 | + }); |
| 324 | + |
| 325 | + test('Other URL generator throws error', () => { |
| 326 | + const mockSessionSavedObject: SavedObject<SearchSessionSavedObjectAttributesPre$8$0$0> = { |
| 327 | + id: 'id', |
| 328 | + type: SEARCH_SESSION_TYPE, |
| 329 | + attributes: { |
| 330 | + name: 'my_name', |
| 331 | + appId: 'my_app_id', |
| 332 | + sessionId: 'sessionId', |
| 333 | + urlGeneratorId: 'my_url_generator_id', |
| 334 | + initialState: {}, |
| 335 | + restoreState: {}, |
| 336 | + persisted: true, |
| 337 | + idMapping: {}, |
| 338 | + realmType: 'realmType', |
| 339 | + realmName: 'realmName', |
| 340 | + username: 'username', |
| 341 | + created: '2021-03-26T00:00:00.000Z', |
| 342 | + expires: '2021-03-30T00:00:00.000Z', |
| 343 | + touched: '2021-03-29T00:00:00.000Z', |
| 344 | + completed: '2021-03-29T00:00:00.000Z', |
| 345 | + status: SearchSessionStatus.COMPLETE, |
| 346 | + version: '7.14.0', |
| 347 | + }, |
| 348 | + references: [], |
| 349 | + }; |
| 350 | + |
| 351 | + expect(() => |
| 352 | + migration(mockSessionSavedObject, {} as SavedObjectMigrationContext) |
| 353 | + ).toThrowErrorMatchingInlineSnapshot( |
| 354 | + `"No migration found for search session URL generator my_url_generator_id"` |
| 355 | + ); |
| 356 | + }); |
| 357 | +}); |
0 commit comments