Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
4ed39f72
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5994
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4ed39f72
编写于
3月 25, 2024
作者:
xuty73419315
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:file manager自动化测试测适配iOS
上级
39312be7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
15 deletion
+32
-15
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+32
-15
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
4ed39f72
...
...
@@ -116,9 +116,11 @@ describe('ExtApi-FileManagerTest', () => {
await
btnReadDirButton
.
tap
()
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
]
"
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
b
\"
]
"
)
// 获取和对比 文件内容
const
btnReadFileButton
=
await
page
.
$
(
'
#btn-read-file
'
)
await
btnReadFileButton
.
tap
()
...
...
@@ -176,9 +178,11 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 2.txt 两个文件都存在
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
2.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
2.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
2.txt
\"
]
"
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
2.txt
\"
,
\"
b
\"
]
"
)
// 测试 rename
await
page
.
setData
({
...
...
@@ -195,10 +199,11 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 3.txt 两个文件都存在
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
3.txt
\"
,
\"
b
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
fileListSuccess
.
sort
(
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
1.txt
\"
,
\"
3.txt
\"
,
\"
b
\"
]
"
)
});
it
(
'
TEMP_PATH test
'
,
async
()
=>
{
...
...
@@ -281,8 +286,10 @@ describe('ExtApi-FileManagerTest', () => {
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
]
"
)
/**
...
...
@@ -406,13 +413,14 @@ describe('ExtApi-FileManagerTest', () => {
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
fileListComplete
.
sort
()
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
,
\"
提前创建的目录
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
.
sort
()
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
"
+
testDirName
+
"
\"
,
\"
提前创建的目录
\"
]
"
)
await
page
.
setData
({
copyFromFile
:
"
a/
"
+
testDirName
+
"
/中文路径/张三/name/中文文件.mock
"
,
copyToFile
:
"
a/提前创建的目录/4.txt
"
})
...
...
@@ -800,7 +808,7 @@ describe('ExtApi-FileManagerTest', () => {
// 读取单个文件信息
let
statsRet
=
await
getData
(
'
statsRet
'
)
expect
(
statsRet
.
length
).
toEqual
(
1
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/1.txt
'
))
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/1.txt$
'
))
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
69
)
/**
...
...
@@ -828,7 +836,7 @@ describe('ExtApi-FileManagerTest', () => {
await
page
.
setData
({
// asset 只能正式版测试,这里只能模拟返回路径
basePath
:
''
,
copyFromFile
:
'
file:///android_asset/uni-uts/uni-prompt/toast_error.png
'
,
copyFromFile
:
'
static/test-image/logo.ico
'
,
copyToFile
:
'
a/m/3.txt
'
,
})
const
btnCopyFileButton
=
await
page
.
$
(
'
#btn-copy-file
'
)
...
...
@@ -847,16 +855,25 @@ describe('ExtApi-FileManagerTest', () => {
// 读取全部文件信息
statsRet
=
await
getData
(
'
statsRet
'
)
statsRet
.
sort
(
function
(
a
,
b
){
if
(
a
.
path
>
b
.
path
){
return
1
}
else
if
(
a
.
path
<
b
.
path
){
return
-
1
}
return
0
})
console
.
log
(
statsRet
)
expect
(
statsRet
.
length
).
toEqual
(
5
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a
'
))
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
0
)
expect
(
statsRet
[
0
].
path
).
toMatch
(
new
RegExp
(
'
.*/a$
'
))
//
expect(statsRet[0].stats.size).toEqual(0)
expect
(
statsRet
[
2
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/2.txt
'
))
expect
(
statsRet
[
2
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/2.txt$
'
))
expect
(
statsRet
[
2
].
stats
.
size
).
toEqual
(
10
)
expect
(
statsRet
[
4
].
path
).
toMatch
(
new
RegExp
(
'
/storage/
\\
S+/Android/data/io.dcloud.uniappx/a/m/3.txt
'
))
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
5842
)
expect
(
statsRet
[
4
].
path
).
toMatch
(
new
RegExp
(
'
.*/a/m/3.txt$
'
))
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
156406
)
// 清理文件,避免影响其他测试用例
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录