"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const chai_1 = require("chai");
const server_commands_1 = require("../../../../shared/server-commands");
describe('Test video description', function () {
    let servers = [];
    let videoUUID = '';
    let videoId;
    const longDescription = 'my super description for server 1'.repeat(50);
    const truncatedDescription = 'my super description for server 1'.repeat(7) + 'my super descrip...';
    before(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(40000);
            servers = yield (0, server_commands_1.createMultipleServers)(2);
            yield (0, server_commands_1.setAccessTokensToServers)(servers);
            yield (0, server_commands_1.doubleFollow)(servers[0], servers[1]);
        });
    });
    it('Should upload video with long description', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(30000);
            const attributes = {
                description: longDescription
            };
            yield servers[0].videos.upload({ attributes });
            yield (0, server_commands_1.waitJobs)(servers);
            const { data } = yield servers[0].videos.list();
            videoId = data[0].id;
            videoUUID = data[0].uuid;
        });
    });
    it('Should have a truncated description on each server when listing videos', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            for (const server of servers) {
                const { data } = yield server.videos.list();
                const video = data.find(v => v.uuid === videoUUID);
                (0, chai_1.expect)(video.description).to.equal(truncatedDescription);
                (0, chai_1.expect)(video.truncatedDescription).to.equal(truncatedDescription);
            }
        });
    });
    it('Should not have a truncated description on each server when getting videos', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            for (const server of servers) {
                const video = yield server.videos.get({ id: videoUUID });
                (0, chai_1.expect)(video.description).to.equal(longDescription);
                (0, chai_1.expect)(video.truncatedDescription).to.equal(truncatedDescription);
            }
        });
    });
    it('Should fetch long description on each server', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            for (const server of servers) {
                const video = yield server.videos.get({ id: videoUUID });
                const { description } = yield server.videos.getDescription({ descriptionPath: video.descriptionPath });
                (0, chai_1.expect)(description).to.equal(longDescription);
            }
        });
    });
    it('Should update with a short description', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(10000);
            const attributes = {
                description: 'short description'
            };
            yield servers[0].videos.update({ id: videoId, attributes });
            yield (0, server_commands_1.waitJobs)(servers);
        });
    });
    it('Should have a small description on each server', function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            for (const server of servers) {
                const video = yield server.videos.get({ id: videoUUID });
                (0, chai_1.expect)(video.description).to.equal('short description');
                const { description } = yield server.videos.getDescription({ descriptionPath: video.descriptionPath });
                (0, chai_1.expect)(description).to.equal('short description');
            }
        });
    });
    after(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield (0, server_commands_1.cleanupTests)(servers);
        });
    });
});
//# sourceMappingURL=video-description.js.map