Commit 3270fc44 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 31854910 060d5d36
......@@ -367,6 +367,8 @@ function handleContinueList(e, textArea) {
export function keypressNoteText(e) {
const textArea = this;
if ($(textArea).atwho?.('isSelecting')) return;
handleContinueList(e, textArea);
handleSurroundSelectedText(e, textArea);
}
......
......@@ -11,6 +11,12 @@ require_relative 'lib/gitlab'
require_relative '../config/bundler_setup'
Bundler.require(:default)
require 'securerandom'
require 'pathname'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require 'rainbow/refinement'
module QA
root = "#{__dir__}/qa"
......
......@@ -2,13 +2,19 @@
require 'logger'
require 'forwardable'
require 'rainbow/refinement'
module QA
module Runtime
module Logger
extend SingleForwardable
using Rainbow
LEVEL_COLORS = {
"DEBUG" => :magenta,
"INFO" => :green,
"WARN" => :yellow,
"ERROR" => :indianred,
"FATAL" => :red
}.freeze
def_delegators :logger, :debug, :info, :warn, :error, :fatal, :unknown
......@@ -23,8 +29,9 @@ module QA
logger.formatter = proc do |severity, datetime, progname, msg|
date_format = datetime.strftime("%Y-%m-%d %H:%M:%S")
msg_prefix = "[date=#{date_format} from=QA Tests] #{severity.ljust(5)} -- "
"[date=#{date_format} from=QA Tests] #{severity.ljust(5)} -- ".yellow + "#{msg}\n"
Rainbow(msg_prefix).send(LEVEL_COLORS.fetch(severity, :yellow)) + "#{msg}\n"
end
end
end
......
# frozen_string_literal: true
require 'active_support/inflector'
require 'rainbow/refinement'
module QA
module Support
......@@ -40,7 +39,9 @@ module QA
QA::Runtime::Logger.debug(msg.join(' '))
end
QA::Runtime::Logger.debug("Attempt number #{attempts + 1}".bg(:yellow).black) if log && max_attempts && attempts > 0
if log && max_attempts && attempts > 0
QA::Runtime::Logger.debug("Attempt number #{attempts + 1}".bg(:yellow).black)
end
result = yield
if result
......
......@@ -2,12 +2,6 @@
require_relative '../qa'
require 'securerandom'
require 'pathname'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require 'rainbow/refinement'
require_relative 'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv.configure!
......@@ -36,7 +30,7 @@ RSpec.configure do |config|
end
config.prepend_before do |example|
QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n")
QA::Runtime::Logger.info("Starting test: #{Rainbow(example.full_description).bright}")
QA::Runtime::Example.current = example
# Reset fabrication counters tracked in resource base
......
......@@ -420,6 +420,14 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
end
context 'when typing enter for autocomplete in a markdown list' do
it 'does not create a new list item' do
fill_in 'Comment', with: "- @#{user.username}\n"
expect(find_field('Comment').value).to eq "- @#{user.username}\n"
end
end
end
private
......
import $ from 'jquery';
import { insertMarkdownText, keypressNoteText } from '~/lib/utils/text_markdown';
import '~/lib/utils/jquery_at_who';
describe('init markdown', () => {
let textArea;
......@@ -223,6 +225,24 @@ describe('init markdown', () => {
expect(textArea.selectionEnd).toBe(text.length);
});
// test that when we're in the middle of autocomplete, we don't
// add a new list item
it.each`
text | expected | atwho_selecting
${'- item @'} | ${'- item @'} | ${true}
${'- item @'} | ${'- item @\n- '} | ${false}
`('behaves correctly during autocomplete', ({ text, expected, atwho_selecting }) => {
jest.spyOn($.fn, 'atwho').mockReturnValue(atwho_selecting);
textArea.value = text;
textArea.setSelectionRange(text.length, text.length);
textArea.addEventListener('keydown', keypressNoteText);
textArea.dispatchEvent(enterEvent);
expect(textArea.value).toEqual(expected);
});
it('does nothing if feature flag disabled', () => {
gon.features = { markdownContinueLists: false };
......
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