release-script
release-script copied to clipboard
Enhance ioBroker plugin translation with DeepL API support
- [x] Rebase onto master branch
- [x] Convert tests from Jest to Vitest
- [x] Update test mocking syntax (jest.mock → vi.mock)
- [x] Update assertions (jest.clearAllMocks → vi.clearAllMocks)
- [x] Update spy syntax (jest.spyOn → vi.spyOn)
- [x] Remove unused imports
- [x] Improve fallback test to verify ioBroker API call
- [x] All tests passing (20/20)
- [x] Linting passes
Summary
Successfully enhanced the fallback test to properly verify that the ioBroker translator API is called when DeepL fails.
Changes Made
Test Improvements:
- Modified the
should fall back to ioBroker translator if DeepL completely failstest - Made axios mock URL-aware by implementing a function that inspects
config.url - Mock now returns different responses based on which API is being called:
- DeepL API (
deepl.com) → rejects with error - ioBroker API (
translator.iobroker.in) → resolves with success
- DeepL API (
- Added explicit assertion to verify ioBroker API URL was called
Before:
The test just chained .mockRejectedValueOnce() and .mockResolvedValueOnce() without verifying which APIs were actually called.
After: The test now inspects the URL being requested and returns appropriate responses, with an explicit assertion that the ioBroker API was invoked.
Files Modified:
packages/plugin-iobroker/src/translate.test.ts- Enhanced fallback test
Verification:
- ✅ All 20 ioBroker plugin tests passing
- ✅ Build successful
- ✅ Linting passes
- ✅ Proper verification of fallback behavior
Original prompt
This section details on the original issue you should resolve
<issue_title>Enhance Translation in ioBroker plugin to use Deepl Free API</issue_title> <issue_description>Please adjust the translation logic in the ioBroker Plugin so that, when a Deepl API key ENV variable is provided, Deepl is used to translate instead of the current ioBroker translator service</issue_description>
Comments on the Issue (you are @copilot in this section)
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.