test(fxa-auth-server): migrate DB, Redis & storage tests from Mocha PART 3#20144
test(fxa-auth-server): migrate DB, Redis & storage tests from Mocha PART 3#20144
Conversation
ef3f9a6 to
80e3020
Compare
|
These PRs are pretty big to be reviewed manually. Here are some steps/prompts that you can use to verify the parity between them.
|
| removePublicAndCanGrantTokens: sinon.fake.resolves(undefined), | ||
| }; | ||
|
|
||
| Container.set(StripeHelper, mockStripeHelper); |
There was a problem hiding this comment.
question, non-blocking: I noticed between this PR and others that there appears a lot of similar container setup, did you find that was the case and there's a lot of duplicate setup, or are they all just slightly different?
There was a problem hiding this comment.
They were sligthly different mocks for each test. I didn't want to refactor it out since it would change unrelated files. We can probably re-evaluate in the follow up issue.
| expect(args[0].foo).toBe('bar'); | ||
| expect(args[0].baz).toBe('qux'); | ||
| expect(args[0].prefix).toBe('wibble'); | ||
| expect(args[0].blee).toBeUndefined(); |
There was a problem hiding this comment.
The original tests had an assertion that the log was passed to the redis constructor
assert.equal(args[1], log, 'redisPool was passed log');Probably safe to omit it, just wanted to flag!
There was a problem hiding this comment.
Should these be unit or integration since they're creating db with each test? I guess I would classify anything that creates a db instance and connects to it an integration test
There was a problem hiding this comment.
Fair question! I can make these integration tests
|
|
||
| import sinon from 'sinon'; | ||
|
|
||
| // Mock fxa-shared/db to prevent real DB connections |
There was a problem hiding this comment.
@nshirley I was confused by function createDB, that gets mocked by below so no real db connection is made.
1bcae6b to
dff5ce7
Compare
…o Jest (FXA-12564) - Convert DB, Redis, and storage test files from Mocha/Chai to Jest - Set maxWorkers=4 for Jest unit tests to prevent OOM kills - Use page.waitForURL for pairing flow success check in functional tests
dff5ce7 to
7fe9eff
Compare
Because
test/local/covering DB, Redis, bounces, account lifecycle, and reminder modules needed migrationThis pull request
lib/:lib/bounces.spec.ts(fromtest/local/bounces.js)lib/account-events.spec.ts(fromtest/local/account-events.js)lib/account-delete.spec.ts(fromtest/local/account-delete.js)lib/db.spec.ts(fromtest/local/db.js)lib/inactive-accounts/index.spec.ts(fromtest/local/inactive-accounts/index.js)test/remote/(require real Redis):test/remote/redis.in.spec.ts(fromtest/local/redis.js)test/remote/cad-reminders.in.spec.ts(fromtest/local/cad-reminders.js)test/remote/subscription-account-reminders.in.spec.ts(fromtest/local/subscription-account-reminders.js)proxyquiretojest.mock()factories,chaiassertions toexpect(),forEach-wrappedit()toit.each()beforeEachand properly awaitingclose()inafterEachIssue
Closes: https://mozilla-hub.atlassian.net/browse/FXA-12564
Checklist
Other Information
Stability: Unit tests (300 total suite) passed 5/5 runs. Integration reminder tests passed 5/5 runs after the Redis contention fix.
Note: Original Mocha test files in
test/local/are intentionally kept in place. Deletion will be handled in a follow-up PR once the migration is validated in CI.Test Parity
All 167 runtime tests have full 1:1 parity — no tests added, dropped, or changed in behavior.
test/local/bounces.jslib/bounces.spec.tstest/local/account-events.jslib/account-events.spec.tstest/local/account-delete.jslib/account-delete.spec.tstest/local/db.jslib/db.spec.tstest/local/inactive-accounts/index.jslib/inactive-accounts/index.spec.tstest/local/redis.jstest/remote/redis.in.spec.tstest/local/cad-reminders.jstest/remote/cad-reminders.in.spec.tstest/local/subscription-account-reminders.jstest/remote/subscription-account-reminders.in.spec.ts