2018-02-14 01:21:39 +00:00
|
|
|
import { TAVERN_ID } from '../../../../../website/server/models/group';
|
|
|
|
|
import { updateDocument } from '../../../../helpers/mongo';
|
|
|
|
|
import {
|
|
|
|
|
requester,
|
|
|
|
|
resetHabiticaDB,
|
2018-06-18 12:40:25 +00:00
|
|
|
} from '../../../../helpers/api-integration/v3';
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
import * as worldState from '../../../../../website/server/libs/worldState';
|
|
|
|
|
import common from '../../../../../website/common';
|
2018-02-14 01:21:39 +00:00
|
|
|
|
|
|
|
|
describe('GET /world-state', () => {
|
|
|
|
|
before(async () => {
|
|
|
|
|
await resetHabiticaDB();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns empty worldBoss object when world boss is not active (and does not require authentication)', async () => {
|
|
|
|
|
const res = await requester().get('/world-state');
|
|
|
|
|
expect(res.worldBoss).to.eql({});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns Tavern quest data when world boss is active', async () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
await updateDocument('groups', { _id: TAVERN_ID }, { quest: { active: true, key: 'dysheartener', progress: { hp: 50000, rage: 9999 } } });
|
2018-02-14 01:21:39 +00:00
|
|
|
|
|
|
|
|
const res = await requester().get('/world-state');
|
2018-02-17 17:11:24 +00:00
|
|
|
expect(res).to.have.nested.property('worldBoss');
|
2018-02-14 01:21:39 +00:00
|
|
|
|
|
|
|
|
expect(res.worldBoss).to.eql({
|
|
|
|
|
active: true,
|
|
|
|
|
extra: {},
|
|
|
|
|
key: 'dysheartener',
|
|
|
|
|
progress: {
|
|
|
|
|
collect: {},
|
|
|
|
|
hp: 50000,
|
|
|
|
|
rage: 9999,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-03-20 21:30:43 +00:00
|
|
|
|
Fall Festival Gem Promo (#138)
* content: add gems blocks
* gemsBlocks: include ios and android identifiers
* wip: promo code
* split common constants into multiple files
* add second promo part
* geCurrentEvent, refactor promo
* fix lint
* fix exports, use world state api
* start adding world state tests
* remove console.log
* use gems block for purchases
* remove comments
* fix most unit tests
* restore comment
* fix lint
* prevent apple/google gift tests from breaking other tests when stub is not reset
* fix unit tests, clarify tests names
* iap: use gift object when gifting gems
* allow gift object with less data
* fix iap tests, remove findById stubs
* iap: require less data from the mobile apps
* apply discounts
* add missing worldState file
* fix lint
* add test event
* start removing 20 gems option for web
* start adding support for all gems packages on web
* fix unit tests for apple, stripe and google
* amazon: support all gems blocks
* paypal: support all gems blocks
* fix payments unit tests, add tests for getGemsBlock
* web: add gems plans with discounts, update stripe
* fix amazon and paypal clients, payments success modals
* amazon pay: disabled state
* update icons, start abstracting payments buttons
* begin redesign
* redesign gems modal
* fix buttons
* fix hover color for gems modal close icon
* add key to world state current event
* extend test event length
* implement gems modals designs
* early test fall2020
* fix header banner position
* add missing files
* use iso 8601 for dates, minor ui fixes
* fix time zones
* events: fix ISO8601 format
* fix css indentation
* start abstracting banners
* refactor payments buttons
* test spooky, fix group plans box
* implement gems promo banners, refactor banners, fixes
* fix lint
* fix dates
* remove unused i18n strings
* fix stripe integration test
* fix world state integration tests
* the current active event
* add missing unit tests
* add storybook story for payments buttons component
* fix typo
* fix(stripe): correct label when gifting subscriptions
2020-09-21 14:22:13 +00:00
|
|
|
context('no current event', () => {
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
sinon.stub(worldState, 'getCurrentEvent').returns(null);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
worldState.getCurrentEvent.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns null for the current event when there is none active', async () => {
|
|
|
|
|
const res = await requester().get('/world-state');
|
|
|
|
|
|
|
|
|
|
expect(res.currentEvent).to.be.null;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
context('no current event', () => {
|
|
|
|
|
const evt = {
|
|
|
|
|
...common.content.events.fall2020,
|
|
|
|
|
event: 'fall2020',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
sinon.stub(worldState, 'getCurrentEvent').returns(evt);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
worldState.getCurrentEvent.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns the current event when there is an active one', async () => {
|
|
|
|
|
const res = await requester().get('/world-state');
|
|
|
|
|
|
|
|
|
|
expect(res.currentEvent).to.eql(evt);
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-03-20 21:56:55 +00:00
|
|
|
});
|