Skip to content

Commit

Permalink
Merge pull request #129 from gravity-ui/unknown-promos
Browse files Browse the repository at this point in the history
fix(promo-manager): get promo status for deleted promo
  • Loading branch information
vanilla-wave authored Oct 4, 2024
2 parents 3fb1f5c + 78f251a commit 4e5caf7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/promo-manager/core/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export class Controller {
};

private isPromoRepeatable = (slug: PromoSlug) => {
const isPromoRepeatable = this.helpers.promoBySlug[slug].repeatable;
const isPromoRepeatable = this.helpers.promoBySlug[slug]?.repeatable ?? false;

const groupSlug = this.getGroupBySlug(slug);
const group = this.options.config.promoGroups.find(
Expand Down
26 changes: 26 additions & 0 deletions src/promo-manager/tests/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,32 @@ describe('promo status', function () {
expect(status).toBe('forbidden');
});

it('undefined promo -> forbidden', async function () {
const controller = new Controller(testOptions);

const status = controller.getPromoStatus('boardPollFake');

expect(status).toBe('forbidden');
});

it('deleted promo with progress promo -> return false', async function () {
const controller = new Controller({
...testOptions,
progressState: {
finishedPromos: ['boardPollFake'],
progressInfoByPromo: {
boardPollFake: {
lastCallTime: Date.now(),
},
},
},
});

const status = controller.getPromoStatus('boardPollFake');

expect(status).toBe('finished');
});

describe('repeatable promos', function () {
it('repeatable finished promo -> canReRun', async function () {
const controller = new Controller(testOptions);
Expand Down

0 comments on commit 4e5caf7

Please sign in to comment.