migrate angular 21 tests

This commit is contained in:
2026-03-09 23:25:11 +01:00
parent bb08e46b0c
commit 0d0873730a
24 changed files with 924 additions and 109 deletions

View File

@@ -1,4 +1,4 @@
import {Injectable, inject} from '@angular/core';
import {EnvironmentInjector, Injectable, inject, runInInjectionContext} from '@angular/core';
import {Upload} from './upload';
import {FileDataService} from './file-data.service';
import {ref, Storage, uploadBytesResumable} from '@angular/fire/storage';
@@ -11,14 +11,19 @@ import {FileServer} from './fileServer';
export class UploadService extends FileBase {
private fileDataService = inject(FileDataService);
private storage = inject(Storage);
private environmentInjector = inject(EnvironmentInjector);
public pushUpload(songId: string, upload: Upload): void {
const directory = this.directory(songId);
const filePath = `${directory}/${upload.file.name}`;
upload.path = directory;
const storageRef = ref(this.storage, filePath);
const task = uploadBytesResumable(storageRef, upload.file);
const {task} = runInInjectionContext(this.environmentInjector, () => {
const storageRef = ref(this.storage, filePath);
return {
task: uploadBytesResumable(storageRef, upload.file),
};
});
task.on(
'state_changed',