Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

4 changes: 0 additions & 4 deletions src/app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,6 @@
"fetchingFolderContent": "Fehler beim Abrufen des Ordnerinhalts",
"togglingFavorite": "Beim Aktualisieren der Favoriten ist ein Fehler aufgetreten",
"togglingSomeFavorites": "Einige Favoriten konnten nicht aktualisiert werden",
"uploadingFolder": "Fehler beim Hochladen des Ordners",
"uploadingFile": "Fehler beim Hochladen der Datei: {{reason}}",
"uploadingItems": "Einige Elemente konnten nicht hochgeladen werden",
"downloadingFile": "Fehler beim Herunterladen der Datei: {{message}}",
"downloadingFolder": "Fehler beim Herunterladen des Ordners: {{message}}",
"movingItemInsideItself": "Du kannst einen Ordner nicht in sich selbst verschieben",
Expand Down Expand Up @@ -1355,7 +1352,6 @@
"upload-failed": "Upload fehlgeschlagen"
},
"generalErrorMessages": {
"retryUploadFailed": "Beim erneuten Hochladen ist etwas schiefgegangen. Versuche es erneut",
"retryDownloadFailed": "Etwas ist schief gelaufen beim erneuten Versuch des Downloads. Versuche den Download erneut.",
"openUploadedFileFailed": "Etwas ist schief gelaufen beim Versuch, die Datei zu öffnen",
"openUploadedFolderFailed": "Etwas ist schief gelaufen beim Versuch, zum Ordner zu navigieren"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@
"fetchingFolderContent": "Error fetching folder content",
"togglingFavorite": "There was an error updating favorites",
"togglingSomeFavorites": "Some favorites could not be updated",
"uploadingFolder": "Error uploading folder",
"uploadingFile": "Error uploading file: {{reason}}",
"uploadingItems": "Some of the elements could not be uploaded",
"downloadingFile": "Error downloading file: {{message}}",
"downloadingFolder": "Error downloading folder: {{message}}",
"movingItemInsideItself": "You can't move a folder inside itself",
Expand Down Expand Up @@ -1379,7 +1376,6 @@
"upload-failed": "Upload failed"
},
"generalErrorMessages": {
"retryUploadFailed": "Something went wrong when retrying the upload. Try uploading again",
"retryDownloadFailed": "Something went wrong while retrying the download. Please try downloading again.",
"openUploadedFileFailed": "Something went wrong while trying to open the file",
"openUploadedFolderFailed": "Something went wrong while trying to navigate to the folder"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,6 @@
"fetchingFolderContent": "Error al obtener la carpeta",
"togglingFavorite": "Hubo un error al actualizar favoritos",
"togglingSomeFavorites": "Algunos favoritos no se pudieron actualizar",
"uploadingFolder": "Error al subir la carpeta",
"uploadingFile": "Error al subir el archivo: {{reason}}",
"uploadingItems": "No se ha podido subir alguno de los elementos",
"downloadingFile": "Error descargando archivo: {{message}}",
"downloadingFolder": "Error descargando carpeta: {{message}}",
"movingItemInsideItself": "No se puede mover una carpeta dentro de sí misma",
Expand Down Expand Up @@ -1359,7 +1356,6 @@
"upload-failed": "Error al subir"
},
"generalErrorMessages": {
"retryUploadFailed": "Algo salió mal al reintentar la subida. Intenta subirlo de nuevo",
"retryDownloadFailed": "Algo salió mal al reintentar la descarga. Intenta la descarga de nuevo",
"openUploadedFileFailed": "Algo salió mal al intentar abrir el archivo",
"openUploadedFolderFailed": "Algo salió mal al intentar navegar hasta la carpeta"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,6 @@
"fetchingFolderContent": "Erreur dans l'extraction du contenu d'un dossier",
"togglingFavorite": "Une erreur s'est produite lors de la mise à jour des favoris",
"togglingSomeFavorites": "Certains favoris n'ont pas pu être mis à jour",
"uploadingFolder": "Erreur lors du téléchargement d'un dossier",
"uploadingFile": "Erreur lors du téléchargement du fichier : {{reason}}",
"uploadingItems": "Certains éléments n'ont pas pu être téléchargés",
"downloadingFile": "Erreur de téléchargement du fichier : {{message}}",
"downloadingFolder": "Erreur de téléchargement du dossier : {{message}}",
"movingItemInsideItself": "Vous ne pouvez pas déplacer un dossier à l'intérieur de lui-même",
Expand Down Expand Up @@ -1358,7 +1355,6 @@
"upload-failed": "Échec du téléchargement"
},
"generalErrorMessages": {
"retryUploadFailed": "Quelque chose s'est mal passé en réessayant de télécharger. Essayez de télécharger à nouveau",
"retryDownloadFailed": "Quelque chose s'est mal passé lors de la nouvelle tentative de téléchargement. Veuillez réessayer le téléchargement.",
"openUploadedFileFailed": "Quelque chose s'est mal passé lors de la tentative d'ouverture du fichier",
"openUploadedFolderFailed": "Quelque chose s'est mal passé lors de la tentative d'accès au dossier"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@
"fetchingFolderContent": "Errore nel recupero del contenuto della cartella",
"togglingFavorite": "Si è verificato un errore durante l'aggiornamento dei preferiti",
"togglingSomeFavorites": "Non è stato possibile aggiornare alcuni preferiti",
"uploadingFolder": "Errore nel caricamento della cartella",
"uploadingFile": "Errore nel caricamento del file: {{reason}}",
"uploadingItems": "Non è stato possibile caricare alcuni elementi",
"downloadingFile": "Errore nel download del file: {{message}}",
"downloadingFolder": "Errore nel download della cartella: {{message}}",
"movingItemInsideItself": "Non è possibile spostare una cartella al suo interno",
Expand Down Expand Up @@ -1379,7 +1376,6 @@
"upload-failed": "Caricamento fallito"
},
"generalErrorMessages": {
"retryUploadFailed": "Qualcosa è andato storto nel riprovare a caricare. Prova a caricare di nuovo",
"retryDownloadFailed": "Qualcosa è andato storto nel tentativo di ripetere il download. Riprova il download.",
"openUploadedFileFailed": "Qualcosa è andato storto nel tentativo di aprire il file",
"openUploadedFolderFailed": "Qualcosa è andato storto nel tentativo di navigare nella cartella"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,6 @@
"fetchingFolderContent": "Erro ao carregar o conteúdo da pasta",
"togglingFavorite": "Ocorreu um erro ao atualizar os favoritos",
"togglingSomeFavorites": "Não foi possível atualizar alguns favoritos",
"uploadingFolder": "Erro ao enviar a pasta",
"uploadingFile": "Erro ao enviar o arquivo: {{reason}}",
"uploadingItems": "Não foi possível enviar alguns dos elementos",
"downloadingFile": "Erro ao baixar o arquivo: {{message}}",
"downloadingFolder": "Erro ao baixar a pasta: {{message}}",
"movingItemInsideItself": "Você não pode mover uma pasta para dentro dela mesma",
Expand Down Expand Up @@ -1389,7 +1386,6 @@
"upload-failed": "Falha no envio"
},
"generalErrorMessages": {
"retryUploadFailed": "Algo deu errado ao tentar enviar novamente. Tente fazer o envio de novo",
"retryDownloadFailed": "Algo deu errado ao tentar baixar novamente. Tente fazer o download de novo.",
"openUploadedFileFailed": "Algo deu errado ao tentar abrir o arquivo",
"openUploadedFolderFailed": "Algo deu errado ao tentar navegar até a pasta"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,6 @@
"fetchingFolderContent": "Ошибка при получении содержимого папки",
"togglingFavorite": "Произошла ошибка при обновлении избранного",
"togglingSomeFavorites": "Не удалось обновить некоторые элементы избранного",
"uploadingFolder": "Ошибка при загрузке папки",
"uploadingFile": "Ошибка при загрузке файла: {{reason}}",
"uploadingItems": "Некоторые элементы не удалось загрузить",
"downloadingFile": "Ошибка при загрузке файла: {{message}}",
"downloadingFolder": "Ошибка при загрузке папки: {{message}}",
"movingItemInsideItself": "Вы не можете переместить папку внутрь самой себя",
Expand Down Expand Up @@ -1358,7 +1355,6 @@
"upload-failed": "Не удалось загрузить"
},
"generalErrorMessages": {
"retryUploadFailed": "Что-то пошло не так при повторной попытке загрузки. Попробуйте загрузить снова",
"retryDownloadFailed": "Что-то пошло не так при повторной попытке загрузки. Повторите попытку загрузки.",
"openUploadedFileFailed": "Что-то пошло не так при попытке открыть файл",
"openUploadedFolderFailed": "Что-то пошло не так при попытке перейти к папке"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@
"fetchingFolderContent": "獲取文件夾內容時出錯",
"togglingFavorite": "更新我的最愛時發生錯誤",
"togglingSomeFavorites": "部分我的最愛無法更新",
"uploadingFolder": "上傳文件夾時出錯",
"uploadingFile": "上傳文件時出錯:{{reason}}",
"uploadingItems": "部分元素無法上傳",
"downloadingFile": "下載文件時出錯:{{message}}",
"downloadingFolder": "下載文件夾時出錯:{{message}}",
"movingItemInsideItself": "您不能將文件夾移動到其內部",
Expand Down Expand Up @@ -1379,7 +1376,6 @@
"upload-failed": "上傳失敗"
},
"generalErrorMessages": {
"retryUploadFailed": "重試上傳時出現問題。請重新上傳",
"retryDownloadFailed": "重試下載時出現問題。請重新下載",
"openUploadedFileFailed": "打開檔案時出現問題",
"openUploadedFolderFailed": "打開資料夾時出現問題"
Expand Down
4 changes: 0 additions & 4 deletions src/app/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,6 @@
"fetchingFolderContent": "获取文件夹内容时出错",
"togglingFavorite": "更新收藏时出错",
"togglingSomeFavorites": "部分收藏无法更新",
"uploadingFolder": "上传文件夹时出错",
"uploadingFile": "上传文件时出错: {{reason}}",
"uploadingItems": "部分元素无法上传",
"downloadingFile": "下载文件时出错: {{message}}",
"downloadingFolder": "下载文件夹时出错: {{message}}",
"movingItemInsideItself": "您无法移动文件夹本身",
Expand Down Expand Up @@ -1379,7 +1376,6 @@
"upload-failed": "上传失败"
},
"generalErrorMessages": {
"retryUploadFailed": "重试上传时出了问题。请再次上传",
"retryDownloadFailed": "重试下载时出现问题。请重试下载",
"openUploadedFileFailed": "尝试打开文件时出现问题",
"openUploadedFolderFailed": "尝试访问文件夹时出现问题"
Expand Down
135 changes: 8 additions & 127 deletions src/app/network/RetryManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ import { describe, it, test, expect, vi, beforeEach } from 'vitest';
import RetryManager, { RetryableTask, RetryableTaskStatus, RetryableTaskType } from './RetryManager';

describe('RetryManager', () => {
const sampleTask: RetryableTask = { taskId: 'task1', type: RetryableTaskType.Upload, params: {} };
const sampleTask: RetryableTask = { taskId: 'task1', type: RetryableTaskType.Download, params: {} };
const anotherTask: RetryableTask = { taskId: 'task2', type: RetryableTaskType.Download, params: {} };

beforeEach(() => {
RetryManager.clearTasks();
});

it('should add a task with failed status', () => {
RetryManager.addTask(sampleTask);
const tasks = RetryManager.getTasks();
expect(tasks).toHaveLength(1);
expect(tasks[0]).toEqual({ ...sampleTask, status: RetryableTaskStatus.Failed });
});

it('should add multiple tasks with failed status', () => {
RetryManager.addTasks([sampleTask, anotherTask]);
const tasks = RetryManager.getTasks();
Expand All @@ -35,14 +28,14 @@ describe('RetryManager', () => {
});

it('should change the status of a task', () => {
RetryManager.addTask(sampleTask);
RetryManager.addTasks([sampleTask]);
RetryManager.changeStatus('task1', RetryableTaskStatus.Retrying);
const tasks = RetryManager.getTasks();
expect(tasks[0].status).toBe(RetryableTaskStatus.Retrying);
});

it('should not change status if taskId does not exist', () => {
RetryManager.addTask(sampleTask);
RetryManager.addTasks([sampleTask]);
RetryManager.changeStatus('invalidTask', RetryableTaskStatus.Retrying);
const tasks = RetryManager.getTasks();
expect(tasks[0].status).toBe(RetryableTaskStatus.Failed);
Expand Down Expand Up @@ -73,98 +66,31 @@ describe('RetryManager', () => {
expect(getDownloadStatuses()).toEqual([RetryableTaskStatus.Retrying, RetryableTaskStatus.Retrying]);
});

it('should remove a task by taskId', () => {
RetryManager.addTasks([sampleTask, anotherTask]);
RetryManager.removeTask('task1');
const tasks = RetryManager.getTasks();
expect(tasks).toHaveLength(1);
expect(tasks[0].taskId).toBe('task2');
});

describe('when removing the entries of a related task', () => {
const buildTask = (taskId: string, relatedTaskId?: string): RetryableTask => ({
taskId,
type: RetryableTaskType.Upload,
params: relatedTaskId ? { relatedTaskId } : {},
});
const remainingTaskIds = () => RetryManager.getTasks().map((task) => task.taskId);

beforeEach(() => {
RetryManager.addTasks([
buildTask('folder-file-a', 'folder'),
buildTask('folder-file-b', 'folder'),
buildTask('folder'),
buildTask('other-folder-file', 'other-folder'),
buildTask('standalone-file'),
]);
});

test('when entries belong to the task, then they are removed and the other entries are kept', () => {
RetryManager.removeTasksOfRelatedTask('folder');

expect(remainingTaskIds()).toEqual(['other-folder-file', 'standalone-file']);
});

test('when an entry has no related task and its own id matches, then it is removed', () => {
RetryManager.removeTasksOfRelatedTask('standalone-file');

expect(remainingTaskIds()).toEqual(['folder-file-a', 'folder-file-b', 'folder', 'other-folder-file']);
});

test('when an entry is re-added without a related task, then it keeps the replaced entry related task', () => {
RetryManager.addTasks([buildTask('folder-file-a')]);

RetryManager.removeTasksOfRelatedTask('folder');

expect(remainingTaskIds()).toEqual(['other-folder-file', 'standalone-file']);
});

test('when entries are removed, then listeners are notified', () => {
const listener = vi.fn();
RetryManager.subscribe(listener);

RetryManager.removeTasksOfRelatedTask('folder');

expect(listener).toHaveBeenCalledTimes(1);
RetryManager.unsubscribe(listener);
});
});

it('should clear all tasks', () => {
RetryManager.addTasks([sampleTask, anotherTask]);
RetryManager.clearTasks();
const tasks = RetryManager.getTasks();
expect(tasks).toHaveLength(0);
});

it('should return true if a task is being retried', () => {
RetryManager.addTask(sampleTask);
expect(RetryManager.isRetryingTask('task1')).toBe(true);
});

it('should return false if a task is not being retried', () => {
RetryManager.addTask(sampleTask);
expect(RetryManager.isRetryingTask('nonExistentTask')).toBe(false);
});

it('should notify listeners on state change', () => {
const listener = vi.fn();
RetryManager.subscribe(listener);
RetryManager.addTask(sampleTask);
RetryManager.addTasks([sampleTask]);
expect(listener).toHaveBeenCalledTimes(1);

RetryManager.changeStatus('task1', RetryableTaskStatus.Retrying);
expect(listener).toHaveBeenCalledTimes(2);

RetryManager.removeTask('task1');
RetryManager.clearTasks();
expect(listener).toHaveBeenCalledTimes(3);
});

it('should unsubscribe listeners correctly', () => {
const listener = vi.fn();
RetryManager.subscribe(listener);
RetryManager.unsubscribe(listener);
RetryManager.addTask(sampleTask);
RetryManager.addTasks([sampleTask]);
expect(listener).not.toHaveBeenCalled();
});

Expand All @@ -174,58 +100,13 @@ describe('RetryManager', () => {
RetryManager.subscribe(listener1);
RetryManager.subscribe(listener2);

RetryManager.addTask(sampleTask);
RetryManager.addTasks([sampleTask]);
expect(listener1).toHaveBeenCalledTimes(1);
expect(listener2).toHaveBeenCalledTimes(1);

RetryManager.unsubscribe(listener1);
RetryManager.addTask(anotherTask);
RetryManager.addTasks([anotherTask]);
expect(listener1).toHaveBeenCalledTimes(1);
expect(listener2).toHaveBeenCalledTimes(2);
});

it('should return all tasks if no type is specified', () => {
RetryManager.addTasks([
{ taskId: 'task1', type: RetryableTaskType.Upload, params: {} },
{ taskId: 'task2', type: RetryableTaskType.Download, params: {} },
]);

const tasks = RetryManager.getTasks();
expect(tasks).toHaveLength(2);
expect(tasks).toEqual(
expect.arrayContaining([
expect.objectContaining({ taskId: 'task1', type: RetryableTaskType.Upload }),
expect.objectContaining({ taskId: 'task2', type: RetryableTaskType.Download }),
]),
);
});

it('should return only upload tasks when type is upload', () => {
RetryManager.addTasks([
{ taskId: 'task1', type: RetryableTaskType.Upload, params: {} },
{ taskId: 'task2', type: RetryableTaskType.Download, params: {} },
]);

const tasks = RetryManager.getTasks(RetryableTaskType.Upload);
expect(tasks).toHaveLength(1);
expect(tasks[0]).toEqual(expect.objectContaining({ taskId: 'task1', type: RetryableTaskType.Upload }));
});

it('should return only download tasks when type is download', () => {
RetryManager.addTasks([
{ taskId: 'task1', type: RetryableTaskType.Upload, params: {} },
{ taskId: 'task2', type: RetryableTaskType.Download, params: {} },
]);

const tasks = RetryManager.getTasks(RetryableTaskType.Download);
expect(tasks).toHaveLength(1);
expect(tasks[0]).toEqual(expect.objectContaining({ taskId: 'task2', type: RetryableTaskType.Download }));
});

it('should return an empty array if no tasks match the specified type', () => {
RetryManager.addTask({ taskId: 'task1', type: RetryableTaskType.Upload, params: {} });

const tasks = RetryManager.getTasks(RetryableTaskType.Download);
expect(tasks).toHaveLength(0);
});
});
Loading
Loading