Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2ec6a7e1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
2ec6a7e1
编写于
4月 10, 2018
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed markdown preview in IDE not working for new files
上级
23fb465c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
11 deletion
+49
-11
app/assets/javascripts/ide/components/repo_editor.vue
app/assets/javascripts/ide/components/repo_editor.vue
+2
-2
spec/javascripts/ide/components/repo_editor_spec.js
spec/javascripts/ide/components/repo_editor_spec.js
+37
-0
spec/javascripts/test_bundle.js
spec/javascripts/test_bundle.js
+10
-9
未找到文件。
app/assets/javascripts/ide/components/repo_editor.vue
浏览文件 @
2ec6a7e1
...
...
@@ -22,7 +22,7 @@ export default {
...
mapState
([
'
rightPanelCollapsed
'
,
'
viewer
'
,
'
delayViewerUpdated
'
,
'
panelResizing
'
]),
...
mapGetters
([
'
currentMergeRequest
'
]),
shouldHideEditor
()
{
return
this
.
file
&&
this
.
file
.
binary
&&
!
this
.
file
.
raw
;
return
this
.
file
&&
this
.
file
.
binary
&&
!
this
.
file
.
content
;
},
editTabCSS
()
{
return
{
...
...
@@ -212,7 +212,7 @@ export default {
<content-viewer
v-if=
"shouldHideEditor || file.viewMode === 'preview'"
:content=
"file.content || file.raw"
:path=
"file.rawPath"
:path=
"file.rawPath
|| file.path
"
:file-size=
"file.size"
:project-path=
"file.projectId"
/>
</div>
...
...
spec/javascripts/ide/components/repo_editor_spec.js
浏览文件 @
2ec6a7e1
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
store
from
'
~/ide/stores
'
;
import
repoEditor
from
'
~/ide/components/repo_editor.vue
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
setTimeoutPromise
from
'
../../helpers/set_timeout_promise_helper
'
;
import
{
file
,
resetStore
}
from
'
../helpers
'
;
describe
(
'
RepoEditor
'
,
()
=>
{
...
...
@@ -79,16 +82,30 @@ describe('RepoEditor', () => {
});
describe
(
'
when file is markdown and viewer mode is review
'
,
()
=>
{
let
mock
;
beforeEach
(
done
=>
{
mock
=
new
MockAdapter
(
axios
);
vm
.
file
.
projectId
=
'
namespace/project
'
;
vm
.
file
.
previewMode
=
{
id
:
'
markdown
'
,
previewTitle
:
'
Preview Markdown
'
,
};
vm
.
file
.
content
=
'
testing 123
'
;
vm
.
$store
.
state
.
viewer
=
'
diff
'
;
mock
.
onPost
(
'
/namespace/project/preview_markdown
'
).
reply
(
200
,
{
body
:
'
<p>testing 123</p>
'
,
});
vm
.
$nextTick
(
done
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
renders an Edit and a Preview Tab
'
,
done
=>
{
Vue
.
nextTick
(()
=>
{
const
tabs
=
vm
.
$el
.
querySelectorAll
(
'
.ide-mode-tabs .nav-links li
'
);
...
...
@@ -99,6 +116,26 @@ describe('RepoEditor', () => {
done
();
});
});
it
(
'
renders markdown for tempFile
'
,
done
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
file
.
path
=
`
${
vm
.
file
.
path
}
.md`
;
vm
.
$store
.
state
.
entries
[
vm
.
file
.
path
]
=
vm
.
file
;
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.ide-mode-tabs .nav-links a
'
)[
1
].
click
();
})
.
then
(
setTimeoutPromise
)
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.preview-container
'
).
innerHTML
).
toContain
(
'
<p>testing 123</p>
'
,
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
when open file is binary and not raw
'
,
()
=>
{
...
...
spec/javascripts/test_bundle.js
浏览文件 @
2ec6a7e1
...
...
@@ -22,7 +22,7 @@ Vue.config.warnHandler = (msg, vm, trace) => {
};
let
hasVueErrors
=
false
;
Vue
.
config
.
errorHandler
=
function
(
err
)
{
Vue
.
config
.
errorHandler
=
function
(
err
)
{
hasVueErrors
=
true
;
fail
(
err
);
};
...
...
@@ -43,10 +43,11 @@ window.gl = window.gl || {};
window
.
gl
.
TEST_HOST
=
TEST_HOST
;
window
.
gon
=
window
.
gon
||
{};
window
.
gon
.
test_env
=
true
;
gon
.
relative_url_root
=
''
;
let
hasUnhandledPromiseRejections
=
false
;
window
.
addEventListener
(
'
unhandledrejection
'
,
(
event
)
=>
{
window
.
addEventListener
(
'
unhandledrejection
'
,
event
=>
{
hasUnhandledPromiseRejections
=
true
;
console
.
error
(
'
Unhandled promise rejection:
'
);
console
.
error
(
event
.
reason
.
stack
||
event
.
reason
);
...
...
@@ -71,13 +72,13 @@ const axiosDefaultAdapter = getDefaultAdapter();
// render all of our tests
const
testsContext
=
require
.
context
(
'
.
'
,
true
,
/_spec$/
);
testsContext
.
keys
().
forEach
(
function
(
path
)
{
testsContext
.
keys
().
forEach
(
function
(
path
)
{
try
{
testsContext
(
path
);
}
catch
(
err
)
{
console
.
error
(
'
[ERROR] Unable to load spec:
'
,
path
);
describe
(
'
Test bundle
'
,
function
()
{
it
(
`includes '
${
path
}
'`
,
function
()
{
describe
(
'
Test bundle
'
,
function
()
{
it
(
`includes '
${
path
}
'`
,
function
()
{
expect
(
err
).
toBeNull
();
});
});
...
...
@@ -85,7 +86,7 @@ testsContext.keys().forEach(function (path) {
});
describe
(
'
test errors
'
,
()
=>
{
beforeAll
(
(
done
)
=>
{
beforeAll
(
done
=>
{
if
(
hasUnhandledPromiseRejections
||
hasVueWarnings
||
hasVueErrors
)
{
setTimeout
(
done
,
1000
);
}
else
{
...
...
@@ -149,18 +150,18 @@ if (process.env.BABEL_ENV === 'coverage') {
'
./issue_show/index.js
'
,
];
describe
(
'
Uncovered files
'
,
function
()
{
describe
(
'
Uncovered files
'
,
function
()
{
const
sourceFiles
=
require
.
context
(
'
~
'
,
true
,
/
\.
js$/
);
$
.
holdReady
(
true
);
sourceFiles
.
keys
().
forEach
(
function
(
path
)
{
sourceFiles
.
keys
().
forEach
(
function
(
path
)
{
// ignore if there is a matching spec file
if
(
testsContext
.
keys
().
indexOf
(
`
${
path
.
replace
(
/
\.
js$/
,
''
)}
_spec`
)
>
-
1
)
{
return
;
}
it
(
`includes '
${
path
}
'`
,
function
()
{
it
(
`includes '
${
path
}
'`
,
function
()
{
try
{
sourceFiles
(
path
);
}
catch
(
err
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录