Commit b1ef1d06 authored by Rémy Coutable's avatar Rémy Coutable

Fix flaky wiki specs by waiting for the SVG to be loaded first

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 117e2614
......@@ -3,6 +3,8 @@
require "spec_helper"
describe "User creates wiki page" do
include WikiHelpers
let(:user) { create(:user) }
let(:wiki) { ProjectWiki.new(project, user) }
let(:project) { create(:project) }
......@@ -14,9 +16,11 @@ describe "User creates wiki page" do
end
context "when wiki is empty" do
before do
before do |example|
visit(project_wikis_path(project))
wait_for_svg_to_be_loaded(example)
click_link "Create your first page"
end
......@@ -45,7 +49,7 @@ describe "User creates wiki page" do
expect(page).to have_content("Create New Page")
end
it "shows non-escaped link in the pages list", :quarantine do
it "shows non-escaped link in the pages list" do
fill_in(:wiki_title, with: "one/two/three-test")
page.within(".wiki-form") do
......@@ -163,7 +167,7 @@ describe "User creates wiki page" do
expect(page).to have_link('Link to Home', href: "/#{project.full_path}/-/wikis/home")
end
it_behaves_like 'wiki file attachments', :quarantine
it_behaves_like 'wiki file attachments'
end
context "in a group namespace", :js do
......@@ -175,7 +179,7 @@ describe "User creates wiki page" do
expect(page).to have_field("wiki[message]", with: "Create home")
end
it "creates a page from the home page", :quarantine do
it "creates a page from the home page" do
page.within(".wiki-form") do
fill_in(:wiki_content, with: "My awesome wiki!")
......
......@@ -19,9 +19,12 @@ describe 'User views a wiki page' do
sign_in(user)
end
context 'when wiki is empty' do
context 'when wiki is empty', :js do
before do
visit(project_wikis_path(project))
visit project_wikis_path(project)
wait_for_svg_to_be_loaded
click_link "Create your first page"
fill_in(:wiki_title, with: 'one/two/three-test')
......@@ -32,7 +35,7 @@ describe 'User views a wiki page' do
end
end
it 'shows the history of a page that has a path', :js do
it 'shows the history of a page that has a path' do
expect(current_path).to include('one/two/three-test')
first(:link, text: 'three').click
......@@ -45,7 +48,7 @@ describe 'User views a wiki page' do
end
end
it 'shows an old version of a page', :js do
it 'shows an old version of a page' do
expect(current_path).to include('one/two/three-test')
expect(find('.wiki-pages')).to have_content('three')
......@@ -162,9 +165,12 @@ describe 'User views a wiki page' do
end
it 'opens a default wiki page', :js do
visit(project_path(project))
visit project_path(project)
find('.shortcuts-wiki').click
wait_for_svg_to_be_loaded
click_link "Create your first page"
expect(page).to have_content('Create New Page')
......
......@@ -3,6 +3,11 @@
module WikiHelpers
extend self
def wait_for_svg_to_be_loaded(example = nil)
# Ensure the SVG is loaded first before clicking the button
find('.svg-content .js-lazy-loaded') if example.nil? || example.metadata.key?(:js)
end
def upload_file_to_wiki(project, user, file_name)
opts = {
file_name: file_name,
......
......@@ -42,7 +42,7 @@ RSpec.shared_examples 'wiki file attachments' do
end
end
context 'uploading is complete', :quarantine do
context 'uploading is complete' do
it 'shows "Attach a file" button on uploading complete' do
attach_with_dropzone
wait_for_requests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment