Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(promo-manager): get promo status for deleted promo #129

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading