"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const server_commands_1 = require("../../../../shared/server-commands");
describe('Test bulk API validators', function () {
    let server;
    let userAccessToken;
    before(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.timeout(120000);
            server = yield (0, server_commands_1.createSingleServer)(1);
            yield (0, server_commands_1.setAccessTokensToServers)([server]);
            const user = { username: 'user1', password: 'password' };
            yield server.users.create({ username: user.username, password: user.password });
            userAccessToken = yield server.login.getAccessToken(user);
        });
    });
    describe('When removing comments of', function () {
        const path = '/api/v1/bulk/remove-comments-of';
        it('Should fail with an unauthenticated user', function () {
            return tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield (0, server_commands_1.makePostBodyRequest)({
                    url: server.url,
                    path,
                    fields: { accountName: 'user1', scope: 'my-videos' },
                    expectedStatus: 401
                });
            });
        });
        it('Should fail with an unknown account', function () {
            return tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield (0, server_commands_1.makePostBodyRequest)({
                    url: server.url,
                    token: server.accessToken,
                    path,
                    fields: { accountName: 'user2', scope: 'my-videos' },
                    expectedStatus: 404
                });
            });
        });
        it('Should fail with an invalid scope', function () {
            return tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield (0, server_commands_1.makePostBodyRequest)({
                    url: server.url,
                    token: server.accessToken,
                    path,
                    fields: { accountName: 'user1', scope: 'my-videoss' },
                    expectedStatus: 400
                });
            });
        });
        it('Should fail to delete comments of the instance without the appropriate rights', function () {
            return tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield (0, server_commands_1.makePostBodyRequest)({
                    url: server.url,
                    token: userAccessToken,
                    path,
                    fields: { accountName: 'user1', scope: 'instance' },
                    expectedStatus: 403
                });
            });
        });
        it('Should succeed with the correct params', function () {
            return tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield (0, server_commands_1.makePostBodyRequest)({
                    url: server.url,
                    token: server.accessToken,
                    path,
                    fields: { accountName: 'user1', scope: 'instance' },
                    expectedStatus: 204
                });
            });
        });
    });
    after(function () {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            yield (0, server_commands_1.cleanupTests)([server]);
        });
    });
});
//# sourceMappingURL=bulk.js.map