| 1 | import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts'; |
| 2 | |
| 3 | describe('Gantt diagram', () => { |
| 4 | beforeEach(() => { |
| 5 | cy.clock(new Date('1010-10-10').getTime()); |
| 6 | }); |
| 7 | it('should render a gantt chart', () => { |
| 8 | imgSnapshotTest( |
| 9 | ` |
| 10 | gantt |
| 11 | dateFormat YYYY-MM-DD |
| 12 | axisFormat %d/%m |
| 13 | title Adding GANTT diagram to mermaid |
| 14 | excludes weekdays 2014-01-10 |
| 15 | |
| 16 | section A section |
| 17 | Completed task :done, des1, 2014-01-06,2014-01-08 |
| 18 | Active task :active, des2, 2014-01-09, 3d |
| 19 | Future task : des3, after des2, 5d |
| 20 | Future task2 : des4, after des3, 5d |
| 21 | |
| 22 | section Critical tasks |
| 23 | Completed task in the critical line :crit, done, 2014-01-06,24h |
| 24 | Implement parser and jison :crit, done, after des1, 2d |
| 25 | Create tests for parser :crit, active, 3d |
| 26 | Future task in critical line :crit, 5d |
| 27 | Create tests for renderer :2d |
| 28 | Add to mermaid :1d |
| 29 | |
| 30 | section Documentation |
| 31 | Describe gantt syntax :active, a1, after des1, 3d |
| 32 | Add gantt diagram to demo page :after a1 , 20h |
| 33 | Add another diagram to demo page :doc1, after a1 , 48h |
| 34 | |
| 35 | section Last section |
| 36 | Describe gantt syntax :after doc1, 3d |
| 37 | Add gantt diagram to demo page : 20h |
| 38 | Add another diagram to demo page : 48h |
| 39 | `, |
| 40 | {} |
| 41 | ); |
| 42 | }); |
| 43 | it('Handle multiline section titles with different line breaks', () => { |
| 44 | imgSnapshotTest( |
| 45 | ` |
| 46 | gantt |
| 47 | dateFormat YYYY-MM-DD |
| 48 | axisFormat %d/%m |
| 49 | title GANTT diagram with multiline section titles |
| 50 | excludes weekdays 2014-01-10 |
| 51 | |
| 52 | section A section<br>multiline |
| 53 | Completed task : done, des1, 2014-01-06,2014-01-08 |
| 54 | Active task : active, des2, 2014-01-09, 3d |
| 55 | Future task : des3, after des2, 5d |
| 56 | Future task2 : des4, after des3, 5d |
| 57 | |
| 58 | section Critical tasks<br/>multiline |
| 59 | Completed task in the critical line : crit, done, 2014-01-06, 24h |
| 60 | Implement parser and jison : crit, done, after des1, 2d |
| 61 | Create tests for parser : crit, active, 3d |
| 62 | Future task in critical line : crit, 5d |
| 63 | Create tests for renderer : 2d |
| 64 | Add to mermaid : 1d |
| 65 | |
| 66 | section Documentation<br />multiline |
| 67 | Describe gantt syntax : active, a1, after des1, 3d |
| 68 | Add gantt diagram to demo page : after a1, 20h |
| 69 | Add another diagram to demo page : doc1, after a1, 48h |
| 70 | |
| 71 | section Last section<br />multiline |
| 72 | Describe gantt syntax : after doc1, 3d |
| 73 | Add gantt diagram to demo page : 20h |
| 74 | Add another diagram to demo page : 48h |
| 75 | `, |
| 76 | {} |
| 77 | ); |
| 78 | }); |
| 79 | it('Multiple dependencies syntax', () => { |
| 80 | imgSnapshotTest( |
| 81 | ` |
| 82 | gantt |
| 83 | dateFormat YYYY-MM-DD |
| 84 | axisFormat %d/%m |
| 85 | title Adding GANTT diagram to mermaid |
| 86 | excludes weekdays 2014-01-10 |
| 87 | |
| 88 | apple :a, 2017-07-20, 1w |
| 89 | banana :crit, b, 2017-07-23, 1d |
| 90 | cherry :active, c, after b a, 1d |
| 91 | `, |
| 92 | {} |
| 93 | ); |
| 94 | }); |
| 95 | it('should handle multiple dependencies syntax with after and until', () => { |
| 96 | imgSnapshotTest( |
| 97 | ` |
| 98 | gantt |
| 99 | dateFormat YYYY-MM-DD |
| 100 | axisFormat %d/%m |
| 101 | title Adding GANTT diagram to mermaid |
| 102 | excludes weekdays 2014-01-10 |
| 103 | todayMarker off |
| 104 | |
| 105 | section team's critical event |
| 106 | deadline A :milestone, crit, deadlineA, 2024-02-01, 0 |
| 107 | deadline B :milestone, crit, deadlineB, 2024-02-15, 0 |
| 108 | boss on leave :bossaway, 2024-01-28, 2024-02-11 |
| 109 | |
| 110 | section new intern |
| 111 | onboarding :onboarding, 2024-01-02, 1w |
| 112 | literature review :litreview, 2024-01-02, 10d |
| 113 | project A :projectA, after onboarding litreview, until deadlineA bossaway |
| 114 | chilling :chilling, after projectA, until deadlineA |
| 115 | project B :projectB, after deadlineA, until deadlineB |
| 116 | `, |
| 117 | {} |
| 118 | ); |
| 119 | }); |
| 120 | it('should FAIL rendering a gantt chart for issue #1060 with invalid date', () => { |
| 121 | imgSnapshotTest( |
| 122 | ` |
| 123 | gantt |
| 124 | excludes weekdays 2017-01-10 |
| 125 | title Projects Timeline |
| 126 | |
| 127 | section asdf |
| 128 | specs :done, :ps, 2019-05-10, 50d |
| 129 | Plasma :pc, 2019-06-20, 60d |
| 130 | Rollup :or, 2019-08-20, 50d |
| 131 | |
| 132 | section CEL |
| 133 | |
| 134 | plasma-chamber :done, :pc, 2019-05-20, 60d |
| 135 | Plasma Implementation (Rust) :por, 2019-06-20, 120d |
| 136 | Predicates (Atomic Swap) :pred, 2019-07-20, 60d |
| 137 | |
| 138 | section DEX |
| 139 | |
| 140 | History zkSNARK :hs, 2019-08-10, 40d |
| 141 | Exit :vs, after hs, 60d |
| 142 | PredicateSpec :ps, 2019-09-1, 20d |
| 143 | PlasmaIntegration :pi, after ps,40d |
| 144 | |
| 145 | |
| 146 | section Events |
| 147 | |
| 148 | ETHBoston :done, :eb, 2019-09-08, 3d |
| 149 | DevCon :active, :dc, 2019-10-08, 3d |
| 150 | |
| 151 | section Plasma Calls & updates |
| 152 | OVM :ovm, 2019-07-12, 120d |
| 153 | Plasma call 26 :pc26, 2019-08-21, 1d |
| 154 | Plasma call 27 :pc27, 2019-09-03, 1d |
| 155 | Plasma call 28 :pc28, 2019-09-17, 1d |
| 156 | `, |
| 157 | {} |
| 158 | ); |
| 159 | }); |
| 160 | |
| 161 | it('should default to showing today marker', () => { |
| 162 | // This test only works if the environment thinks today is 1010-10-10 |
| 163 | imgSnapshotTest( |
| 164 | ` |
| 165 | gantt |
| 166 | title Show today marker (vertical line should be visible) |
| 167 | dateFormat YYYY-MM-DD |
| 168 | axisFormat %d |
| 169 | %% Should default to being on |
| 170 | %% todayMarker on |
| 171 | section Section1 |
| 172 | Yesterday: 1010-10-09, 1d |
| 173 | Today: 1010-10-10, 1d |
| 174 | `, |
| 175 | {} |
| 176 | ); |
| 177 | }); |
| 178 | |
| 179 | it('should hide today marker', () => { |
| 180 | imgSnapshotTest( |
| 181 | ` |
| 182 | gantt |
| 183 | title Hide today marker (vertical line should not be visible) |
| 184 | dateFormat YYYY-MM-DD |
| 185 | axisFormat %d |
| 186 | todayMarker off |
| 187 | section Section1 |
| 188 | Yesterday: 1010-10-09, 1d |
| 189 | Today: 1010-10-10, 1d |
| 190 | `, |
| 191 | {} |
| 192 | ); |
| 193 | }); |
| 194 | |
| 195 | it('should style today marker', () => { |
| 196 | imgSnapshotTest( |
| 197 | ` |
| 198 | gantt |
| 199 | title Style today marker (vertical line should be 5px wide and half-transparent blue) |
| 200 | dateFormat YYYY-MM-DD |
| 201 | axisFormat %d |
| 202 | todayMarker stroke-width:5px,stroke:#00f,opacity:0.5 |
| 203 | section Section1 |
| 204 | Yesterday: 1010-10-09, 1d |
| 205 | Today: 1010-10-10, 1d |
| 206 | `, |
| 207 | {} |
| 208 | ); |
| 209 | }); |
| 210 | |
| 211 | it('should handle milliseconds', () => { |
| 212 | imgSnapshotTest( |
| 213 | ` |
| 214 | gantt |
| 215 | title A Gantt Diagram |
| 216 | dateFormat x |
| 217 | axisFormat %L |
| 218 | section Section |
| 219 | A task :a1, 0, 30ms |
| 220 | Another task :after a1, 20ms |
| 221 | section Another |
| 222 | Another another task :b1, 20, 12ms |
| 223 | Another another another task :after b1, 0.024s |
| 224 | `, |
| 225 | {} |
| 226 | ); |
| 227 | }); |
| 228 | |
| 229 | it('should render a gantt diagram when useMaxWidth is true (default)', () => { |
| 230 | renderGraph( |
| 231 | ` |
| 232 | gantt |
| 233 | dateFormat YYYY-MM-DD |
| 234 | axisFormat %d/%m |
| 235 | title Adding GANTT diagram to mermaid |
| 236 | excludes weekdays 2014-01-10 |
| 237 | |
| 238 | section A section |
| 239 | Completed task :done, des1, 2014-01-06,2014-01-08 |
| 240 | Active task :active, des2, 2014-01-09, 3d |
| 241 | Future task : des3, after des2, 5d |
| 242 | Future task2 : des4, after des3, 5d |
| 243 | |
| 244 | section Critical tasks |
| 245 | Completed task in the critical line :crit, done, 2014-01-06,24h |
| 246 | Implement parser and jison :crit, done, after des1, 2d |
| 247 | Create tests for parser :crit, active, 3d |
| 248 | Future task in critical line :crit, 5d |
| 249 | Create tests for renderer :2d |
| 250 | Add to mermaid :1d |
| 251 | |
| 252 | section Documentation |
| 253 | Describe gantt syntax :active, a1, after des1, 3d |
| 254 | Add gantt diagram to demo page :after a1 , 20h |
| 255 | Add another diagram to demo page :doc1, after a1 , 48h |
| 256 | |
| 257 | section Last section |
| 258 | Describe gantt syntax :after doc1, 3d |
| 259 | Add gantt diagram to demo page : 20h |
| 260 | Add another diagram to demo page : 48h |
| 261 | `, |
| 262 | { gantt: { useMaxWidth: true } } |
| 263 | ); |
| 264 | cy.get('svg').should((svg) => { |
| 265 | expect(svg).to.have.attr('width', '100%'); |
| 266 | // expect(svg).to.have.attr('height'); |
| 267 | // use within because the absolute value can be slightly different depending on the environment ±5% |
| 268 | // const height = parseFloat(svg.attr('height')); |
| 269 | // expect(height).to.be.within(484 * 0.95, 484 * 1.05); |
| 270 | const style = svg.attr('style'); |
| 271 | expect(style).to.match(/^max-width: [\d.]+px;$/); |
| 272 | const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); |
| 273 | expect(maxWidthValue).to.be.within( |
| 274 | Cypress.config().viewportWidth * 0.95, |
| 275 | Cypress.config().viewportWidth * 1.05 |
| 276 | ); |
| 277 | }); |
| 278 | }); |
| 279 | |
| 280 | it('should render a gantt diagram when useMaxWidth is false', () => { |
| 281 | renderGraph( |
| 282 | ` |
| 283 | gantt |
| 284 | dateFormat YYYY-MM-DD |
| 285 | axisFormat %d/%m |
| 286 | title Adding GANTT diagram to mermaid |
| 287 | excludes weekdays 2014-01-10 |
| 288 | |
| 289 | section A section |
| 290 | Completed task :done, des1, 2014-01-06,2014-01-08 |
| 291 | Active task :active, des2, 2014-01-09, 3d |
| 292 | Future task : des3, after des2, 5d |
| 293 | Future task2 : des4, after des3, 5d |
| 294 | |
| 295 | section Critical tasks |
| 296 | Completed task in the critical line :crit, done, 2014-01-06,24h |
| 297 | Implement parser and jison :crit, done, after des1, 2d |
| 298 | Create tests for parser :crit, active, 3d |
| 299 | Future task in critical line :crit, 5d |
| 300 | Create tests for renderer :2d |
| 301 | Add to mermaid :1d |
| 302 | |
| 303 | section Documentation |
| 304 | Describe gantt syntax :active, a1, after des1, 3d |
| 305 | Add gantt diagram to demo page :after a1 , 20h |
| 306 | Add another diagram to demo page :doc1, after a1 , 48h |
| 307 | |
| 308 | section Last section |
| 309 | Describe gantt syntax :after doc1, 3d |
| 310 | Add gantt diagram to demo page : 20h |
| 311 | Add another diagram to demo page : 48h |
| 312 | `, |
| 313 | { gantt: { useMaxWidth: false } } |
| 314 | ); |
| 315 | cy.get('svg').should((svg) => { |
| 316 | const width = parseFloat(svg.attr('width')); |
| 317 | expect(width).to.be.within( |
| 318 | Cypress.config().viewportWidth * 0.95, |
| 319 | Cypress.config().viewportWidth * 1.05 |
| 320 | ); |
| 321 | expect(svg).to.not.have.attr('style'); |
| 322 | }); |
| 323 | }); |
| 324 | it('should render a gantt diagram with data labels at the top when topAxis is true', () => { |
| 325 | imgSnapshotTest( |
| 326 | ` |
| 327 | gantt |
| 328 | dateFormat YYYY-MM-DD |
| 329 | axisFormat %d/%m |
| 330 | title Adding GANTT diagram to mermaid |
| 331 | excludes weekdays 2014-01-10 |
| 332 | |
| 333 | section A section |
| 334 | Completed task :done, des1, 2014-01-06,2014-01-08 |
| 335 | Active task :active, des2, 2014-01-09, 3d |
| 336 | Future task : des3, after des2, 5d |
| 337 | Future task2 : des4, after des3, 5d |
| 338 | |
| 339 | section Critical tasks |
| 340 | Completed task in the critical line :crit, done, 2014-01-06,24h |
| 341 | Implement parser and jison :crit, done, after des1, 2d |
| 342 | Create tests for parser :crit, active, 3d |
| 343 | Future task in critical line :crit, 5d |
| 344 | Create tests for renderer :2d |
| 345 | Add to mermaid :1d |
| 346 | |
| 347 | section Documentation |
| 348 | Describe gantt syntax :active, a1, after des1, 3d |
| 349 | Add gantt diagram to demo page :after a1 , 20h |
| 350 | Add another diagram to demo page :doc1, after a1 , 48h |
| 351 | |
| 352 | section Last section |
| 353 | Describe gantt syntax :after doc1, 3d |
| 354 | Add gantt diagram to demo page : 20h |
| 355 | Add another diagram to demo page : 48h |
| 356 | `, |
| 357 | { gantt: { topAxis: true } } |
| 358 | ); |
| 359 | }); |
| 360 | |
| 361 | it('should render a gantt diagram with a vert tag', () => { |
| 362 | imgSnapshotTest( |
| 363 | ` |
| 364 | gantt |
| 365 | title A Gantt Diagram |
| 366 | dateFormat ss |
| 367 | axisFormat %Ss |
| 368 | |
| 369 | section Section |
| 370 | A task : a1, 00, 6s |
| 371 | Milestone : vert, 01, |
| 372 | section Another |
| 373 | Task in sec : 06, 3s |
| 374 | another task : 3s |
| 375 | ` |
| 376 | ); |
| 377 | }); |
| 378 | it('should render a gantt diagram with tick is 2 milliseconds', () => { |
| 379 | imgSnapshotTest( |
| 380 | ` |
| 381 | gantt |
| 382 | title A Gantt Diagram |
| 383 | dateFormat SSS |
| 384 | axisFormat %Lms |
| 385 | tickInterval 2millisecond |
| 386 | excludes weekends |
| 387 | |
| 388 | section Section |
| 389 | A task : a1, 000, 6ms |
| 390 | Another task : after a1, 6ms |
| 391 | section Another |
| 392 | Task in sec : a2, 006, 3ms |
| 393 | another task : 3ms |
| 394 | `, |
| 395 | {} |
| 396 | ); |
| 397 | }); |
| 398 | |
| 399 | it('should render a gantt diagram with tick is 2 seconds', () => { |
| 400 | imgSnapshotTest( |
| 401 | ` |
| 402 | gantt |
| 403 | title A Gantt Diagram |
| 404 | dateFormat ss |
| 405 | axisFormat %Ss |
| 406 | tickInterval 2second |
| 407 | excludes weekends |
| 408 | |
| 409 | section Section |
| 410 | A task : a1, 00, 6s |
| 411 | Another task : after a1, 6s |
| 412 | section Another |
| 413 | Task in sec : 06, 3s |
| 414 | another task : 3s |
| 415 | `, |
| 416 | {} |
| 417 | ); |
| 418 | }); |
| 419 | |
| 420 | it('should render a gantt diagram with tick is 15 minutes', () => { |
| 421 | imgSnapshotTest( |
| 422 | ` |
| 423 | gantt |
| 424 | title A Gantt Diagram |
| 425 | dateFormat YYYY-MM-DD |
| 426 | axisFormat %H:%M |
| 427 | tickInterval 15minute |
| 428 | excludes weekends |
| 429 | |
| 430 | section Section |
| 431 | A task : a1, 2022-10-03, 6h |
| 432 | Another task : after a1, 6h |
| 433 | section Another |
| 434 | Task in sec : 2022-10-03, 3h |
| 435 | another task : 3h |
| 436 | `, |
| 437 | {} |
| 438 | ); |
| 439 | }); |
| 440 | |
| 441 | it('should render a gantt diagram with tick is 6 hours', () => { |
| 442 | imgSnapshotTest( |
| 443 | ` |
| 444 | gantt |
| 445 | title A Gantt Diagram |
| 446 | dateFormat YYYY-MM-DD |
| 447 | axisFormat %d %H:%M |
| 448 | tickInterval 6hour |
| 449 | excludes weekends |
| 450 | |
| 451 | section Section |
| 452 | A task : a1, 2022-10-03, 1d |
| 453 | Another task : after a1, 2d |
| 454 | section Another |
| 455 | Task in sec : 2022-10-04, 2d |
| 456 | another task : 2d |
| 457 | `, |
| 458 | {} |
| 459 | ); |
| 460 | }); |
| 461 | |
| 462 | it('should render a gantt diagram with tick is 1 day', () => { |
| 463 | imgSnapshotTest( |
| 464 | ` |
| 465 | gantt |
| 466 | title A Gantt Diagram |
| 467 | dateFormat YYYY-MM-DD |
| 468 | axisFormat %m-%d |
| 469 | tickInterval 1day |
| 470 | excludes weekends |
| 471 | |
| 472 | section Section |
| 473 | A task : a1, 2022-10-01, 30d |
| 474 | Another task : after a1, 20d |
| 475 | section Another |
| 476 | Task in sec : 2022-10-20, 12d |
| 477 | another task : 24d |
| 478 | `, |
| 479 | {} |
| 480 | ); |
| 481 | }); |
| 482 | |
| 483 | it('should render a gantt diagram with tick is 1 week', () => { |
| 484 | imgSnapshotTest( |
| 485 | ` |
| 486 | gantt |
| 487 | title A Gantt Diagram |
| 488 | dateFormat YYYY-MM-DD |
| 489 | axisFormat %m-%d |
| 490 | tickInterval 1week |
| 491 | excludes weekends |
| 492 | |
| 493 | section Section |
| 494 | A task : a1, 2022-10-01, 30d |
| 495 | Another task : after a1, 20d |
| 496 | section Another |
| 497 | Task in sec : 2022-10-20, 12d |
| 498 | another task : 24d |
| 499 | `, |
| 500 | {} |
| 501 | ); |
| 502 | }); |
| 503 | |
| 504 | it('should render a gantt diagram with tick is 1 week, with the day starting on monday', () => { |
| 505 | imgSnapshotTest( |
| 506 | ` |
| 507 | gantt |
| 508 | title A Gantt Diagram |
| 509 | dateFormat YYYY-MM-DD |
| 510 | axisFormat %m-%d |
| 511 | tickInterval 1week |
| 512 | weekday monday |
| 513 | excludes weekends |
| 514 | |
| 515 | section Section |
| 516 | A task : a1, 2022-10-01, 30d |
| 517 | Another task : after a1, 20d |
| 518 | section Another |
| 519 | Task in sec : 2022-10-20, 12d |
| 520 | another task : 24d |
| 521 | `, |
| 522 | {} |
| 523 | ); |
| 524 | }); |
| 525 | |
| 526 | it('should render a gantt diagram with tick is 1 month', () => { |
| 527 | imgSnapshotTest( |
| 528 | ` |
| 529 | gantt |
| 530 | title A Gantt Diagram |
| 531 | dateFormat YYYY-MM-DD |
| 532 | axisFormat %m-%d |
| 533 | tickInterval 1month |
| 534 | excludes weekends |
| 535 | |
| 536 | section Section |
| 537 | A task : a1, 2022-10-01, 30d |
| 538 | Another task : after a1, 20d |
| 539 | section Another |
| 540 | Task in sec : 2022-10-20, 12d |
| 541 | another task : 24d |
| 542 | `, |
| 543 | {} |
| 544 | ); |
| 545 | }); |
| 546 | |
| 547 | it('should render a gantt diagram with tick is 1 day and topAxis is true', () => { |
| 548 | imgSnapshotTest( |
| 549 | ` |
| 550 | gantt |
| 551 | title A Gantt Diagram |
| 552 | dateFormat YYYY-MM-DD |
| 553 | axisFormat %m-%d |
| 554 | tickInterval 1day |
| 555 | excludes weekends |
| 556 | |
| 557 | section Section |
| 558 | A task : a1, 2022-10-01, 30d |
| 559 | Another task : after a1, 20d |
| 560 | section Another |
| 561 | Task in sec : 2022-10-20, 12d |
| 562 | another task : 24d |
| 563 | `, |
| 564 | { gantt: { topAxis: true } } |
| 565 | ); |
| 566 | }); |
| 567 | |
| 568 | it('should render only the day when using dateFormat D', () => { |
| 569 | imgSnapshotTest( |
| 570 | ` |
| 571 | gantt |
| 572 | title Test |
| 573 | dateFormat D |
| 574 | A :a, 1, 1d |
| 575 | `, |
| 576 | {} |
| 577 | ); |
| 578 | }); |
| 579 | |
| 580 | // TODO: fix it |
| 581 | // |
| 582 | // This test is skipped deliberately |
| 583 | // because it fails and blocks our development pipeline |
| 584 | // It was added as an attempt to fix gantt performance issues |
| 585 | // |
| 586 | // https://github.com/mermaid-js/mermaid/issues/3274 |
| 587 | // |
| 588 | it.skip('should render a gantt diagram with very large intervals, skipping excludes if interval > 5 years', () => { |
| 589 | imgSnapshotTest( |
| 590 | `gantt |
| 591 | title A long Gantt Diagram |
| 592 | dateFormat YYYY-MM-DD |
| 593 | axisFormat %m-%d |
| 594 | tickInterval 1day |
| 595 | excludes weekends |
| 596 | section Section |
| 597 | A task : a1, 9999-10-01, 30d |
| 598 | Another task : after a1, 20d |
| 599 | section Another |
| 600 | Task in sec : 2022-10-20, 12d |
| 601 | another task : 24d |
| 602 | ` |
| 603 | ); |
| 604 | }); |
| 605 | it('should render a gantt diagram excluding friday and saturday', () => { |
| 606 | imgSnapshotTest( |
| 607 | `gantt |
| 608 | title A Gantt Diagram |
| 609 | dateFormat YYYY-MM-DD |
| 610 | excludes weekends |
| 611 | weekend friday |
| 612 | section Section1 |
| 613 | A task :a1, 2024-02-28, 10d` |
| 614 | ); |
| 615 | }); |
| 616 | it('should render a gantt diagram excluding saturday and sunday', () => { |
| 617 | imgSnapshotTest( |
| 618 | `gantt |
| 619 | title A Gantt Diagram |
| 620 | dateFormat YYYY-MM-DD |
| 621 | excludes weekends |
| 622 | weekend saturday |
| 623 | section Section1 |
| 624 | A task :a1, 2024-02-28, 10d` |
| 625 | ); |
| 626 | }); |
| 627 | it('should render when compact is true', () => { |
| 628 | imgSnapshotTest( |
| 629 | ` |
| 630 | --- |
| 631 | displayMode: compact |
| 632 | --- |
| 633 | gantt |
| 634 | title GANTT compact |
| 635 | dateFormat HH:mm:ss |
| 636 | axisFormat %Hh%M |
| 637 | |
| 638 | section DB Clean |
| 639 | Clean: 12:00:00, 10m |
| 640 | Clean: 12:30:00, 12m |
| 641 | Clean: 13:00:00, 8m |
| 642 | Clean: 13:30:00, 9m |
| 643 | Clean: 14:00:00, 13m |
| 644 | Clean: 14:30:00, 10m |
| 645 | Clean: 15:00:00, 11m |
| 646 | |
| 647 | section Sessions |
| 648 | A: 12:00:00, 63m |
| 649 | B: 12:30:00, 12m |
| 650 | C: 13:05:00, 12m |
| 651 | D: 13:06:00, 33m |
| 652 | E: 13:15:00, 55m |
| 653 | F: 13:20:00, 12m |
| 654 | G: 13:32:00, 18m |
| 655 | H: 13:50:00, 20m |
| 656 | I: 14:10:00, 10m |
| 657 | `, |
| 658 | {} |
| 659 | ); |
| 660 | }); |
| 661 | |
| 662 | it('should render a gantt diagram excluding a specific date in YYYY-MM-DD HH:mm:ss format', () => { |
| 663 | imgSnapshotTest( |
| 664 | ` |
| 665 | gantt |
| 666 | dateFormat YYYY-MM-DD HH:mm:ss |
| 667 | excludes 2025-07-07 |
| 668 | section Section |
| 669 | A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30 |
| 670 | Another task:after a1, 20h |
| 671 | `, |
| 672 | {} |
| 673 | ); |
| 674 | }); |
| 675 | |
| 676 | it('should render a gantt diagram excluding saturday and sunday in YYYY-MM-DD HH:mm:ss format', () => { |
| 677 | imgSnapshotTest( |
| 678 | ` |
| 679 | gantt |
| 680 | dateFormat YYYY-MM-DD HH:mm:ss |
| 681 | excludes weekends |
| 682 | weekend saturday |
| 683 | section Section |
| 684 | A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30 |
| 685 | Another task:after a1, 20h |
| 686 | `, |
| 687 | {} |
| 688 | ); |
| 689 | }); |
| 690 | it('should render a gantt diagram excluding friday and saturday in YYYY-MM-DD HH:mm:ss format', () => { |
| 691 | imgSnapshotTest( |
| 692 | ` |
| 693 | gantt |
| 694 | dateFormat YYYY-MM-DD HH:mm:ss |
| 695 | excludes weekends |
| 696 | weekend friday |
| 697 | section Section |
| 698 | A task :a1, 2025-07-04 20:30:30, 2025-07-08 10:30:30 |
| 699 | Another task:after a1, 20h |
| 700 | `, |
| 701 | {} |
| 702 | ); |
| 703 | }); |
| 704 | |
| 705 | it("should render when there's a semicolon in the title", () => { |
| 706 | imgSnapshotTest( |
| 707 | ` |
| 708 | gantt |
| 709 | title ;Gantt With a Semicolon in the Title |
| 710 | dateFormat YYYY-MM-DD |
| 711 | section Section |
| 712 | A task :a1, 2014-01-01, 30d |
| 713 | Another task :after a1 , 20d |
| 714 | section Another |
| 715 | Task in sec :2014-01-12 , 12d |
| 716 | another task : 24d |
| 717 | `, |
| 718 | {} |
| 719 | ); |
| 720 | }); |
| 721 | |
| 722 | it("should render when there's a semicolon in a section is true", () => { |
| 723 | imgSnapshotTest( |
| 724 | ` |
| 725 | gantt |
| 726 | title Gantt Digram |
| 727 | dateFormat YYYY-MM-DD |
| 728 | section ;Section With a Semicolon |
| 729 | A task :a1, 2014-01-01, 30d |
| 730 | Another task :after a1 , 20d |
| 731 | section Another |
| 732 | Task in sec :2014-01-12 , 12d |
| 733 | another task : 24d |
| 734 | `, |
| 735 | {} |
| 736 | ); |
| 737 | }); |
| 738 | |
| 739 | it("should render when there's a semicolon in the task data", () => { |
| 740 | imgSnapshotTest( |
| 741 | ` |
| 742 | gantt |
| 743 | title Gantt Digram |
| 744 | dateFormat YYYY-MM-DD |
| 745 | section Section |
| 746 | ;A task with a semicolon :a1, 2014-01-01, 30d |
| 747 | Another task :after a1 , 20d |
| 748 | section Another |
| 749 | Task in sec :2014-01-12 , 12d |
| 750 | another task : 24d |
| 751 | `, |
| 752 | {} |
| 753 | ); |
| 754 | }); |
| 755 | |
| 756 | it("should render when there's a hashtag in the title", () => { |
| 757 | imgSnapshotTest( |
| 758 | ` |
| 759 | gantt |
| 760 | title #Gantt With a Hashtag in the Title |
| 761 | dateFormat YYYY-MM-DD |
| 762 | section Section |
| 763 | A task :a1, 2014-01-01, 30d |
| 764 | Another task :after a1 , 20d |
| 765 | section Another |
| 766 | Task in sec :2014-01-12 , 12d |
| 767 | another task : 24d |
| 768 | `, |
| 769 | {} |
| 770 | ); |
| 771 | }); |
| 772 | |
| 773 | it("should render when there's a hashtag in a section is true", () => { |
| 774 | imgSnapshotTest( |
| 775 | ` |
| 776 | gantt |
| 777 | title Gantt Digram |
| 778 | dateFormat YYYY-MM-DD |
| 779 | section #Section With a Hashtag |
| 780 | A task :a1, 2014-01-01, 30d |
| 781 | Another task :after a1 , 20d |
| 782 | section Another |
| 783 | Task in sec :2014-01-12 , 12d |
| 784 | another task : 24d |
| 785 | `, |
| 786 | {} |
| 787 | ); |
| 788 | }); |
| 789 | |
| 790 | it("should render when there's a hashtag in the task data", () => { |
| 791 | imgSnapshotTest( |
| 792 | ` |
| 793 | gantt |
| 794 | title Gantt Digram |
| 795 | dateFormat YYYY-MM-DD |
| 796 | section Section |
| 797 | #A task with a hashtag :a1, 2014-01-01, 30d |
| 798 | Another task :after a1 , 20d |
| 799 | section Another |
| 800 | Task in sec :2014-01-12 , 12d |
| 801 | another task : 24d |
| 802 | `, |
| 803 | {} |
| 804 | ); |
| 805 | }); |
| 806 | it('should handle numeric timestamps with dateFormat x', () => { |
| 807 | imgSnapshotTest( |
| 808 | ` |
| 809 | gantt |
| 810 | title Process time profile (ms) |
| 811 | dateFormat x |
| 812 | axisFormat %L |
| 813 | tickInterval 250millisecond |
| 814 | |
| 815 | section Pipeline |
| 816 | Parse JSON p1: 000, 120 |
| 817 | `, |
| 818 | {} |
| 819 | ); |
| 820 | }); |
| 821 | it('should handle numeric timestamps with dateFormat X', () => { |
| 822 | imgSnapshotTest( |
| 823 | ` |
| 824 | gantt |
| 825 | title Process time profile (ms) |
| 826 | dateFormat X |
| 827 | axisFormat %L |
| 828 | tickInterval 250millisecond |
| 829 | |
| 830 | section Pipeline |
| 831 | Parse JSON p1: 000, 120 |
| 832 | `, |
| 833 | {} |
| 834 | ); |
| 835 | }); |
| 836 | it('should handle seconds-only format with tickInterval (issue #5496)', () => { |
| 837 | imgSnapshotTest( |
| 838 | ` |
| 839 | gantt |
| 840 | tickInterval 1second |
| 841 | dateFormat ss |
| 842 | axisFormat %s |
| 843 | |
| 844 | section Network Request |
| 845 | RTT : rtt, 0, 20 |
| 846 | `, |
| 847 | {} |
| 848 | ); |
| 849 | }); |
| 850 | it('should handle dates with year typo like 202 instead of 2024 (issue #5496)', () => { |
| 851 | imgSnapshotTest( |
| 852 | ` |
| 853 | gantt |
| 854 | title Schedule |
| 855 | dateFormat YYYY-MM-DD |
| 856 | tickInterval 1week |
| 857 | axisFormat %m-%d |
| 858 | |
| 859 | section Vacation |
| 860 | London : 2024-12-01, 7d |
| 861 | London : 202-12-01, 7d |
| 862 | `, |
| 863 | {} |
| 864 | ); |
| 865 | }); |
| 866 | }); |
| 867 | |