|
1 |
| -import { mergeStepsWithSingleChild } from '@src/plugins/helper'; |
| 1 | +import { |
| 2 | + mergeStepsWithSingleChild, |
| 3 | + removeFirstStepWhenSame, |
| 4 | +} from '@src/plugins/helper'; |
2 | 5 |
|
3 | 6 | describe('mergeStepsWithSingleChild', () => {
|
4 | 7 | it('nothing to merge', () => {
|
@@ -235,4 +238,235 @@ describe('mergeStepsWithSingleChild', () => {
|
235 | 238 | // { name: '2', steps: [] },
|
236 | 239 | // ]);
|
237 | 240 | // });
|
| 241 | + |
| 242 | + it('removeFirstMessageWhenSame', () => { |
| 243 | + const steps = [ |
| 244 | + { |
| 245 | + name: 'steps1', |
| 246 | + steps: [ |
| 247 | + { |
| 248 | + name: 'steps1', |
| 249 | + steps: [], |
| 250 | + }, |
| 251 | + { |
| 252 | + name: 'steps2', |
| 253 | + steps: [ |
| 254 | + { |
| 255 | + name: 'steps3', |
| 256 | + steps: [ |
| 257 | + { |
| 258 | + name: 'step1.1', |
| 259 | + steps: [ |
| 260 | + [ |
| 261 | + { name: 'step1.1', steps: [] }, |
| 262 | + { name: 'step1.2', steps: [] }, |
| 263 | + ], |
| 264 | + ], |
| 265 | + }, |
| 266 | + { name: 'step1.2', steps: [] }, |
| 267 | + ], |
| 268 | + }, |
| 269 | + ], |
| 270 | + }, |
| 271 | + ], |
| 272 | + }, |
| 273 | + { name: '2', steps: [] }, |
| 274 | + ] as any; |
| 275 | + const res = removeFirstStepWhenSame(steps); |
| 276 | + |
| 277 | + expect(res).toEqual([ |
| 278 | + { |
| 279 | + name: 'steps1', |
| 280 | + steps: [ |
| 281 | + { |
| 282 | + name: 'steps2', |
| 283 | + steps: [ |
| 284 | + { |
| 285 | + name: 'steps3', |
| 286 | + steps: [ |
| 287 | + { |
| 288 | + name: 'step1.1', |
| 289 | + steps: [{ name: 'step1.2', steps: [] }], |
| 290 | + }, |
| 291 | + { |
| 292 | + name: 'step1.2', |
| 293 | + steps: [], |
| 294 | + }, |
| 295 | + ], |
| 296 | + }, |
| 297 | + ], |
| 298 | + }, |
| 299 | + ], |
| 300 | + }, |
| 301 | + { |
| 302 | + name: '2', |
| 303 | + steps: [], |
| 304 | + }, |
| 305 | + ]); |
| 306 | + }); |
| 307 | + |
| 308 | + it('removeFirstMessageWhenSame - should not remove when has child steps', () => { |
| 309 | + const steps = [ |
| 310 | + { |
| 311 | + attachments: [], |
| 312 | + name: 'withGroupping', |
| 313 | + status: 'passed', |
| 314 | + steps: [ |
| 315 | + { |
| 316 | + attachments: [], |
| 317 | + name: 'withGroupping', |
| 318 | + status: 'passed', |
| 319 | + steps: [ |
| 320 | + { |
| 321 | + attachments: [], |
| 322 | + name: 'log: level 1', |
| 323 | + status: 'passed', |
| 324 | + steps: [], |
| 325 | + }, |
| 326 | + { |
| 327 | + attachments: [], |
| 328 | + name: 'withGroupping', |
| 329 | + status: 'passed', |
| 330 | + steps: [ |
| 331 | + { |
| 332 | + attachments: [], |
| 333 | + name: 'withGroupping', |
| 334 | + status: 'passed', |
| 335 | + steps: [ |
| 336 | + { |
| 337 | + attachments: [], |
| 338 | + name: 'log: level 2', |
| 339 | + status: 'passed', |
| 340 | + steps: [], |
| 341 | + }, |
| 342 | + ], |
| 343 | + }, |
| 344 | + { |
| 345 | + attachments: [], |
| 346 | + name: 'endLogGroup', |
| 347 | + status: 'passed', |
| 348 | + steps: [], |
| 349 | + }, |
| 350 | + ], |
| 351 | + }, |
| 352 | + ], |
| 353 | + }, |
| 354 | + { |
| 355 | + attachments: [], |
| 356 | + name: 'endLogGroup', |
| 357 | + status: 'passed', |
| 358 | + steps: [], |
| 359 | + }, |
| 360 | + ], |
| 361 | + }, |
| 362 | + { |
| 363 | + attachments: [], |
| 364 | + name: 'withGroupping', |
| 365 | + status: 'passed', |
| 366 | + steps: [ |
| 367 | + { |
| 368 | + attachments: [], |
| 369 | + name: 'withGroupping', |
| 370 | + status: 'passed', |
| 371 | + steps: [ |
| 372 | + { |
| 373 | + attachments: [], |
| 374 | + name: 'log: level 1 again', |
| 375 | + status: 'passed', |
| 376 | + steps: [], |
| 377 | + }, |
| 378 | + ], |
| 379 | + }, |
| 380 | + { |
| 381 | + attachments: [], |
| 382 | + name: 'endLogGroup', |
| 383 | + status: 'passed', |
| 384 | + steps: [], |
| 385 | + }, |
| 386 | + ], |
| 387 | + }, |
| 388 | + ] as any; |
| 389 | + const res = removeFirstStepWhenSame(steps); |
| 390 | + |
| 391 | + expect(res).toEqual([ |
| 392 | + { |
| 393 | + attachments: [], |
| 394 | + name: 'withGroupping', |
| 395 | + status: 'passed', |
| 396 | + steps: [ |
| 397 | + { |
| 398 | + attachments: [], |
| 399 | + name: 'withGroupping', |
| 400 | + status: 'passed', |
| 401 | + steps: [ |
| 402 | + { |
| 403 | + attachments: [], |
| 404 | + name: 'log: level 1', |
| 405 | + status: 'passed', |
| 406 | + steps: [], |
| 407 | + }, |
| 408 | + { |
| 409 | + attachments: [], |
| 410 | + name: 'withGroupping', |
| 411 | + status: 'passed', |
| 412 | + steps: [ |
| 413 | + { |
| 414 | + attachments: [], |
| 415 | + name: 'withGroupping', |
| 416 | + status: 'passed', |
| 417 | + steps: [ |
| 418 | + { |
| 419 | + attachments: [], |
| 420 | + name: 'log: level 2', |
| 421 | + status: 'passed', |
| 422 | + steps: [], |
| 423 | + }, |
| 424 | + ], |
| 425 | + }, |
| 426 | + { |
| 427 | + attachments: [], |
| 428 | + name: 'endLogGroup', |
| 429 | + status: 'passed', |
| 430 | + steps: [], |
| 431 | + }, |
| 432 | + ], |
| 433 | + }, |
| 434 | + ], |
| 435 | + }, |
| 436 | + { |
| 437 | + attachments: [], |
| 438 | + name: 'endLogGroup', |
| 439 | + status: 'passed', |
| 440 | + steps: [], |
| 441 | + }, |
| 442 | + ], |
| 443 | + }, |
| 444 | + { |
| 445 | + attachments: [], |
| 446 | + name: 'withGroupping', |
| 447 | + status: 'passed', |
| 448 | + steps: [ |
| 449 | + { |
| 450 | + attachments: [], |
| 451 | + name: 'withGroupping', |
| 452 | + status: 'passed', |
| 453 | + steps: [ |
| 454 | + { |
| 455 | + attachments: [], |
| 456 | + name: 'log: level 1 again', |
| 457 | + status: 'passed', |
| 458 | + steps: [], |
| 459 | + }, |
| 460 | + ], |
| 461 | + }, |
| 462 | + { |
| 463 | + attachments: [], |
| 464 | + name: 'endLogGroup', |
| 465 | + status: 'passed', |
| 466 | + steps: [], |
| 467 | + }, |
| 468 | + ], |
| 469 | + }, |
| 470 | + ]); |
| 471 | + }); |
238 | 472 | });
|
0 commit comments