describe('The deleted player page ', function () {

    const tribe = {
        _id: monk.id(),
        id: 'delete_me',
        name: 'Change Me'
    };
    const player1 = {_id: monk.id(), tribe: tribe.id, name: "player1", isDeleted: true};
    const players = [player1];

    beforeAll(async function () {
        await tribeCollection.drop();
        await tribeCollection.insert(tribe);
        await e2eHelp.authorizeUserForTribes([tribe.id]);
        await browser.get(`${hostName}/test-login?username=${e2eHelp.userEmail}&password="******"`);
        await playersCollection.drop();
        await playersCollection.insert(players);
    });

    afterAll(async function () {
        await tribeCollection.remove({id: tribe.id}, false);
        await playersCollection.drop();
    });

    e2eHelp.afterEachAssertLogsAreEmpty();

    it('will show the player data', async function () {
        await browser.setLocation(`/${tribe.id}/retired-player/${player1._id}`);

        expect(await deletedPlayerPage.playerNameTextField.getAttribute('value'))
            .toBe(player1.name)
    })

});
Example #2
0
    describe("GET", function () {
        let expectedPins = [
            {_id: monk.id(), name: '1', tribe: tribeId},
            {_id: monk.id(), name: '2', tribe: tribeId},
            {_id: monk.id(), name: '3', tribe: tribeId}
        ];

        beforeEach(function (done) {
            pinCollection.remove({tribe: tribeId})
                .then(function () {
                    return pinCollection.insert(expectedPins)
                })
                .then(done, done.fail);
        });

        afterEach(function (done) {
            pinCollection.remove({tribe: tribeId})
                .then(done, done.fail);
        });

        it('will return all available pins on tribe.', function (done) {
            agent.get(path)
                .expect(200)
                .expect('Content-Type', /json/)
                .then(function (response) {
                    expect(clean(response.body)).toEqual(clean(expectedPins));
                })
                .then(done, done.fail);
        });

        it('will return error when tribe is not available.', async function () {
            await agent.get(badTribePath)
                .expect(404)
        });
    });
Example #3
0
        beforeAll(async function () {
            const pairAssignmentSet1 = new PairAssignmentDocument(new Date().toISOString(), [[
                {
                    name: 'Ollie',
                    _id: monk.id()
                },
                {
                    name: 'Speedy',
                    _id: monk.id()
                }
            ]]);
            const pairAssignmentSet2 = new PairAssignmentDocument(new Date().toISOString(), [[
                {name: 'Arthur', _id: monk.id()},
                {name: 'Garth', _id: monk.id()}
            ]]);

            const apiGuy = await ApiGuy.new();
            await apiGuy.postTribe(tribe);
            await Promise.all([
                e2eHelp.authorizeUserForTribes([tribe.id]),
                apiGuy.postPairAssignmentSet(tribe.id, pairAssignmentSet1),
                apiGuy.postPairAssignmentSet(tribe.id, pairAssignmentSet2)
            ]);

            await browser.waitForAngular();

            await browser.setLocation(`/${tribe.id}/history`);
            await browser.wait(() => element(By.id('history-view')).isPresent(), 2000)
        });
describe('The retired players page', function () {

    const tribe = {
        id: 'graveyard',
        name: 'Arkham Asylum'
    };

    const player1 = {_id: monk.id(), tribe: tribe.id, name: "player1", isDeleted: true};
    const player2 = {_id: monk.id(), tribe: tribe.id, name: "player2", isDeleted: true};
    const player3 = {_id: monk.id(), tribe: tribe.id, name: "player3", isDeleted: null};
    const player4 = {_id: monk.id(), tribe: tribe.id, name: "player4", isDeleted: true};
    const players = [
        player1,
        player2,
        player3,
        player4
    ];

    const retiredPlayers = [
        player1,
        player2,
        player4
    ];

    beforeAll(async function () {
        await tribeCollection.insert(tribe);
        await e2eHelp.authorizeUserForTribes([tribe.id]);
        await playersCollection.drop();
        await playersCollection.insert(players);

        await browser.get(`${hostName}/test-login?username=${e2eHelp.userEmail}&password="******"`);
        await browser.waitForAngular();
    });

    afterAll(async function () {
        await tribeCollection.remove({id: tribe.id}, false)
    });

    e2eHelp.afterEachAssertLogsAreEmpty();

    beforeEach(async function () {
        await browser.setLocation(`/${tribe.id}/players/retired`);
    });

    it('shows the retired players', async function () {
        const playerElements = element.all(By.repeater('player in retiredPlayers'));
        expect(playerElements.getText()).toEqual(pluck('name', retiredPlayers));
    });

    it('has a tribe card', function () {
        const tribeCardHeaderElement = element(By.className("tribe-card-header"));
        expect(tribeCardHeaderElement.getText()).toEqual(tribe.name);
    });

});
Example #5
0
    describe('DELETE', function () {
        let newTribe = {
            name: 'TeamMadeByTest',
            id: 'deleteme',
            email: '*****@*****.**',
            badgesEnabled: true,
            _id: monk.id()
        };

        it('will remove a tribe from regular communications.', async function () {
            await host.post(path)
                .send(newTribe)
                .expect(200)
                .expect('Content-Type', /json/);

            await host.delete(path + "/deleteme")
                .expect(200);

            const getAllResponse = await host.get(path)
                .expect(200)
                .expect('Content-Type', /json/);

            const result = find(function (element) {
                return element.name === 'TeamMadeByTest'
            }, getAllResponse.body);

            expect(result).toBeUndefined();

            await host.get(path + '/deleteme')
                .expect(404)
                .expect('Content-Type', /json/);

        });
    })
Example #6
0
    it('GET will not return the tribe if a player had that email but had it removed.', async function () {
        let tribe = {id: 'delete-me', name: 'tribe-from-endpoint-tests'};
        let playerId = monk.id();
        await Bluebird.all([
            host.post(path).send(tribe),
            host.post(path + '/players').send({
                _id: playerId,
                name: 'delete-me',
                tribe: 'delete-me',
                email: userEmail + '._temp'
            })
        ]);

        await authorizeUserForTribes([]);

        await host.post(path + '/players').send({
            _id: playerId,
            name: 'delete-me',
            tribe: 'delete-me',
            email: 'something else '
        });

        const response = await host.get(path)
            .expect(200)
            .expect('Content-Type', /json/);
        expect(clean(response.body)).toEqual(clean([]));

        await Bluebird.all([
            tribesCollection.remove({id: 'delete-me'}, false),
            playersCollection.remove({_id: playerId})
        ]);
    });
Example #7
0
    describe("DELETE", function () {
        let resultPins = [
            {_id: monk.id(), name: '1', tribe: tribeId},
            {_id: monk.id(), name: '2', tribe: tribeId},
            {_id: monk.id(), name: '3', tribe: tribeId}
        ];

        beforeEach(function (done) {
            pinCollection.insert(resultPins)
                .then(done, done.fail);
        });

        afterEach(function (done) {
            pinCollection.remove({tribe: tribeId})
                .then(done, done.fail);
        });

        it('will no longer display the deleted pin', function (done) {
            let httpDelete = agent.delete(path + "/" + resultPins[1]._id);
            httpDelete
                .expect('Content-Type', /json/)
                .expect(200)
                .then(function (response) {
                    expect(response.body).toEqual({});

                    return agent.get(path)
                        .expect(200)
                        .expect('Content-Type', /json/)
                })
                .then(function (response) {
                    expect(clean(response.body)).toEqual(clean([resultPins[0], resultPins[2]]));
                })
                .then(done, done.fail);
        });

        it('will fail when pin does not exist', function (done) {
            let httpDelete = agent.delete(path + "/" + monk.id());
            httpDelete
                .expect('Content-Type', /json/)
                .expect(404)
                .then(function (response) {
                    expect(response.body).toEqual({message: 'Failed to remove the pin because it did not exist.'});
                })
                .then(done, done.fail);
        });
    });
Example #8
0
 it('will return an error when the player does not exist.', function (done) {
     let badId = monk.id();
     let httpDelete = couplingServer.delete(path + "/" + badId);
     httpDelete
         .expect(404)
         .expect({message: 'Player could not be deleted because they do not exist.'})
         .then(done, done.fail);
 });
Example #9
0
 setTimeout(function () {
     let badId = monk.id();
     agent.delete(path + '/' + badId)
         .expect(404)
         .then(function (response) {
             expect(response.body).toEqual({message: 'Pair Assignments could not be deleted because they do not exist.'});
         })
         .then(done, done.fail);
 });
Example #10
0
 it('will fail when pin does not exist', function (done) {
     let httpDelete = agent.delete(path + "/" + monk.id());
     httpDelete
         .expect('Content-Type', /json/)
         .expect(404)
         .then(function (response) {
             expect(response.body).toEqual({message: 'Failed to remove the pin because it did not exist.'});
         })
         .then(done, done.fail);
 });