fix: handle unicode filename and website uploads (#491)
* fix: print meaningful error message for invalid filenames * fix: handle unicode dirnames and filenames * chore: revert custom error message
This commit is contained in:
@@ -77,7 +77,7 @@ export function Upload(): ReactElement {
|
|||||||
let fls: FilePath[] = files.map(f => packageFile(f)) // Apart from packaging, this is needed to not modify the original files array as it can trigger effects
|
let fls: FilePath[] = files.map(f => packageFile(f)) // Apart from packaging, this is needed to not modify the original files array as it can trigger effects
|
||||||
let indexDocument: string | undefined = undefined // This means we assume it's folder
|
let indexDocument: string | undefined = undefined // This means we assume it's folder
|
||||||
|
|
||||||
if (files.length === 1) indexDocument = files[0].name
|
if (files.length === 1) indexDocument = unescape(encodeURIComponent(files[0].name))
|
||||||
else if (files.length > 1) {
|
else if (files.length > 1) {
|
||||||
const idx = detectIndexHtml(files)
|
const idx = detectIndexHtml(files)
|
||||||
|
|
||||||
|
|||||||
+15
-4
@@ -18,15 +18,26 @@ export function detectIndexHtml(files: FilePath[]): DetectedIndex | false {
|
|||||||
return { indexPath: exactMatch }
|
return { indexPath: exactMatch }
|
||||||
}
|
}
|
||||||
|
|
||||||
const prefix = paths[0].split('/')[0] + '/'
|
const sortedPaths = paths.sort((a, b) => a.localeCompare(b))
|
||||||
|
const firstSegments = sortedPaths[0].split('/')
|
||||||
|
const lastSegments = sortedPaths[sortedPaths.length - 1].split('/')
|
||||||
|
let matchingSegments = 0
|
||||||
|
|
||||||
const allStartWithSamePrefix = paths.every(x => x.startsWith(prefix))
|
for (; matchingSegments < firstSegments.length; matchingSegments++) {
|
||||||
|
if (firstSegments[matchingSegments] !== lastSegments[matchingSegments]) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const commonPrefix = firstSegments.slice(0, matchingSegments).join('/') + '/'
|
||||||
|
|
||||||
|
const allStartWithSamePrefix = paths.every(x => x.startsWith(commonPrefix))
|
||||||
|
|
||||||
if (allStartWithSamePrefix) {
|
if (allStartWithSamePrefix) {
|
||||||
const match = paths.find(x => indexHtmls.map(y => prefix + y).includes(x))
|
const match = paths.find(x => indexHtmls.map(y => commonPrefix + y).includes(x))
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
return { indexPath: match, commonPrefix: prefix }
|
return { indexPath: match, commonPrefix }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
🙅𝖆👾\都都𝖇🙅𝖆𝖈\𝖇—🙇\𝖆💁🙇東都東🙇\💁👾𝖆𝖆𝖆𝖇—東東京🙇𝖆𝖈💁🙇🙅🙅
|
||||||
|
都𝖆🙅\👾𝖈𝖈東🙇\都東𝖇𝖆東都\👾👾東東都👾👾\💁\𝖇𝖈𝖆🙇東都都\都👾💁🙇𝖈
|
||||||
|
👾\🙅東東京東都🙅—𝖇京京🙇💁—👾𝖇𝖇𝖇都👾東𝖆京👾京👾🙇都\𝖆—東東—京👾京東
|
||||||
|
—🙅都—𝖈𝖇—\\𝖆都💁💁🙇𝖈𝖈🙅—都\🙇𝖇💁𝖈𝖇\🙇𝖆💁👾京𝖆都都🙅—𝖈𝖇都𝖇
|
||||||
|
𝖇都\𝖈都👾💁𝖈🙇京👾京—𝖆𝖆🙅京𝖈\𝖇—京🙅💁𝖈—都\京都東東𝖆𝖇𝖇🙅\👾京🙅
|
||||||
|
東🙅\都𝖆—👾💁𝖈都🙅東—𝖆🙇𝖆🙇𝖈🙅京東𝖇𝖇🙅都𝖈東👾東🙇🙇🙇👾𝖆🙇👾—東—東
|
||||||
|
𝖆京都東🙅都𝖈🙇都\東🙅🙅👾𝖇𝖇👾𝖇👾👾👾京\—𝖇—🙅\𝖆𝖆京𝖆💁🙅京東𝖆🙇—💁
|
||||||
|
都東東🙇都👾𝖈𝖈𝖆𝖈👾東都💁京—𝖈都東🙇𝖈—🙇𝖈都\\東京🙅𝖇—𝖈🙇東𝖆𝖈東京👾
|
||||||
|
—𝖇—💁👾都👾𝖇—𝖈東京𝖇\都𝖆\\👾都🙅𝖈—𝖈京𝖈都👾👾💁𝖇都🙅💁東京👾都東東
|
||||||
|
👾—東🙇東🙇東𝖇💁💁東京—\京𝖇東——𝖆京京🙅💁🙇💁東🙅𝖆𝖈東🙅東𝖇💁👾東\\𝖆
|
||||||
|
都🙅💁—🙅𝖈🙇𝖈👾𝖆🙇👾𝖆\東𝖆🙇𝖆𝖆🙇都🙇都京𝖈🙅—都👾👾𝖇💁🙇🙅\\🙅𝖇🙅👾
|
||||||
|
—\京東𝖇東京𝖈𝖆\京東👾🙅𝖆💁東𝖇都𝖈—東都🙇🙇—𝖈💁👾\💁—🙅💁\𝖇京𝖈🙅💁
|
||||||
|
\🙇𝖇💁都🙇京\🙇𝖈🙅都—𝖆🙇𝖇𝖈𝖇𝖇🙅🙅𝖇👾\東—🙅🙇💁京𝖇東東\𝖇💁𝖈都𝖆👾
|
||||||
|
東🙇\👾𝖇👾💁都𝖆\🙇👾𝖈👾👾東𝖆京👾東都💁🙇💁———京都京東京💁👾𝖈京💁🙇🙅𝖈
|
||||||
|
𝖈\𝖆👾東👾𝖇—京東京👾京💁東京🙅都京👾🙅𝖈京—東🙇東🙅都𝖇𝖇京都𝖇—\𝖇都🙅𝖆
|
||||||
|
𝖈👾—都東👾\—🙅𝖈\—👾🙅𝖆👾—🙇👾東都🙅—💁——京𝖇—𝖆🙇🙅👾💁𝖆都🙇🙅\𝖆
|
||||||
|
𝖇—東\𝖇𝖈𝖇𝖆都👾🙇京都🙇🙇\🙅—\🙇👾𝖇東—👾🙅𝖈🙇—東💁𝖈𝖈都都東🙅\🙇\
|
||||||
|
🙅都京京👾—👾🙅𝖈👾𝖈都東💁🙅東🙅👾🙇𝖇𝖇東𝖈𝖇𝖇👾—京𝖈東𝖈🙅京𝖇\🙅𝖇🙇—\
|
||||||
|
京💁—\\💁💁京—🙇👾💁𝖆👾🙇𝖇𝖈🙇京𝖆🙇𝖈🙇𝖇🙅𝖇𝖈𝖈都𝖈🙇𝖆𝖈—𝖈都𝖇京都💁
|
||||||
|
🙇\𝖈—𝖆東京都🙇\\—京𝖇𝖈𝖈🙇👾東🙅🙅—𝖆—京𝖈東\都𝖆🙅𝖆—𝖇🙇都—🙅東👾
|
||||||
|
\𝖈🙅🙇東\👾京—東👾𝖈𝖈💁𝖈💁𝖈𝖆—\\都東𝖆💁東𝖆𝖆都都𝖈🙇𝖇𝖆東都🙅—都𝖆
|
||||||
|
\🙇🙅𝖇🙅🙅𝖇👾—都\𝖇👾🙅京🙅𝖇💁𝖇都🙇\🙇🙅京都𝖈\—𝖆𝖇💁🙅🙅𝖈🙅都🙇\東
|
||||||
|
𝖆𝖈𝖈𝖆\𝖇都𝖆都\𝖈京𝖆𝖈𝖇𝖇𝖇💁👾🙅👾都👾\𝖈𝖇𝖈\\東👾都𝖈𝖇🙇👾京💁京🙅
|
||||||
|
𝖈東都🙅🙇——\👾𝖈𝖈東\—💁𝖇𝖈🙇👾—都🙅𝖈—𝖆💁🙅💁東👾𝖇𝖇𝖈都𝖆東𝖈𝖈京🙅
|
||||||
|
京🙇💁👾🙅👾𝖆𝖆𝖆都\\🙇🙇𝖈都👾都👾東𝖈🙇💁—🙇👾——𝖈𝖇🙅京—👾都💁🙇🙇𝖈\
|
||||||
|
𝖇都👾💁東京💁💁🙇🙇京🙅都👾👾👾𝖇𝖆𝖈—𝖆𝖆\𝖈💁—🙇🙅都𝖆𝖇𝖆—🙇𝖇𝖇東🙅\\
|
||||||
|
\東𝖈🙇𝖈𝖆𝖆𝖇💁👾—東𝖆—\𝖈\\\東\🙇🙇🙅𝖈都—𝖆👾—𝖇—🙇\𝖇都京𝖈東🙇
|
||||||
|
🙇京\——𝖆💁🙅—東💁𝖇𝖆𝖆𝖆𝖈🙇東🙇💁京💁𝖇𝖇—都都𝖇💁🙅\🙅𝖆東👾京京𝖆東\
|
||||||
|
👾東𝖆𝖇東—東都💁都𝖆\東𝖆京👾都🙅\𝖈𝖇—都👾都𝖇\東💁🙇💁—🙅都𝖆𝖆𝖆東\—
|
||||||
|
京🙇京京京東—💁\💁🙇𝖇京💁💁都都👾\京𝖈🙅京京京👾🙅👾👾京——👾京𝖈𝖇🙅𝖆𝖆👾
|
||||||
|
𝖈\東𝖆\🙇𝖇𝖆💁𝖈𝖈\🙇𝖈👾京𝖈𝖈𝖆🙅🙇🙅都🙅京𝖇東👾🙇🙇🙇💁🙇京京🙇—👾都👾
|
||||||
|
𝖆京𝖈都京👾—💁𝖆東𝖆\𝖆💁京👾\都💁都💁🙅東🙇𝖈京京🙇都🙅𝖆𝖈———💁👾🙅🙅𝖇
|
||||||
|
🙇💁𝖆𝖇𝖈𝖇👾都都京—𝖆💁🙇—\京都𝖆𝖇🙇\東東\🙇👾—𝖈𝖈🙅京東𝖆𝖇💁💁𝖇🙅𝖆
|
||||||
|
👾💁𝖆—👾🙅🙅𝖇\𝖈—🙅\🙇𝖈🙅𝖇東🙇👾👾𝖈👾𝖈\京東\\京𝖈🙅🙅🙇𝖇京𝖈𝖈\都
|
||||||
|
東𝖇💁\🙅—🙇東𝖆\💁💁𝖆𝖈💁—東京\\🙅\𝖈👾👾京京\👾\東𝖇𝖇𝖇👾—𝖇𝖆𝖈東
|
||||||
|
🙅東𝖈\👾𝖈💁𝖈𝖆——都\都—\🙇𝖇𝖈👾𝖇京京💁都𝖈🙇👾𝖈京𝖈🙅—都💁\🙇都👾京
|
||||||
|
🙇🙇𝖇𝖆💁🙇🙅👾都👾\👾𝖈💁💁💁—👾——𝖆\💁💁都京東𝖇京𝖆—🙇京\👾𝖇𝖈𝖆💁京
|
||||||
|
—🙅都東京—東🙅—𝖈\京🙇𝖇🙇𝖈💁𝖆𝖇👾𝖇🙇𝖇𝖇👾🙇𝖈🙇💁都👾💁東🙇東𝖆都𝖆京𝖇
|
||||||
|
𝖆東🙇東—𝖈𝖆—京都💁𝖈💁𝖆🙇東🙅京都都👾👾🙇\都🙅\𝖆\🙇—𝖆🙇—🙇京京𝖈京都
|
||||||
|
東𝖆東🙇🙇𝖇🙇💁🙅👾𝖇💁東💁🙇🙅💁𝖈💁𝖆𝖈京💁🙇𝖆東都🙇都🙅𝖆—🙇𝖇🙇東京💁\🙅
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
🙅𝖆👾\都都𝖇🙅𝖆𝖈\𝖇—🙇\𝖆💁🙇東都東🙇\💁👾𝖆𝖆𝖆𝖇—東東京🙇𝖆𝖈💁🙇🙅🙅
|
||||||
|
都𝖆🙅\👾𝖈𝖈東🙇\都東𝖇𝖆東都\👾👾東東都👾👾\💁\𝖇𝖈𝖆🙇東都都\都👾💁🙇𝖈
|
||||||
|
👾\🙅東東京東都🙅—𝖇京京🙇💁—👾𝖇𝖇𝖇都👾東𝖆京👾京👾🙇都\𝖆—東東—京👾京東
|
||||||
|
—🙅都—𝖈𝖇—\\𝖆都💁💁🙇𝖈𝖈🙅—都\🙇𝖇💁𝖈𝖇\🙇𝖆💁👾京𝖆都都🙅—𝖈𝖇都𝖇
|
||||||
|
𝖇都\𝖈都👾💁𝖈🙇京👾京—𝖆𝖆🙅京𝖈\𝖇—京🙅💁𝖈—都\京都東東𝖆𝖇𝖇🙅\👾京🙅
|
||||||
|
東🙅\都𝖆—👾💁𝖈都🙅東—𝖆🙇𝖆🙇𝖈🙅京東𝖇𝖇🙅都𝖈東👾東🙇🙇🙇👾𝖆🙇👾—東—東
|
||||||
|
𝖆京都東🙅都𝖈🙇都\東🙅🙅👾𝖇𝖇👾𝖇👾👾👾京\—𝖇—🙅\𝖆𝖆京𝖆💁🙅京東𝖆🙇—💁
|
||||||
|
都東東🙇都👾𝖈𝖈𝖆𝖈👾東都💁京—𝖈都東🙇𝖈—🙇𝖈都\\東京🙅𝖇—𝖈🙇東𝖆𝖈東京👾
|
||||||
|
—𝖇—💁👾都👾𝖇—𝖈東京𝖇\都𝖆\\👾都🙅𝖈—𝖈京𝖈都👾👾💁𝖇都🙅💁東京👾都東東
|
||||||
|
👾—東🙇東🙇東𝖇💁💁東京—\京𝖇東——𝖆京京🙅💁🙇💁東🙅𝖆𝖈東🙅東𝖇💁👾東\\𝖆
|
||||||
|
都🙅💁—🙅𝖈🙇𝖈👾𝖆🙇👾𝖆\東𝖆🙇𝖆𝖆🙇都🙇都京𝖈🙅—都👾👾𝖇💁🙇🙅\\🙅𝖇🙅👾
|
||||||
|
—\京東𝖇東京𝖈𝖆\京東👾🙅𝖆💁東𝖇都𝖈—東都🙇🙇—𝖈💁👾\💁—🙅💁\𝖇京𝖈🙅💁
|
||||||
|
\🙇𝖇💁都🙇京\🙇𝖈🙅都—𝖆🙇𝖇𝖈𝖇𝖇🙅🙅𝖇👾\東—🙅🙇💁京𝖇東東\𝖇💁𝖈都𝖆👾
|
||||||
|
東🙇\👾𝖇👾💁都𝖆\🙇👾𝖈👾👾東𝖆京👾東都💁🙇💁———京都京東京💁👾𝖈京💁🙇🙅𝖈
|
||||||
|
𝖈\𝖆👾東👾𝖇—京東京👾京💁東京🙅都京👾🙅𝖈京—東🙇東🙅都𝖇𝖇京都𝖇—\𝖇都🙅𝖆
|
||||||
|
𝖈👾—都東👾\—🙅𝖈\—👾🙅𝖆👾—🙇👾東都🙅—💁——京𝖇—𝖆🙇🙅👾💁𝖆都🙇🙅\𝖆
|
||||||
|
𝖇—東\𝖇𝖈𝖇𝖆都👾🙇京都🙇🙇\🙅—\🙇👾𝖇東—👾🙅𝖈🙇—東💁𝖈𝖈都都東🙅\🙇\
|
||||||
|
🙅都京京👾—👾🙅𝖈👾𝖈都東💁🙅東🙅👾🙇𝖇𝖇東𝖈𝖇𝖇👾—京𝖈東𝖈🙅京𝖇\🙅𝖇🙇—\
|
||||||
|
京💁—\\💁💁京—🙇👾💁𝖆👾🙇𝖇𝖈🙇京𝖆🙇𝖈🙇𝖇🙅𝖇𝖈𝖈都𝖈🙇𝖆𝖈—𝖈都𝖇京都💁
|
||||||
|
🙇\𝖈—𝖆東京都🙇\\—京𝖇𝖈𝖈🙇👾東🙅🙅—𝖆—京𝖈東\都𝖆🙅𝖆—𝖇🙇都—🙅東👾
|
||||||
|
\𝖈🙅🙇東\👾京—東👾𝖈𝖈💁𝖈💁𝖈𝖆—\\都東𝖆💁東𝖆𝖆都都𝖈🙇𝖇𝖆東都🙅—都𝖆
|
||||||
|
\🙇🙅𝖇🙅🙅𝖇👾—都\𝖇👾🙅京🙅𝖇💁𝖇都🙇\🙇🙅京都𝖈\—𝖆𝖇💁🙅🙅𝖈🙅都🙇\東
|
||||||
|
𝖆𝖈𝖈𝖆\𝖇都𝖆都\𝖈京𝖆𝖈𝖇𝖇𝖇💁👾🙅👾都👾\𝖈𝖇𝖈\\東👾都𝖈𝖇🙇👾京💁京🙅
|
||||||
|
𝖈東都🙅🙇——\👾𝖈𝖈東\—💁𝖇𝖈🙇👾—都🙅𝖈—𝖆💁🙅💁東👾𝖇𝖇𝖈都𝖆東𝖈𝖈京🙅
|
||||||
|
京🙇💁👾🙅👾𝖆𝖆𝖆都\\🙇🙇𝖈都👾都👾東𝖈🙇💁—🙇👾——𝖈𝖇🙅京—👾都💁🙇🙇𝖈\
|
||||||
|
𝖇都👾💁東京💁💁🙇🙇京🙅都👾👾👾𝖇𝖆𝖈—𝖆𝖆\𝖈💁—🙇🙅都𝖆𝖇𝖆—🙇𝖇𝖇東🙅\\
|
||||||
|
\東𝖈🙇𝖈𝖆𝖆𝖇💁👾—東𝖆—\𝖈\\\東\🙇🙇🙅𝖈都—𝖆👾—𝖇—🙇\𝖇都京𝖈東🙇
|
||||||
|
🙇京\——𝖆💁🙅—東💁𝖇𝖆𝖆𝖆𝖈🙇東🙇💁京💁𝖇𝖇—都都𝖇💁🙅\🙅𝖆東👾京京𝖆東\
|
||||||
|
👾東𝖆𝖇東—東都💁都𝖆\東𝖆京👾都🙅\𝖈𝖇—都👾都𝖇\東💁🙇💁—🙅都𝖆𝖆𝖆東\—
|
||||||
|
京🙇京京京東—💁\💁🙇𝖇京💁💁都都👾\京𝖈🙅京京京👾🙅👾👾京——👾京𝖈𝖇🙅𝖆𝖆👾
|
||||||
|
𝖈\東𝖆\🙇𝖇𝖆💁𝖈𝖈\🙇𝖈👾京𝖈𝖈𝖆🙅🙇🙅都🙅京𝖇東👾🙇🙇🙇💁🙇京京🙇—👾都👾
|
||||||
|
𝖆京𝖈都京👾—💁𝖆東𝖆\𝖆💁京👾\都💁都💁🙅東🙇𝖈京京🙇都🙅𝖆𝖈———💁👾🙅🙅𝖇
|
||||||
|
🙇💁𝖆𝖇𝖈𝖇👾都都京—𝖆💁🙇—\京都𝖆𝖇🙇\東東\🙇👾—𝖈𝖈🙅京東𝖆𝖇💁💁𝖇🙅𝖆
|
||||||
|
👾💁𝖆—👾🙅🙅𝖇\𝖈—🙅\🙇𝖈🙅𝖇東🙇👾👾𝖈👾𝖈\京東\\京𝖈🙅🙅🙇𝖇京𝖈𝖈\都
|
||||||
|
東𝖇💁\🙅—🙇東𝖆\💁💁𝖆𝖈💁—東京\\🙅\𝖈👾👾京京\👾\東𝖇𝖇𝖇👾—𝖇𝖆𝖈東
|
||||||
|
🙅東𝖈\👾𝖈💁𝖈𝖆——都\都—\🙇𝖇𝖈👾𝖇京京💁都𝖈🙇👾𝖈京𝖈🙅—都💁\🙇都👾京
|
||||||
|
🙇🙇𝖇𝖆💁🙇🙅👾都👾\👾𝖈💁💁💁—👾——𝖆\💁💁都京東𝖇京𝖆—🙇京\👾𝖇𝖈𝖆💁京
|
||||||
|
—🙅都東京—東🙅—𝖈\京🙇𝖇🙇𝖈💁𝖆𝖇👾𝖇🙇𝖇𝖇👾🙇𝖈🙇💁都👾💁東🙇東𝖆都𝖆京𝖇
|
||||||
|
𝖆東🙇東—𝖈𝖆—京都💁𝖈💁𝖆🙇東🙅京都都👾👾🙇\都🙅\𝖆\🙇—𝖆🙇—🙇京京𝖈京都
|
||||||
|
東𝖆東🙇🙇𝖇🙇💁🙅👾𝖇💁東💁🙇🙅💁𝖈💁𝖆𝖈京💁🙇𝖆東都🙇都🙅𝖆—🙇𝖇🙇東京💁\🙅
|
||||||
+1
-1
@@ -25,7 +25,7 @@ async function selectStampAndUpload(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function assertUploadedContentAtPath(swarmHash, path, contentType) {
|
async function assertUploadedContentAtPath(swarmHash, path, contentType) {
|
||||||
const response = await axios.get(`http://localhost:1633/bzz/${swarmHash}/${path}`)
|
const response = await axios.get(`http://localhost:1633/bzz/${swarmHash}/${encodeURI(path)}`)
|
||||||
|
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
throw new Error(`Expected 200 OK, got ${response.status}`)
|
throw new Error(`Expected 200 OK, got ${response.status}`)
|
||||||
|
|||||||
+11
-1
@@ -7,10 +7,20 @@ const { testImageFileUpload } = require('./test-case/ImageFileUpload')
|
|||||||
const { testTextFileUpload } = require('./test-case/TextFileUpload')
|
const { testTextFileUpload } = require('./test-case/TextFileUpload')
|
||||||
const { testWebsiteUpload } = require('./test-case/WebsiteUpload')
|
const { testWebsiteUpload } = require('./test-case/WebsiteUpload')
|
||||||
const { testReactWebsiteUpload } = require('./test-case/ReactWebsiteUpload')
|
const { testReactWebsiteUpload } = require('./test-case/ReactWebsiteUpload')
|
||||||
|
const { testUnicodeFileUpload } = require('./test-case/UnicodeFileUpload')
|
||||||
|
const { testUnicodeWebsiteUpload } = require('./test-case/UnicodeWebsiteUpload')
|
||||||
|
|
||||||
const VIEWPORT = { width: 1366, height: 768 }
|
const VIEWPORT = { width: 1366, height: 768 }
|
||||||
|
|
||||||
const testCases = [testTextFileUpload, testImageFileUpload, testFolderUpload, testWebsiteUpload, testReactWebsiteUpload]
|
const testCases = [
|
||||||
|
testUnicodeFileUpload,
|
||||||
|
testUnicodeWebsiteUpload,
|
||||||
|
testTextFileUpload,
|
||||||
|
testImageFileUpload,
|
||||||
|
testFolderUpload,
|
||||||
|
testWebsiteUpload,
|
||||||
|
testReactWebsiteUpload,
|
||||||
|
]
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const server = prepareServer()
|
const server = prepareServer()
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
const puppeteer = require('puppeteer')
|
||||||
|
const { selectStampAndUpload } = require('../helpers')
|
||||||
|
const { Assert, Click } = require('../library')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {puppeteer.Page} page Puppeteer Page object returned by `browser.newPage()`
|
||||||
|
*/
|
||||||
|
async function testUnicodeFileUpload(page) {
|
||||||
|
await Click.elementWithText(page, 'a', 'Files')
|
||||||
|
await Click.elementWithTextAndUpload(page, 'button', 'Add File', 'test-data/—𝖆𝖆🙇\\𝖈𝖈.txt')
|
||||||
|
await assertUploadPreview(page)
|
||||||
|
await selectStampAndUpload(page)
|
||||||
|
await assertDownloadPreview(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {puppeteer.Page} page Puppeteer Page object returned by `browser.newPage()`
|
||||||
|
*/
|
||||||
|
async function assertUploadPreview(page) {
|
||||||
|
await Assert.elementWithTextExists(page, 'p', 'Filename: —𝖆𝖆🙇\\𝖈𝖈.txt')
|
||||||
|
await Assert.elementWithTextExists(page, 'p', 'Kind: text/plain')
|
||||||
|
await Assert.elementWithTextExists(page, 'p', 'Size: 5.51 kB')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {puppeteer.Page} page Puppeteer Page object returned by `browser.newPage()`
|
||||||
|
*/
|
||||||
|
async function assertDownloadPreview(page) {
|
||||||
|
assertUploadPreview(page)
|
||||||
|
await Assert.elementWithTextExists(page, 'p', 'Swarm Hash: 30fbf1d2[…]ba400e86')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { testUnicodeFileUpload }
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
const puppeteer = require('puppeteer')
|
||||||
|
const { selectStampAndUpload, assertUploadedContentAtPath } = require('../helpers')
|
||||||
|
const { Click } = require('../library')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {puppeteer.Page} page Puppeteer Page object returned by `browser.newPage()`
|
||||||
|
*/
|
||||||
|
async function testUnicodeWebsiteUpload(page) {
|
||||||
|
await Click.elementWithText(page, 'a', 'Files')
|
||||||
|
await Click.elementWithTextAndUpload(page, 'button', 'Add Website', 'test-data/test-unicode-website—𝖆𝖆🙇\\𝖈𝖈')
|
||||||
|
const swarmHash = await selectStampAndUpload(page)
|
||||||
|
await assertUploadedContentAtPath(swarmHash, 'index.html', 'text/html; charset=utf-8')
|
||||||
|
await assertUploadedContentAtPath(swarmHash, '—𝖆𝖆🙇/𝖈𝖈.txt', 'text/plain; charset=utf-8')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { testUnicodeWebsiteUpload }
|
||||||
Reference in New Issue
Block a user