aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/files/FileSystemAPIUtils.ts
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-03-27 17:14:55 +0100
committerskjnldsv <skjnldsv@protonmail.com>2024-04-04 13:33:10 +0200
commitaacc7abccc8101e0603ba9664ca513563b9b3fd6 (patch)
tree47acfe948b3814510f3831ce8f39de3028b3cd42 /cypress/e2e/files/FileSystemAPIUtils.ts
parent15bf34dac8f66e1d034590338b49cfa4ad4ff37e (diff)
downloadnextcloud-server-aacc7abccc8101e0603ba9664ca513563b9b3fd6.tar.gz
nextcloud-server-aacc7abccc8101e0603ba9664ca513563b9b3fd6.zip
chore: adjusting cypress drag and drop tests
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'cypress/e2e/files/FileSystemAPIUtils.ts')
-rw-r--r--cypress/e2e/files/FileSystemAPIUtils.ts59
1 files changed, 59 insertions, 0 deletions
diff --git a/cypress/e2e/files/FileSystemAPIUtils.ts b/cypress/e2e/files/FileSystemAPIUtils.ts
new file mode 100644
index 00000000000..995aef2ced5
--- /dev/null
+++ b/cypress/e2e/files/FileSystemAPIUtils.ts
@@ -0,0 +1,59 @@
+import { basename } from 'node:path'
+
+class FileSystemEntry {
+
+ private _isFile: boolean
+ private _fullPath: string
+
+ constructor(isFile: boolean, fullPath: string) {
+ this._isFile = isFile
+ this._fullPath = fullPath
+ }
+
+ get isFile() {
+ return !!this._isFile
+ }
+
+ get isDirectory() {
+ return !this.isFile
+ }
+
+ get name() {
+ return basename(this._fullPath)
+ }
+
+}
+
+export class FileSystemFileEntry extends FileSystemEntry {
+
+ private _contents: string
+
+ constructor(fullPath: string, contents: string) {
+ super(true, fullPath)
+ this._contents = contents
+ }
+
+ file(success: (file: File) => void) {
+ success(new File([this._contents], this.name))
+ }
+
+}
+
+export class FileSystemDirectoryEntry extends FileSystemEntry {
+
+ private _entries: FileSystemEntry[]
+
+ constructor(fullPath: string, entries: FileSystemEntry[]) {
+ super(false, fullPath)
+ this._entries = entries || []
+ }
+
+ createReader() {
+ return {
+ readEntries: (success: (entries: FileSystemEntry[]) => void) => {
+ success(this._entries)
+ },
+ }
+ }
+
+}