test: isolate HTTP suites from scheduler and bank-card case order (WealthLedger/backend#65)
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
BankSummaryDto,
|
||||
ExpenseCategoryDto,
|
||||
} from '../src/modules/banking/bank-cards/presentation/bank-card.dto';
|
||||
import { TbankHourlyScheduler } from '../src/modules/investments/tbank-sync/tbank-hourly.scheduler';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
|
||||
jest.setTimeout(60000);
|
||||
@@ -77,7 +78,10 @@ describe('Manual bank cards configured HTTP and real SQLite', () => {
|
||||
const start = async () => {
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
})
|
||||
.overrideProvider(TbankHourlyScheduler)
|
||||
.useValue({ tick: jest.fn() })
|
||||
.compile();
|
||||
app = module.createNestApplication();
|
||||
configureApp(app);
|
||||
await app.listen(0, '127.0.0.1');
|
||||
@@ -369,6 +373,8 @@ describe('Manual bank cards configured HTTP and real SQLite', () => {
|
||||
expect((await getCard(own.id)).balance.value).toBe('1000');
|
||||
});
|
||||
it('renames default category without role loss; duplicates and stale rename conflict', async () => {
|
||||
// Defaults are seeded by the first write of the user; this case must not depend on earlier cases.
|
||||
await createCard();
|
||||
const category = (await categories()).find((c) => c.isDefault);
|
||||
assert.ok(category);
|
||||
await auth('patch', '/categories/' + category.id)
|
||||
@@ -725,11 +731,19 @@ describe('Manual bank cards configured HTTP and real SQLite', () => {
|
||||
expect(await getCard(card.id)).toEqual(before);
|
||||
expect((await getOp(refund.id)).originalExpenseId).toBe(purchase.id);
|
||||
await auth('post', '/operations').send(deletedBody).expect(410);
|
||||
// The rename is this case's own prerequisite, not an effect of an earlier case.
|
||||
const defaultCategory = (await categories()).find((c) => c.isDefault);
|
||||
assert.ok(defaultCategory);
|
||||
await auth('patch', '/categories/' + defaultCategory.id)
|
||||
.send({ version: defaultCategory.version, name: 'Остальное' })
|
||||
.expect(200);
|
||||
expect((await categories()).find((c) => c.isDefault)?.name).toBe(
|
||||
'Остальное',
|
||||
);
|
||||
});
|
||||
it('enforces actual FK and unique constraints', async () => {
|
||||
// Seeds the owner's default categories so the unique-name check has a real row to collide with.
|
||||
await createCard();
|
||||
await expect(
|
||||
db.expenseCategory.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user