Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
1d5c2fd5bc
commit
26284552f5
11 changed files with 124 additions and 16 deletions
|
@ -100,7 +100,6 @@ Style/ExplicitBlockArgument:
|
|||
- 'spec/services/pages/zip_directory_service_spec.rb'
|
||||
- 'spec/services/todo_service_spec.rb'
|
||||
- 'spec/support/helpers/feature_flag_helpers.rb'
|
||||
- 'spec/support/helpers/features/runner_helpers.rb'
|
||||
- 'spec/support/helpers/features/top_nav_spec_helpers.rb'
|
||||
- 'spec/support/helpers/graphql_helpers.rb'
|
||||
- 'spec/support/helpers/modal_helpers.rb'
|
||||
|
|
|
@ -52,6 +52,7 @@ export default {
|
|||
:icon="icon"
|
||||
:title="label"
|
||||
:aria-label="label"
|
||||
data-qa-selector="editor_toolbar_button"
|
||||
@click="clickHandler"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
.file-editor.code
|
||||
- if Feature.enabled?(:source_editor_toolbar, current_user)
|
||||
#editor-toolbar
|
||||
.js-edit-mode-pane.qa-editor#editor{ data: { 'editor-loading': true } }<
|
||||
.js-edit-mode-pane.qa-editor#editor{ data: { 'editor-loading': true, qa_selector: 'source_editor_preview_container' } }<
|
||||
%pre.editor-loading-content= params[:content] || local_assigns[:blob_data]
|
||||
- if local_assigns[:path]
|
||||
.js-edit-mode-pane#preview.hide
|
||||
|
|
|
@ -7,6 +7,30 @@ module QA
|
|||
include Shared::CommitMessage
|
||||
include Shared::CommitButton
|
||||
include Shared::Editor
|
||||
|
||||
view 'app/assets/javascripts/editor/components/source_editor_toolbar_button.vue' do
|
||||
element :editor_toolbar_button
|
||||
end
|
||||
|
||||
view 'app/views/projects/blob/_editor.html.haml' do
|
||||
element :source_editor_preview_container
|
||||
end
|
||||
|
||||
def has_markdown_preview?(component, content)
|
||||
within_element(:source_editor_preview_container) do
|
||||
has_css?(component, exact_text: content)
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_markdown_preview(component, content)
|
||||
return if has_markdown_preview?(component, content)
|
||||
|
||||
raise ElementNotFound, %("Couldn't find #{component} element with content '#{content}')
|
||||
end
|
||||
|
||||
def click_editor_toolbar
|
||||
click_element(:editor_toolbar_button)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,11 @@ module QA
|
|||
end
|
||||
|
||||
def remove_content
|
||||
text_area.send_keys([:command, 'a'], :backspace)
|
||||
if page.driver.browser.capabilities.platform.include? "mac"
|
||||
text_area.send_keys([:command, 'a'], :backspace)
|
||||
else
|
||||
text_area.send_keys([:control, 'a'], :backspace)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
RSpec.describe 'Create', :smoke, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/326624', type: :investigating } do
|
||||
RSpec.describe 'Create', :smoke do
|
||||
describe 'Personal snippet creation' do
|
||||
let(:snippet) do
|
||||
Resource::Snippet.fabricate_via_browser_ui! do |snippet|
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# frozen_string_literal: true
|
||||
# tagged transient due to feature-flag caching flakiness. Remove tag along with feature flag removal.
|
||||
module QA
|
||||
RSpec.describe 'Create', feature_flag: { name: 'source_editor_toolbar', scope: :global } do
|
||||
describe 'Source editor toolbar preview' do
|
||||
let(:project) do
|
||||
Resource::Project.fabricate_via_api! do |project|
|
||||
project.name = 'empty-project-with-md'
|
||||
project.initialize_with_readme = true
|
||||
end
|
||||
end
|
||||
|
||||
let(:edited_readme_content) { 'Here is the edited content.' }
|
||||
|
||||
before do
|
||||
Runtime::Feature.enable(:source_editor_toolbar)
|
||||
Flow::Login.sign_in
|
||||
end
|
||||
|
||||
after do
|
||||
Runtime::Feature.disable(:source_editor_toolbar)
|
||||
end
|
||||
|
||||
it 'can preview markdown side-by-side while editing',
|
||||
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/367749' do
|
||||
project.visit!
|
||||
Page::Project::Show.perform do |project|
|
||||
project.click_file('README.md')
|
||||
end
|
||||
|
||||
Page::File::Show.perform(&:click_edit)
|
||||
|
||||
# wait_until required due to feature_caching. Remove along with feature flag removal.
|
||||
Page::File::Edit.perform do |file|
|
||||
Support::Waiter.wait_until(sleep_interval: 2, max_duration: 60, reload_page: page,
|
||||
retry_on_exception: true) do
|
||||
expect(file).to have_element(:editor_toolbar_button)
|
||||
end
|
||||
file.remove_content
|
||||
file.click_editor_toolbar
|
||||
file.add_content('# ' + edited_readme_content)
|
||||
file.wait_for_markdown_preview('h1', edited_readme_content)
|
||||
file.commit_changes
|
||||
end
|
||||
|
||||
Page::File::Show.perform do |file|
|
||||
aggregate_failures 'file details' do
|
||||
expect(file).to have_notice('Your changes have been successfully committed.')
|
||||
expect(file).to have_file_content(edited_readme_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -17,7 +17,7 @@ shared_examples 'Snowplow event tracking' do
|
|||
|
||||
subject
|
||||
|
||||
expect_no_snowplow_event
|
||||
expect_no_snowplow_event(category: category, action: action)
|
||||
end
|
||||
|
||||
it 'is emitted' do
|
||||
|
|
|
@ -33,7 +33,7 @@ RSpec.shared_examples 'does not track when feature flag is disabled' do |feature
|
|||
end
|
||||
end
|
||||
|
||||
RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events' do
|
||||
RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events for given event params' do
|
||||
before do
|
||||
stub_application_setting(usage_ping_enabled: true)
|
||||
end
|
||||
|
@ -44,22 +44,21 @@ RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events
|
|||
|
||||
specify do
|
||||
aggregate_failures do
|
||||
expect(track_action(author: user1, project: project)).to be_truthy
|
||||
expect(track_action(author: user1, project: project)).to be_truthy
|
||||
expect(track_action(author: user2, project: project)).to be_truthy
|
||||
expect(track_action({ author: user1 }.merge(track_params))).to be_truthy
|
||||
expect(track_action({ author: user1 }.merge(track_params))).to be_truthy
|
||||
expect(track_action({ author: user2 }.merge(track_params))).to be_truthy
|
||||
expect(count_unique).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not track edit actions if author is not present' do
|
||||
expect(track_action(author: nil, project: project)).to be_nil
|
||||
expect(track_action({ author: nil }.merge(track_params))).to be_nil
|
||||
end
|
||||
|
||||
it 'emits snowplow event' do
|
||||
track_action(author: user1, project: project)
|
||||
track_action({ author: user1 }.merge(track_params))
|
||||
|
||||
expect_snowplow_event(category: 'issues_edit', action: action, user: user1,
|
||||
namespace: project.namespace, project: project)
|
||||
expect_snowplow_event(**{ category: category, action: event_action, user: user1 }.merge(event_params))
|
||||
end
|
||||
|
||||
context 'with route_hll_to_snowplow_phase2 disabled' do
|
||||
|
@ -68,9 +67,35 @@ RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events
|
|||
end
|
||||
|
||||
it 'does not emit snowplow event' do
|
||||
track_action(author: user1, project: project)
|
||||
track_action({ author: user1 }.merge(track_params))
|
||||
|
||||
expect_no_snowplow_event
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events' do
|
||||
it_behaves_like 'a daily tracked issuable snowplow and service ping events for given event params' do
|
||||
let_it_be(:track_params) { { project: project } }
|
||||
let_it_be(:event_params) { track_params.merge(namespace: project.namespace) }
|
||||
let_it_be(:category) { 'issues_edit' }
|
||||
let_it_be(:event_action) { action }
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events with namespace' do
|
||||
it_behaves_like 'a daily tracked issuable snowplow and service ping events for given event params' do
|
||||
let(:track_params) { { namespace: namespace } }
|
||||
let(:event_params) { track_params.merge(label: event_label, property: event_property) }
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.shared_examples 'does not track with namespace when feature flag is disabled' do |feature_flag|
|
||||
context "when feature flag #{feature_flag} is disabled" do
|
||||
it 'does not track action' do
|
||||
stub_feature_flags(feature_flag => false)
|
||||
|
||||
expect(track_action(author: user1, namespace: namespace)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -128,10 +128,10 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
|
|||
stub_feature_flags(notes_create_service_tracking: false)
|
||||
end
|
||||
|
||||
it 'does not track any events', :snowplow do
|
||||
it 'does not track Notes::CreateService events', :snowplow do
|
||||
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: { body: 'hi!' }
|
||||
|
||||
expect_no_snowplow_event
|
||||
expect_no_snowplow_event(category: 'Notes::CreateService', action: 'execute')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue