|
478 | 478 |
|
479 | 479 | expect(page.find(".op-meeting-agenda-item--presenter")).to have_text(user.name)
|
480 | 480 | end
|
| 481 | + |
| 482 | + context "when testing section selection behaviour" do |
| 483 | + shared_let(:meeting_without_sections) { create(:meeting, project:, start_time: 1.hour.from_now) } |
| 484 | + shared_let(:meeting_with_sections) do |
| 485 | + create(:meeting, project:, start_time: 2.hours.from_now).tap do |meeting| |
| 486 | + create(:meeting_section, meeting:, title: "Section 1") |
| 487 | + create(:meeting_section, meeting:, title: "Section 2") |
| 488 | + end |
| 489 | + end |
| 490 | + shared_let(:recurring_meeting) do |
| 491 | + create(:recurring_meeting, project:) |
| 492 | + end |
| 493 | + shared_let(:empty_recurring_meeting_occurrence) do |
| 494 | + create(:meeting, |
| 495 | + project:, |
| 496 | + recurring_meeting:, |
| 497 | + start_time: 3.hours.from_now) |
| 498 | + end |
| 499 | + shared_let(:recurring_meeting_occurrence) do |
| 500 | + create(:meeting, |
| 501 | + project:, |
| 502 | + recurring_meeting:, |
| 503 | + start_time: 4.hours.from_now).tap do |meeting| |
| 504 | + create(:meeting_section, meeting:, title: "Section 1") |
| 505 | + create(:meeting_section, meeting:, title: "Section 2") |
| 506 | + end |
| 507 | + end |
| 508 | + |
| 509 | + it "automatically selects the backlog for one-time meetings without sections" do |
| 510 | + check_section_auto_selection(meeting_without_sections, "Agenda backlog") |
| 511 | + end |
| 512 | + |
| 513 | + it "automatically selects the backlog for one-time meetings with sections" do |
| 514 | + check_section_auto_selection(meeting_with_sections, "Agenda backlog") |
| 515 | + end |
| 516 | + |
| 517 | + it "automatically selects the last section for recurring meeting occurrences" do |
| 518 | + last_section = recurring_meeting_occurrence.sections.last.title |
| 519 | + check_section_auto_selection(recurring_meeting_occurrence, last_section) |
| 520 | + end |
| 521 | + |
| 522 | + it "shows no preselection when no sections exist for recurring meeting occurrences" do |
| 523 | + check_section_auto_selection(empty_recurring_meeting_occurrence, "") |
| 524 | + end |
| 525 | + |
| 526 | + it "updates section selection when switching between meetings" do |
| 527 | + work_package_page.visit! |
| 528 | + switch_to_meetings_tab |
| 529 | + |
| 530 | + meetings_tab.open_add_to_meeting_dialog |
| 531 | + |
| 532 | + retry_block do |
| 533 | + fill_in("meeting_agenda_item_meeting_id", with: recurring_meeting_occurrence.title) |
| 534 | + page.find(".ng-option-marked", text: recurring_meeting_occurrence.title) |
| 535 | + page.find(".ng-option-marked").click |
| 536 | + |
| 537 | + wait_for_network_idle |
| 538 | + |
| 539 | + last_section = recurring_meeting_occurrence.sections.last |
| 540 | + expect(page).to have_content(last_section.title) |
| 541 | + |
| 542 | + fill_in("meeting_agenda_item_meeting_id", with: meeting_without_sections.title) |
| 543 | + page.find(".ng-option-marked", text: meeting_without_sections.title) |
| 544 | + page.find(".ng-option-marked").click |
| 545 | + |
| 546 | + wait_for_network_idle |
| 547 | + |
| 548 | + expect(page).to have_content("Agenda backlog") |
| 549 | + end |
| 550 | + end |
| 551 | + |
| 552 | + it "shows section autocompleter as disabled when no meeting is selected" do |
| 553 | + work_package_page.visit! |
| 554 | + switch_to_meetings_tab |
| 555 | + |
| 556 | + meetings_tab.open_add_to_meeting_dialog |
| 557 | + |
| 558 | + page.find_field("meeting_agenda_item_meeting_section_id", disabled: true, visible: false) |
| 559 | + expect(page).to have_content("Meeting selection is required first") |
| 560 | + end |
| 561 | + end |
481 | 562 | end
|
482 | 563 | end
|
483 | 564 |
|
|
513 | 594 | it_behaves_like "with a meetings tab"
|
514 | 595 | end
|
515 | 596 |
|
| 597 | + private |
| 598 | + |
516 | 599 | def switch_to_meetings_tab
|
517 | 600 | work_package_page.switch_to_tab(tab: "meetings")
|
518 | 601 | meetings_tab.expect_tab_content_rendered # wait for the tab to be rendered
|
519 | 602 | end
|
| 603 | + |
| 604 | + def check_section_auto_selection(meeting, expected_section) |
| 605 | + work_package_page.visit! |
| 606 | + switch_to_meetings_tab |
| 607 | + |
| 608 | + meetings_tab.open_add_to_meeting_dialog |
| 609 | + |
| 610 | + fill_in("meeting_agenda_item_meeting_id", with: meeting.title) |
| 611 | + page.find(".ng-option-marked", text: meeting.title) |
| 612 | + page.find(".ng-option-marked").click |
| 613 | + |
| 614 | + wait_for_network_idle |
| 615 | + |
| 616 | + section_field = find_field("meeting_agenda_item_meeting_section_id") |
| 617 | + expect(section_field).not_to be_disabled |
| 618 | + |
| 619 | + expect(page).to have_css(".ng-value-label", text: expected_section) |
| 620 | + end |
520 | 621 | end
|
0 commit comments