diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/support/shared_examples/features/wiki | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features/wiki')
6 files changed, 91 insertions, 36 deletions
diff --git a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb index 44d82d2e753..2f8ebd0d264 100644 --- a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb @@ -20,15 +20,25 @@ RSpec.shared_examples 'User creates wiki page' do click_link "Create your first page" end - it "shows validation error message" do + it "shows validation error message if the form is force submitted", :js do page.within(".wiki-form") do fill_in(:wiki_content, with: "") - click_on("Create page") + page.execute_script("window.onbeforeunload = null") + page.execute_script("document.querySelector('.wiki-form').submit()") end expect(page).to have_content("The form contains the following error:").and have_content("Content can't be blank") + end + + it "disables the submit button", :js do + page.within(".wiki-form") do + fill_in(:wiki_content, with: "") + expect(page).to have_button('Create page', disabled: true) + end + end + it "makes sure links to unknown pages work correctly", :js do page.within(".wiki-form") do fill_in(:wiki_content, with: "[link test](test)") @@ -42,7 +52,7 @@ RSpec.shared_examples 'User creates wiki page' do expect(page).to have_content("Create New Page") end - it "shows non-escaped link in the pages list" do + it "shows non-escaped link in the pages list", :js do fill_in(:wiki_title, with: "one/two/three-test") page.within(".wiki-form") do @@ -61,7 +71,7 @@ RSpec.shared_examples 'User creates wiki page' do expect(page).to have_field("wiki[message]", with: "Create home") end - it "creates a page from the home page" do + it "creates a page from the home page", :js do fill_in(:wiki_content, with: "[test](test)\n[GitLab API doc](api)\n[Rake tasks](raketasks)\n# Wiki header\n") fill_in(:wiki_message, with: "Adding links to wiki") @@ -79,7 +89,7 @@ RSpec.shared_examples 'User creates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, "test")) - page.within(:css, ".nav-text") do + page.within(:css, ".wiki-page-header") do expect(page).to have_content("Create New Page") end @@ -91,7 +101,7 @@ RSpec.shared_examples 'User creates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, "api")) - page.within(:css, ".nav-text") do + page.within(:css, ".wiki-page-header") do expect(page).to have_content("Create") end @@ -103,7 +113,7 @@ RSpec.shared_examples 'User creates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, "raketasks")) - page.within(:css, ".nav-text") do + page.within(:css, ".wiki-page-header") do expect(page).to have_content("Create") end end @@ -142,7 +152,7 @@ RSpec.shared_examples 'User creates wiki page' do end end - it 'creates a wiki page with Org markup', :aggregate_failures do + it 'creates a wiki page with Org markup', :aggregate_failures, :js do org_content = <<~ORG * Heading ** Subheading @@ -170,7 +180,7 @@ RSpec.shared_examples 'User creates wiki page' do visit wiki_path(wiki) end - context "via the `new wiki page` page" do + context "via the `new wiki page` page", :js do it "creates a page with a single word" do click_link("New page") @@ -189,7 +199,7 @@ RSpec.shared_examples 'User creates wiki page' do .and have_content("My awesome wiki!") end - it "creates a page with spaces in the name" do + it "creates a page with spaces in the name", :js do click_link("New page") page.within(".wiki-form") do @@ -207,7 +217,7 @@ RSpec.shared_examples 'User creates wiki page' do .and have_content("My awesome wiki!") end - it "creates a page with hyphens in the name" do + it "creates a page with hyphens in the name", :js do click_link("New page") page.within(".wiki-form") do diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb index 3350e54a8a7..1e325535e81 100644 --- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb @@ -90,9 +90,11 @@ RSpec.shared_examples 'User updates wiki page' do expect(page).to have_field('wiki[message]', with: 'Update Wiki title') end - it 'shows a validation error message' do + it 'shows a validation error message if the form is force submitted', :js do fill_in(:wiki_content, with: '') - click_button('Save changes') + + page.execute_script("window.onbeforeunload = null") + page.execute_script("document.querySelector('.wiki-form').submit()") expect(page).to have_selector('.wiki-form') expect(page).to have_content('Edit Page') @@ -101,6 +103,13 @@ RSpec.shared_examples 'User updates wiki page' do expect(find('textarea#wiki_content').value).to eq('') end + it "disables the submit button", :js do + page.within(".wiki-form") do + fill_in(:wiki_content, with: "") + expect(page).to have_button('Save changes', disabled: true) + end + end + it 'shows the emoji autocompletion dropdown', :js do find('#wiki_content').native.send_keys('') fill_in(:wiki_content, with: ':') @@ -108,7 +117,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(page).to have_selector('.atwho-view') end - it 'shows the error message' do + it 'shows the error message', :js do wiki_page.update(content: 'Update') # rubocop:disable Rails/SaveBang click_button('Save changes') @@ -116,13 +125,17 @@ RSpec.shared_examples 'User updates wiki page' do expect(page).to have_content('Someone edited the page the same time you did.') end - it 'updates a page' do + it 'updates a page', :js do fill_in('Content', with: 'Updated Wiki Content') click_on('Save changes') expect(page).to have_content('Updated Wiki Content') end + it 'focuses on the content field', :js do + expect(page).to have_selector '.note-textarea:focus' + end + it 'cancels editing of a page' do page.within(:css, '.wiki-form .form-actions') do click_on('Cancel') @@ -143,7 +156,7 @@ RSpec.shared_examples 'User updates wiki page' do visit wiki_page_path(wiki, wiki_page, action: :edit) end - it 'moves the page to the root folder' do + it 'moves the page to the root folder', :js do fill_in(:wiki_title, with: "/#{page_name}") click_button('Save changes') @@ -151,7 +164,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, page_name)) end - it 'moves the page to other dir' do + it 'moves the page to other dir', :js do new_page_dir = "foo1/bar1/#{page_name}" fill_in(:wiki_title, with: new_page_dir) @@ -161,7 +174,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, new_page_dir)) end - it 'remains in the same place if title has not changed' do + it 'remains in the same place if title has not changed', :js do original_path = wiki_page_path(wiki, wiki_page) fill_in(:wiki_title, with: page_name) @@ -171,7 +184,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(current_path).to eq(original_path) end - it 'can be moved to a different dir with a different name' do + it 'can be moved to a different dir with a different name', :js do new_page_dir = "foo1/bar1/new_page_name" fill_in(:wiki_title, with: new_page_dir) @@ -181,7 +194,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, new_page_dir)) end - it 'can be renamed and moved to the root folder' do + it 'can be renamed and moved to the root folder', :js do new_name = 'new_page_name' fill_in(:wiki_title, with: "/#{new_name}") @@ -191,7 +204,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(current_path).to eq(wiki_page_path(wiki, new_name)) end - it 'squishes the title before creating the page' do + it 'squishes the title before creating the page', :js do new_page_dir = " foo1 / bar1 / #{page_name} " fill_in(:wiki_title, with: new_page_dir) @@ -220,7 +233,7 @@ RSpec.shared_examples 'User updates wiki page' do expect(page).to have_content('Wiki page was successfully updated.') end - it 'shows a validation error when trying to change the content' do + it 'shows a validation error when trying to change the content', :js do fill_in 'Content', with: 'new content' click_on 'Save changes' diff --git a/spec/support/shared_examples/features/wiki/user_uses_wiki_shortcuts_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_uses_wiki_shortcuts_shared_examples.rb index 759cfaf6b1f..857d923785f 100644 --- a/spec/support/shared_examples/features/wiki/user_uses_wiki_shortcuts_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_uses_wiki_shortcuts_shared_examples.rb @@ -15,6 +15,6 @@ RSpec.shared_examples 'User uses wiki shortcuts' do it 'visit edit wiki page using "e" keyboard shortcut', :js do find('body').native.send_key('e') - expect(find('.wiki-page-title')).to have_content('Edit Page') + expect(find('.page-title')).to have_content('Edit Page') end end diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_empty_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_empty_shared_examples.rb index d7f5b485a82..14180d503df 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_empty_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_empty_shared_examples.rb @@ -53,7 +53,7 @@ RSpec.shared_examples 'User views empty wiki' do if writable element.click_link 'Create your first page' - expect(page).to have_button('Create page') + expect(page).to have_button('Create page', disabled: true) else expect(element).not_to have_link('Create your first page') end diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb index af769be6d4b..61feeff57bb 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb @@ -44,7 +44,7 @@ RSpec.shared_examples 'User views a wiki page' do expect(current_path).to include('one/two/three-test') - page.within(:css, '.nav-text') do + page.within(:css, '.wiki-page-header') do expect(page).to have_content('History') end end @@ -69,7 +69,7 @@ RSpec.shared_examples 'User views a wiki page' do click_on('Page history') - within('.nav-text') do + within('.wiki-page-header') do expect(page).to have_content('History') end diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_sidebar_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_sidebar_shared_examples.rb index a7ba7a8ad07..639eb3f2b99 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_sidebar_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_sidebar_shared_examples.rb @@ -17,23 +17,55 @@ RSpec.shared_examples 'User views wiki sidebar' do create(:wiki_page, wiki: wiki, title: 'another', content: 'another') end - it 'renders a default sidebar when there is no customized sidebar' do - visit wiki_path(wiki) + context 'when there is no custom sidebar' do + before do + visit wiki_path(wiki) + end - expect(page).to have_content('another') - expect(page).not_to have_link('View All Pages') + it 'renders a default sidebar' do + within('.right-sidebar') do + expect(page).to have_content('another') + expect(page).not_to have_link('View All Pages') + end + end + + it 'can create a custom sidebar', :js do + click_on 'Edit sidebar' + fill_in :wiki_content, with: 'My custom sidebar' + click_on 'Create page' + + within('.right-sidebar') do + expect(page).to have_content('My custom sidebar') + expect(page).not_to have_content('another') + end + end end - context 'when there is a customized sidebar' do + context 'when there is a custom sidebar' do before do - create(:wiki_page, wiki: wiki, title: '_sidebar', content: 'My customized sidebar') - end + create(:wiki_page, wiki: wiki, title: '_sidebar', content: 'My custom sidebar') - it 'renders my customized sidebar instead of the default one' do visit wiki_path(wiki) + end + + it 'renders the custom sidebar instead of the default one' do + within('.right-sidebar') do + expect(page).to have_content('My custom sidebar') + expect(page).not_to have_content('another') + end + end + + it 'can edit the custom sidebar', :js do + click_on 'Edit sidebar' + + expect(page).to have_field(:wiki_content, with: 'My custom sidebar') + + fill_in :wiki_content, with: 'My other custom sidebar' + click_on 'Save changes' - expect(page).to have_content('My customized sidebar') - expect(page).not_to have_content('Another') + within('.right-sidebar') do + expect(page).to have_content('My other custom sidebar') + end end end end |