import * as dotenv from "dotenv";
import chai from "chai";
import * as _ from "lodash";
const chaiHttp = require("chai-http");

chai.use(chaiHttp);

const should = chai.should();

dotenv.config({ path: __dirname + "/../../cloud/.env" });

import * as CloudTestUtils from "../utils/TestUtils.Cloud";
import * as QueueTestProxy from "../utils/QueueTestProxy";
import { Cloud } from "@bigscreen/cloud/src/Cloud";
import * as Models from "@bigscreen/cloud/src/Models";
import CloudApiServer from "@bigscreen/cloud/cloud_api";

const cloudApiKey = "f4czwPZdYidGTcWRbhcWAcFiTaDYhYDraDsjYLYO2YXd4LxQqpMpbcdmyxZEBKNZ";

describe("DELETE ME - test social profile cache.", () => {
    const VERSION = "0.9.0";
    let adminUser: CloudSchemas.BigscreenUser;
    let sender : CloudSchemas.BigscreenUser;

    before(async () => {
        await Cloud.initialize();
        await Cloud.flushAll();
        adminUser = await CloudTestUtils.getAdminUser();
        sender = await CloudTestUtils.getRandomTestUser(VERSION);
        await QueueTestProxy.startTestQueue();
    });

    it("Add all users to the active users list", async () => {
        return Cloud.addBigscreenUser(sender);
    });

    it(`DELETE ME - test profile cache.`, async () => {
        // First request should return 20 items and a cursor.
        let res = await chai.request(CloudApiServer)
            .get("/social/test_profile_cache")
            .set("Authorization", `Bearer ${cloudApiKey}`)
            .set("x-access-token", sender.accessToken);
        res.should.have.status(200);
    });

    it("disconnect user(s)", async () => {
        await Cloud.removeBigscreenUser(sender);
    });
    
    after(async() => {
        await QueueTestProxy.stopTestQueue();
    });
});
