|
380 | 380 | end
|
381 | 381 | end
|
382 | 382 |
|
| 383 | + describe "#edit_profile" do |
| 384 | + let!(:partner) { create(:partner, name: "Frank") } |
| 385 | + subject { edit_profile_path(partner.id) } |
| 386 | + |
| 387 | + context "when step-wise editing is enabled" do |
| 388 | + before do |
| 389 | + Flipper.enable(:partner_step_form) |
| 390 | + visit subject |
| 391 | + end |
| 392 | + |
| 393 | + it "displays all sections in a closed state by default" do |
| 394 | + within ".accordion" do |
| 395 | + expect(page).to have_css("#agency_information.accordion-collapse.collapse", visible: false) |
| 396 | + expect(page).to have_css("#program_delivery_address.accordion-collapse.collapse", visible: false) |
| 397 | + |
| 398 | + partner.partials_to_show.each do |partial| |
| 399 | + expect(page).to have_css("##{partial}.accordion-collapse.collapse", visible: false) |
| 400 | + end |
| 401 | + end |
| 402 | + end |
| 403 | + |
| 404 | + it "allows sections to be opened, closed, filled in any order, and reviewed" do |
| 405 | + # Media |
| 406 | + find("button[data-bs-target='#media_information']").click |
| 407 | + expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true) |
| 408 | + within "#media_information" do |
| 409 | + fill_in "Website", with: "https://www.example.com" |
| 410 | + end |
| 411 | + find("button[data-bs-target='#media_information']").click |
| 412 | + expect(page).to have_css("#media_information.accordion-collapse.collapse", visible: false) |
| 413 | + |
| 414 | + # Executive director |
| 415 | + find("button[data-bs-target='#executive_director']").click |
| 416 | + expect(page).to have_css("#executive_director.accordion-collapse.collapse.show", visible: true) |
| 417 | + within "#executive_director" do |
| 418 | + fill_in "Executive Director Name", with: "Lisa Smith" |
| 419 | + end |
| 420 | + |
| 421 | + # Save Progress |
| 422 | + all("input[type='submit'][value='Save Progress']").last.click |
| 423 | + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") |
| 424 | + |
| 425 | + # Save and Review |
| 426 | + all("input[type='submit'][value='Save and Review']").last.click |
| 427 | + expect(current_path).to eq(partner_path(partner.id)) |
| 428 | + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") |
| 429 | + end |
| 430 | + |
| 431 | + it "displays the edit view with sections containing validation errors expanded" do |
| 432 | + # Open up Media section and clear out website value |
| 433 | + find("button[data-bs-target='#media_information']").click |
| 434 | + within "#media_information" do |
| 435 | + fill_in "Website", with: "" |
| 436 | + end |
| 437 | + |
| 438 | + # Open Pick up person section and fill in 4 email addresses |
| 439 | + find("button[data-bs-target='#pick_up_person']").click |
| 440 | + within "#pick_up_person" do |
| 441 | + |
| 442 | + end |
| 443 | + |
| 444 | + # Open Partner Settings section and uncheck all options |
| 445 | + find("button[data-bs-target='#partner_settings']").click |
| 446 | + within "#partner_settings" do |
| 447 | + uncheck "Enable Quantity-based Requests" if has_checked_field?("Enable Quantity-based Requests") |
| 448 | + uncheck "Enable Child-based Requests (unclick if you only do bulk requests)" if has_checked_field?("Enable Child-based Requests (unclick if you only do bulk requests)") |
| 449 | + uncheck "Enable Requests for Individuals" if has_checked_field?("Enable Requests for Individuals") |
| 450 | + end |
| 451 | + |
| 452 | + # Save Progress |
| 453 | + all("input[type='submit'][value='Save Progress']").last.click |
| 454 | + |
| 455 | + # Expect an alert-danger message containing validation errors |
| 456 | + expect(page).to have_css(".alert-danger", text: /There is a problem/) |
| 457 | + expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.") |
| 458 | + expect(page).to have_content("Enable child based requests At least one request type must be set") |
| 459 | + expect(page).to have_content("Pick up email can't have more than three email addresses") |
| 460 | + |
| 461 | + # Expect media section, executive director section, and partner settings section to be opened |
| 462 | + expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true) |
| 463 | + expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true) |
| 464 | + expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true) |
| 465 | + |
| 466 | + # Try to Submit and Review from error state |
| 467 | + all("input[type='submit'][value='Save and Review']").last.click |
| 468 | + |
| 469 | + # Expect an alert-danger message containing validation errors |
| 470 | + expect(page).to have_css(".alert-danger", text: /There is a problem/) |
| 471 | + expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.") |
| 472 | + expect(page).to have_content("Enable child based requests At least one request type must be set") |
| 473 | + expect(page).to have_content("Pick up email can't have more than three email addresses") |
| 474 | + |
| 475 | + # Expect media section, executive director section, and partner settings section to be opened |
| 476 | + expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true) |
| 477 | + expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true) |
| 478 | + expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true) |
| 479 | + end |
| 480 | + end |
| 481 | + end |
| 482 | + |
383 | 483 | describe "#approve_partner" do
|
384 | 484 | let(:tooltip_message) do
|
385 | 485 | "Partner has not requested approval yet. Partners are able to request approval by going into 'My Organization' and clicking 'Request Approval' button."
|
|
0 commit comments