feat(gitea): add embeds, modals and the issue and pull request commands
Creating an issue or a pull request needs a title and a description, which do not fit in a slash command option, so the branches chosen as options are kept in memory for a few minutes until the modal is submitted.
This commit is contained in:
7 files changed
+470
-12
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { consume, pendingCount, purgeExpired, remember } from '../src/services/gitea/pending-actions.js';
|
||||
|
||||
describe('pending actions', () => {
|
||||
it('returns a stored value exactly once', () => {
|
||||
remember('pr:1', { head: 'feature', base: 'main' });
|
||||
assert.deepEqual(consume('pr:1'), { head: 'feature', base: 'main' });
|
||||
assert.equal(consume('pr:1'), null);
|
||||
});
|
||||
|
||||
it('returns null for an unknown key', () => {
|
||||
assert.equal(consume('pr:unknown'), null);
|
||||
});
|
||||
|
||||
it('drops an expired entry', () => {
|
||||
const start = 1_000;
|
||||
remember('pr:2', 'value', { ttlMs: 500, now: start });
|
||||
assert.equal(consume('pr:2', { now: start + 501 }), null);
|
||||
});
|
||||
|
||||
it('keeps a value still within its window', () => {
|
||||
remember('pr:3', 'value', { ttlMs: 500, now: 0 });
|
||||
assert.equal(consume('pr:3', { now: 499 }), 'value');
|
||||
});
|
||||
|
||||
it('purges expired entries without touching fresh ones', () => {
|
||||
remember('pr:4', 'old', { ttlMs: 10, now: 0 });
|
||||
remember('pr:5', 'fresh', { ttlMs: 10_000, now: 0 });
|
||||
assert.equal(purgeExpired(100), 1);
|
||||
assert.equal(pendingCount(), 1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user