|
93 | 93 |
|
94 | 94 | click_on 'New Partner Agency' |
95 | 95 |
|
96 | | - fill_in 'Name *', with: partner_attributes[:name] |
| 96 | + fill_in 'Name', with: partner_attributes[:name] |
97 | 97 | fill_in 'E-mail *', with: partner_attributes[:email] |
98 | 98 | fill_in 'Quota', with: partner_attributes[:quota] |
99 | 99 | fill_in 'Notes', with: partner_attributes[:notes] |
|
125 | 125 | assert page.has_content? "Partner Agencies for #{organization.name}" |
126 | 126 | click_on 'New Partner Agency' |
127 | 127 |
|
128 | | - fill_in 'Name *', with: partner_attributes[:name] |
| 128 | + fill_in 'Name', with: partner_attributes[:name] |
129 | 129 |
|
130 | 130 | find('button', text: 'Add Partner Agency').click |
131 | 131 | end |
|
384 | 384 | expect(partner.name).to eq(name) |
385 | 385 | end |
386 | 386 |
|
387 | | - it "prevents a user from updating a partner with empty name" do |
388 | | - visit subject |
389 | | - fill_in "Name", with: "" |
390 | | - click_button "Update Partner" |
391 | | - |
392 | | - expect(page.find(".alert")).to have_content "Something didn't work quite right -- try again?" |
393 | | - end |
394 | | - |
395 | 387 | it "User can uncheck send_reminders" do |
396 | 388 | visit subject |
397 | 389 | uncheck 'send_reminders' |
|
458 | 450 |
|
459 | 451 | describe "#edit_profile" do |
460 | 452 | let!(:partner) { create(:partner, name: "Frank") } |
461 | | - subject { edit_profile_path(partner.id) } |
462 | 453 |
|
463 | 454 | context "when step-wise editing is enabled" do |
464 | 455 | before do |
465 | 456 | Flipper.enable(:partner_step_form) |
466 | | - visit subject |
| 457 | + visit edit_profile_path(partner.id) |
467 | 458 | end |
468 | 459 |
|
469 | 460 | it "displays all sections in a closed state by default" do |
|
554 | 545 | expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true) |
555 | 546 | expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true) |
556 | 547 | end |
| 548 | + |
| 549 | + context "Mandatory fields validation" do |
| 550 | + subject { all("input[type='submit'][value='Save Progress']").last.click } |
| 551 | + |
| 552 | + before do |
| 553 | + find("button[data-bs-target='#agency_information']").click |
| 554 | + within "#agency_information" do |
| 555 | + fill_in "Agency Name", with: "Agency1" |
| 556 | + select "Basic Needs Bank", from: "Agency Type" |
| 557 | + fill_in "Address (line 1)", with: "123 Main St" |
| 558 | + fill_in "City", with: "Metropolis" |
| 559 | + fill_in "State", with: "CA" |
| 560 | + fill_in "Zip Code", with: "90210" |
| 561 | + end |
| 562 | + find("button[data-bs-target='#agency_stability']").click |
| 563 | + within "#agency_stability" do |
| 564 | + fill_in "Program Name(s)", with: "Program 1" |
| 565 | + fill_in "Program Description(s)", with: "Really great program" |
| 566 | + end |
| 567 | + end |
| 568 | + |
| 569 | + context "No social media filled" do |
| 570 | + before do |
| 571 | + find("button[data-bs-target='#media_information']").click |
| 572 | + within "#media_information" do |
| 573 | + fill_in "Website", with: "" |
| 574 | + uncheck "No Social Media Presence" |
| 575 | + end |
| 576 | + end |
| 577 | + |
| 578 | + context "partner status is invited" do |
| 579 | + before do |
| 580 | + partner.invited! |
| 581 | + end |
| 582 | + |
| 583 | + it "displays success message" do |
| 584 | + expect { |
| 585 | + subject |
| 586 | + }.to change { partner.reload.updated_at } |
| 587 | + |
| 588 | + expect(page).to have_content("Details were successfully updated.") |
| 589 | + end |
| 590 | + end |
| 591 | + |
| 592 | + context "partner status is awaiting_review" do |
| 593 | + before do |
| 594 | + partner.awaiting_review! |
| 595 | + end |
| 596 | + |
| 597 | + it "displays validation errors" do |
| 598 | + expect { |
| 599 | + subject |
| 600 | + }.not_to change { partner.reload.updated_at } |
| 601 | + expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.") |
| 602 | + end |
| 603 | + end |
| 604 | + |
| 605 | + context "partner status is approved" do |
| 606 | + before do |
| 607 | + partner.approved! |
| 608 | + end |
| 609 | + |
| 610 | + it "displays validation errors" do |
| 611 | + expect { |
| 612 | + subject |
| 613 | + }.not_to change { partner.reload.updated_at } |
| 614 | + |
| 615 | + expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.") |
| 616 | + end |
| 617 | + |
| 618 | + context "partner's organization one_step_partner_invite is true" do |
| 619 | + before do |
| 620 | + partner.organization.update!(one_step_partner_invite: true) |
| 621 | + end |
| 622 | + |
| 623 | + it "displays success message" do |
| 624 | + expect { |
| 625 | + subject |
| 626 | + }.to change { partner.reload.updated_at } |
| 627 | + |
| 628 | + expect(page).to have_content("Details were successfully updated.") |
| 629 | + end |
| 630 | + end |
| 631 | + end |
| 632 | + end |
| 633 | + |
| 634 | + context "Mandatory fields empty" do |
| 635 | + before do |
| 636 | + # find("button[data-bs-target='#agency_information']").click |
| 637 | + within "#agency_information" do |
| 638 | + fill_in "Agency Name", with: "" |
| 639 | + select "", from: "Agency Type" |
| 640 | + fill_in "Address (line 1)", with: "" |
| 641 | + fill_in "City", with: "" |
| 642 | + fill_in "State", with: "" |
| 643 | + fill_in "Zip Code", with: "" |
| 644 | + end |
| 645 | + # find("button[data-bs-target='#agency_stability']").click |
| 646 | + within "#agency_stability" do |
| 647 | + fill_in "Program Name(s)", with: "" |
| 648 | + fill_in "Program Description(s)", with: "" |
| 649 | + end |
| 650 | + end |
| 651 | + context "partner status is invited" do |
| 652 | + before do |
| 653 | + partner.invited! |
| 654 | + end |
| 655 | + |
| 656 | + it "displays success message" do |
| 657 | + expect { |
| 658 | + subject |
| 659 | + }.to change { partner.reload.updated_at } |
| 660 | + |
| 661 | + expect(page).to have_content("Details were successfully updated.") |
| 662 | + end |
| 663 | + end |
| 664 | + |
| 665 | + context "partner status is awaiting_review" do |
| 666 | + before do |
| 667 | + partner.awaiting_review! |
| 668 | + end |
| 669 | + |
| 670 | + it "displays validation errors" do |
| 671 | + expect { |
| 672 | + subject |
| 673 | + }.not_to change { partner.reload.updated_at } |
| 674 | + expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description") |
| 675 | + end |
| 676 | + end |
| 677 | + |
| 678 | + context "partner status is approved" do |
| 679 | + before do |
| 680 | + partner.approved! |
| 681 | + end |
| 682 | + |
| 683 | + it "displays validation errors" do |
| 684 | + expect { |
| 685 | + subject |
| 686 | + }.not_to change { partner.reload.updated_at } |
| 687 | + |
| 688 | + expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description") |
| 689 | + end |
| 690 | + |
| 691 | + context "partner's organization one_step_partner_invite is true" do |
| 692 | + before do |
| 693 | + partner.organization.update!(one_step_partner_invite: true) |
| 694 | + end |
| 695 | + |
| 696 | + it "displays success message" do |
| 697 | + expect { |
| 698 | + subject |
| 699 | + }.to change { partner.reload.updated_at } |
| 700 | + |
| 701 | + expect(page).to have_content("Details were successfully updated.") |
| 702 | + end |
| 703 | + end |
| 704 | + end |
| 705 | + end |
| 706 | + end |
557 | 707 | end |
558 | 708 | end |
559 | 709 |
|
|
0 commit comments