Skip to content

Commit 7051f15

Browse files
committed
Adds spec to test for presence of alert when we try to navigate away from an unsaved edited story
1 parent cc06e42 commit 7051f15

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

spec/features/stories_manage_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@
6868
expect(page).to have_content "Story updated!"
6969
end
7070

71+
it "alerts me when I try to navigate away from the page without saving my edits", js: true do
72+
visit project_path(id: project.id)
73+
click_button "More actions"
74+
click_link "Edit"
75+
fill_in "story[title]", with: "As a user, I want to edit stories"
76+
click_link "Back"
77+
alert_text = page.driver.browser.switch_to.alert.text
78+
79+
expect(alert_text).to eq "You have unsaved changes. Are you sure you want to go back?"
80+
end
81+
7182
it "allows me to delete a story" do
7283
visit project_path(id: project.id)
7384

0 commit comments

Comments
 (0)