Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
bc459e62
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bc459e62
编写于
4月 27, 2021
作者:
R
repo-ranger[bot]
提交者:
GitHub
4月 27, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3230 from cdr/jsjoeio/fix-e2e-tests
refactor(testing): fix flaky terminal test
上级
1e683f3d
449c6da7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
30 deletion
+29
-30
test/e2e/models/CodeServer.ts
test/e2e/models/CodeServer.ts
+27
-30
test/e2e/terminal.test.ts
test/e2e/terminal.test.ts
+2
-0
未找到文件。
test/e2e/models/CodeServer.ts
浏览文件 @
bc459e62
...
...
@@ -5,6 +5,7 @@ import { CODE_SERVER_ADDRESS } from "../../utils/constants"
// See Playwright docs: https://playwright.dev/docs/pom/
export
class
CodeServer
{
page
:
Page
editorSelector
=
"
div.monaco-workbench
"
constructor
(
page
:
Page
)
{
this
.
page
=
page
...
...
@@ -30,15 +31,18 @@ export class CodeServer {
// but usually a reload or two fixes it
// TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues
while
(
!
editorIsVisible
)
{
// When a reload happens, we want to wait for all resources to be
// loaded completely. Hence why we use that instead of DOMContentLoaded
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/
await
this
.
page
.
waitForLoadState
(
"
load
"
)
// Give it an extra second just in case it's feeling extra slow
await
this
.
page
.
waitForTimeout
(
1000
)
reloadCount
+=
1
if
(
await
this
.
isEditorVisible
())
{
console
.
log
(
` Editor became visible after
${
reloadCount
}
reloads`
)
break
}
// When a reload happens, we want to wait for all resources to be
// loaded completely. Hence why we use that instead of DOMContentLoaded
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/
await
this
.
page
.
reload
({
waitUntil
:
"
load
"
})
await
this
.
page
.
reload
()
}
}
...
...
@@ -49,28 +53,19 @@ export class CodeServer {
// Make sure the editor actually loaded
// If it's not visible after 5 seconds, something is wrong
await
this
.
page
.
waitForLoadState
(
"
networkidle
"
)
return
await
this
.
page
.
isVisible
(
"
div.monaco-workbench
"
,
{
timeout
:
5000
}
)
return
await
this
.
page
.
isVisible
(
this
.
editorSelector
)
}
/**
* Focuses Integrated Terminal
* by going to the Application Menu
* and clicking View > Terminal
* by using "Terminal: Focus Terminal"
* from the Command Palette
*
* This should focus the terminal no matter
* if it already has focus and/or is or isn't
* visible already.
*/
async
focusTerminal
()
{
// If the terminal is already visible
// then we can focus it by hitting the keyboard shortcut
const
isTerminalVisible
=
await
this
.
page
.
isVisible
(
"
#terminal
"
)
if
(
isTerminalVisible
)
{
await
this
.
page
.
keyboard
.
press
(
`Control+Backquote`
)
// Wait for terminal to receive focus
await
this
.
page
.
waitForSelector
(
"
div.terminal.xterm.focus
"
)
// Sometimes the terminal reloads
// which is why we wait for it twice
await
this
.
page
.
waitForSelector
(
"
div.terminal.xterm.focus
"
)
return
}
// Open using the manu
// Click [aria-label="Application Menu"] div[role="none"]
await
this
.
page
.
click
(
'
[aria-label="Application Menu"] div[role="none"]
'
)
...
...
@@ -78,17 +73,19 @@ export class CodeServer {
await
this
.
page
.
hover
(
"
text=View
"
)
await
this
.
page
.
click
(
"
text=View
"
)
// Click text=Terminal
await
this
.
page
.
hover
(
"
text=Terminal
"
)
await
this
.
page
.
click
(
"
text=Terminal
"
)
// Click text=Command Palette
await
this
.
page
.
hover
(
"
text=Command Palette
"
)
await
this
.
page
.
click
(
"
text=Command Palette
"
)
// Type Terminal: Focus Terminal
await
this
.
page
.
keyboard
.
type
(
"
Terminal: Focus Terminal
"
)
// Click Terminal: Focus Terminal
await
this
.
page
.
hover
(
"
text=Terminal: Focus Terminal
"
)
await
this
.
page
.
click
(
"
text=Terminal: Focus Terminal
"
)
// Wait for terminal to receive focus
// Sometimes the terminal reloads once or twice
// which is why we wait for it to have the focus class
await
this
.
page
.
waitForSelector
(
"
div.terminal.xterm.focus
"
)
// Sometimes the terminal reloads
// which is why we wait for it twice
await
this
.
page
.
waitForSelector
(
"
div.terminal.xterm.focus
"
)
// Wait for terminal textarea to show up
await
this
.
page
.
waitForSelector
(
"
textarea.xterm-helper-textarea
"
)
}
/**
...
...
test/e2e/terminal.test.ts
浏览文件 @
bc459e62
...
...
@@ -52,6 +52,8 @@ test.describe("Integrated Terminal", () => {
await
page
.
waitForLoadState
(
"
load
"
)
await
page
.
keyboard
.
type
(
`echo '
${
testString
}
' > '
${
tmpFile
}
'`
)
await
page
.
keyboard
.
press
(
"
Enter
"
)
// It may take a second to process
await
page
.
waitForTimeout
(
1000
)
const
{
stdout
}
=
await
output
expect
(
stdout
).
toMatch
(
testString
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录