Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
459 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FactoryBot.define do | ||
factory :guide_node_base, class: Guide::Node::Base, traits: [:cms_node] do | ||
route "guide/base" | ||
end | ||
|
||
factory :guide_node_guide, class: Guide::Node::Guide, traits: [:cms_node] do | ||
route "guide/guide" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FactoryBot.define do | ||
factory :guide_procedure, class: Guide::Procedure do | ||
name unique_id | ||
link_url "https://shirasagi.example.jp" | ||
html "<p>#{unique_id}</p>" | ||
procedure_location "location1\nlocation2\nlocation3" | ||
belongings "belong1\nbelong2\nbelong3" | ||
procedure_applicant "applicant1\napplicant2\napplicant3" | ||
remarks "remarks" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :guide_question, class: Guide::Question do | ||
name unique_id | ||
question_type "yes_no" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
require 'spec_helper' | ||
|
||
describe "guide_agents_nodes_guide", type: :feature, dbscope: :example, js: true do | ||
let(:site) { cms_site } | ||
let(:layout) { create_cms_layout } | ||
let(:node) { create :guide_node_guide, layout_id: layout.id, filename: "guide" } | ||
|
||
context "public" do | ||
before do | ||
Capybara.app_host = "http://#{site.domain}" | ||
end | ||
|
||
context "no procedures" do | ||
it "#index" do | ||
visit node.url | ||
within ".guide-node-form" do | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.start_guide") | ||
end | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 0)) | ||
click_on I18n.t("guide.links.show_answer") | ||
|
||
expect(page).to have_text(I18n.t("guide.views.your-answers")) | ||
click_on I18n.t("guide.links.show_result") | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 0)) | ||
click_on I18n.t("guide.links.show_procedure") | ||
|
||
expect(page).to have_text(I18n.t("guide.views.all_procedure")) | ||
click_on I18n.t("guide.links.show_result") | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 0)) | ||
click_on I18n.t("guide.links.back_to_first") | ||
|
||
within "footer.send" do | ||
click_on I18n.t("guide.links.start_guide") | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "diagram" do | ||
let!(:procedure1) { create :guide_procedure, cur_site: site, cur_node: node, name: "procedure1", order: 10 } | ||
let!(:procedure2) { create :guide_procedure, cur_site: site, cur_node: node, name: "procedure2", order: 20 } | ||
let!(:procedure3) { create :guide_procedure, cur_site: site, cur_node: node, name: "procedure3", order: 30 } | ||
let!(:procedure4) { create :guide_procedure, cur_site: site, cur_node: node, name: "procedure4", order: 40 } | ||
let!(:procedure5) { create :guide_procedure, cur_site: site, cur_node: node, name: "procedure5", order: 50 } | ||
|
||
let!(:question1) { create :guide_question, cur_site: site, cur_node: node, name: "question1", order: 10, in_edges: in_edges(procedure1) } | ||
let!(:question2) { create :guide_question, cur_site: site, cur_node: node, name: "question2", order: 20, in_edges: in_edges(procedure2) } | ||
let!(:question3) { create :guide_question, cur_site: site, cur_node: node, name: "question3", order: 30, in_edges: in_edges(procedure3) } | ||
let!(:question4) { create :guide_question, cur_site: site, cur_node: node, name: "question4", order: 40, in_edges: in_edges(procedure4) } | ||
let!(:question5) { create :guide_question, cur_site: site, cur_node: node, name: "question5", order: 50, in_edges: in_edges(procedure5) } | ||
|
||
def in_edges(point) | ||
[ | ||
{ value: I18n.t("guide.links.applicable"), question_type: "yes_no", point_ids: [point.id] }, | ||
{ value: I18n.t("guide.links.not_applicable"), question_type: "yes_no", point_ids: [] } | ||
] | ||
end | ||
|
||
it "#index" do | ||
visit node.url | ||
within ".guide-node-form" do | ||
# 5 times yes | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.start_guide") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question1.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question2.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question3.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question4.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question5.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 5)) | ||
expect(page).to have_link(procedure1.name) | ||
expect(page).to have_link(procedure2.name) | ||
expect(page).to have_link(procedure3.name) | ||
expect(page).to have_link(procedure4.name) | ||
expect(page).to have_link(procedure5.name) | ||
|
||
click_on I18n.t("guide.links.back_to_first") | ||
|
||
# 3 times yes, 2 times no | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.start_guide") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question1.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question2.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question3.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question4.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question5.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.applicable") | ||
end | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 3)) | ||
expect(page).to have_link(procedure1.name) | ||
expect(page).to have_no_link(procedure2.name) | ||
expect(page).to have_link(procedure3.name) | ||
expect(page).to have_no_link(procedure4.name) | ||
expect(page).to have_link(procedure5.name) | ||
|
||
click_on I18n.t("guide.links.back_to_first") | ||
|
||
# 5 times no | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.start_guide") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question1.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question2.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question3.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question4.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".question-nav", text: I18n.t("guide.views.choose_yes_no")) | ||
expect(page).to have_css(".question", text: question5.name) | ||
within "footer.send" do | ||
click_on I18n.t("guide.links.not_applicable") | ||
end | ||
|
||
expect(page).to have_css(".procedure-count", text: I18n.t("guide.views.procedures_needed", count: 0)) | ||
expect(page).to have_no_link(procedure1.name) | ||
expect(page).to have_no_link(procedure2.name) | ||
expect(page).to have_no_link(procedure3.name) | ||
expect(page).to have_no_link(procedure4.name) | ||
expect(page).to have_no_link(procedure5.name) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
require 'spec_helper' | ||
|
||
describe "guide_procedures", type: :feature, dbscope: :example, js: true do | ||
let(:site) { cms_site } | ||
let(:node) { create :guide_node_guide, filename: "guide" } | ||
let(:item) { create(:guide_procedure, cur_site: site, cur_node: node) } | ||
|
||
let(:index_path) { guide_procedures_path site.id, node } | ||
let(:new_path) { new_guide_procedure_path site.id, node } | ||
let(:show_path) { guide_procedure_path site.id, node, item } | ||
let(:edit_path) { edit_guide_procedure_path site.id, node, item } | ||
let(:delete_path) { delete_guide_procedure_path site.id, node, item } | ||
|
||
context "basic crud" do | ||
before { login_cms_user } | ||
|
||
it "#index" do | ||
visit index_path | ||
expect(current_path).not_to eq sns_login_path | ||
end | ||
|
||
it "#new" do | ||
visit new_path | ||
within "form#item-form" do | ||
fill_in "item[name]", with: "sample" | ||
click_on I18n.t("ss.buttons.save") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.saved')) | ||
end | ||
|
||
it "#show" do | ||
visit show_path | ||
|
||
within "#addon-basic" do | ||
expect(page).to have_text(item.name) | ||
expect(page).to have_text(item.link_url) | ||
end | ||
within "#addon-guide-agents-addons-procedure" do | ||
expect(page).to have_text("location1") | ||
expect(page).to have_text("belong1") | ||
expect(page).to have_text("applicant1") | ||
expect(page).to have_text("remarks") | ||
end | ||
end | ||
|
||
it "#edit" do | ||
visit edit_path | ||
within "form#item-form" do | ||
fill_in "item[name]", with: "modify" | ||
fill_in "item[link_url]", with: "https://modify.example.jp" | ||
fill_in_code_mirror "item[html]", with: "<p>modify_html</p>" | ||
fill_in "item[procedure_location]", with: "modify_location1" | ||
fill_in "item[belongings]", with: "modify_belong1" | ||
fill_in "item[procedure_applicant]", with: "modify_applicant1" | ||
fill_in "item[remarks]", with: "modify_remarks" | ||
click_on I18n.t("ss.buttons.save") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.saved')) | ||
|
||
within "#addon-basic" do | ||
expect(page).to have_text("modify") | ||
expect(page).to have_text("https://modify.example.jp") | ||
end | ||
within "#addon-guide-agents-addons-procedure" do | ||
expect(page).to have_text("modify_html") | ||
expect(page).to have_text("modify_location1") | ||
expect(page).to have_text("modify_belong1") | ||
expect(page).to have_text("modify_applicant1") | ||
expect(page).to have_text("modify_remarks") | ||
end | ||
end | ||
|
||
it "#delete" do | ||
visit delete_path | ||
within "form" do | ||
click_on I18n.t("ss.buttons.delete") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.deleted')) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require 'spec_helper' | ||
|
||
describe "guide_questions", type: :feature, dbscope: :example, js: true do | ||
let(:site) { cms_site } | ||
let(:node) { create :guide_node_guide, filename: "guide" } | ||
let(:item) { create(:guide_question, cur_site: site, cur_node: node) } | ||
|
||
let(:index_path) { guide_questions_path site.id, node } | ||
let(:new_path) { new_guide_question_path site.id, node } | ||
let(:show_path) { guide_question_path site.id, node, item } | ||
let(:edit_path) { edit_guide_question_path site.id, node, item } | ||
let(:delete_path) { delete_guide_question_path site.id, node, item } | ||
|
||
context "basic crud" do | ||
before { login_cms_user } | ||
|
||
it "#index" do | ||
visit index_path | ||
expect(current_path).not_to eq sns_login_path | ||
end | ||
|
||
it "#new" do | ||
visit new_path | ||
within "form#item-form" do | ||
fill_in "item[name]", with: "sample" | ||
click_on I18n.t("ss.buttons.save") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.saved')) | ||
end | ||
|
||
it "#show" do | ||
visit show_path | ||
expect(page).to have_css("#addon-basic", text: item.name) | ||
expect(page).to have_css("#addon-guide-agents-addons-question", text: I18n.t("guide.options.question_type.yes_no")) | ||
end | ||
|
||
it "#edit" do | ||
visit edit_path | ||
within "form#item-form" do | ||
fill_in "item[name]", with: "modify" | ||
choose "item_question_type_choices" | ||
choose "item_check_type_single" | ||
fill_in "item[in_edges][][value]", with: "answer1" | ||
click_on I18n.t("ss.buttons.save") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.saved')) | ||
|
||
expect(page).to have_css("#addon-basic", text: "modify") | ||
expect(page).to have_css("#addon-guide-agents-addons-question", text: I18n.t("guide.options.question_type.choices")) | ||
end | ||
|
||
it "#delete" do | ||
visit delete_path | ||
within "form" do | ||
click_on I18n.t("ss.buttons.delete") | ||
end | ||
expect(page).to have_css('#notice', text: I18n.t('ss.notice.deleted')) | ||
end | ||
end | ||
end |
Oops, something went wrong.