From 304bd1e77a5442f614aacd2b35f330777118b2cd Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Mon, 19 Oct 2026 15:32:53 -0700 Subject: merge with upstream https://github.com/RblSb/SyncTube --- test/tests/TestServer.hx | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'test/tests/TestServer.hx') diff --git a/test/tests/TestServer.hx b/test/tests/TestServer.hx index 2d0b71d..2bd4a3a 100644 --- a/test/tests/TestServer.hx +++ b/test/tests/TestServer.hx @@ -1,5 +1,6 @@ package test.tests; +import Types.ProgressType; import Types.WsEvent; import Types.WsEventType; import haxe.Json; @@ -19,6 +20,7 @@ class TestServer extends Test { @:timeout(500) function testBadRequests(async:Async) { final server = new Main({loadState: false}); + server.config.gatePassword = ""; server.onServerInited = () -> { final url = 'http://${server.localIp}:${server.port}'; request('$url/你好,世界!@$^&*)_+-=', data -> { @@ -52,6 +54,66 @@ class TestServer extends Test { return ~/\r?\n/g.split(text); } + @:timeout(2000) + function testIncompleteUpload(async:Async) { + final server = new Main({loadState: false}); + server.onServerInited = () -> { + final client = new FakeClient(server.localIp, server.port); + final url = "/cache/upload-test.mp4"; + client.message().then(data -> { + Assert.equals(Connected, data.type); + client.name = data.connected.clientName; + return client.send({ + type: AddVideo, + addVideo: { + item: { + url: url, + title: "upload", + author: "", + duration: 30, + isTemp: false, + playerType: RawType, + doCache: false, + isIncomplete: true + }, + atEnd: true + } + }); + }).then(data -> { + Assert.equals(AddVideo, data.type); + Assert.isTrue(data.addVideo.item.isIncomplete == true); + Assert.equals(1, server.videoList.length); + // uploads stream while incomplete, so they stay playable + Assert.isTrue(server.videoList.getItem(0).isPlayable()); + return client.send({ + type: Progress, + progress: { + type: Uploading, + ratio: 0.5, + url: url + } + }); + }).then(data -> { + Assert.equals(Progress, data.type); + Assert.equals(ProgressType.Uploading, data.progress.type); + Assert.equals(0.5, data.progress.ratio); + return client.send({ + type: Progress, + progress: { + type: Completed, + ratio: 1, + url: url + } + }); + }).then(data -> { + Assert.equals(Progress, data.type); + Assert.equals(ProgressType.Completed, data.progress.type); + Assert.isFalse(server.videoList.getItem(0).isIncomplete == true); + async.done(); + }); + } + } + function request(url:String, onComplete:(data:String) -> Void):Void { Http.get(url, r -> { r.setEncoding("utf8"); -- cgit v1.2.3