test: add IntegrationDependency integration tests#347
test: add IntegrationDependency integration tests#347zongqichen wants to merge 2 commits intofeat/integration-dependenciesfrom
Conversation
- Add external Data Product test packages (test-sai-supplier-v1, test-s4-supplier-v1) - Add integration tests for IntegrationDependency generation with @ORD.Extensions - Add integration tests for cdsrc customization of IntegrationDependency - Add integration tests for custom.ord.json merging of IntegrationDependency
SummaryThe following content is AI-generated and provides a summary of the pull request: Add Integration Tests for IntegrationDependency Feature✅ Test: Comprehensive integration test suite for the IntegrationDependency generation feature. ChangesThis PR adds integration tests to verify the IntegrationDependency generation functionality across multiple scenarios: Test Infrastructure
Test Data ProductsAdded two external Data Product test packages simulating SAP Intelligent Agriculture (SAI) and S4HANA integrations:
Test Scenarios1. Basic IntegrationDependency Generation (13 new tests)
2. cdsrc Customization (3 new tests)
3. custom.ord.json Merging (3 new tests)
Test Configuration Files
PR Bot InformationVersion:
💌 Have ideas or want to contribute? Create an issue and share your thoughts with us! Made with ❤️ by Hyperspace. |
There was a problem hiding this comment.
Summary
The PR adds comprehensive integration tests for IntegrationDependency generation. However, there are several instances where array elements are accessed without proper null/undefined checks in the test predicates, which could cause runtime errors if the data structure doesn't match expectations. These should be fixed with optional chaining to make the tests more robust.
PR Bot Information
Version: 1.17.46 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Correlation ID:
893b4bd0-0059-11f1-924c-d2f2025a0498 - LLM:
anthropic--claude-4.5-sonnet - Event Trigger:
pull_request.opened
| const integrationDep = ordDocument.integrationDependencies[0]; | ||
| expect(integrationDep.aspects).toHaveLength(2); | ||
|
|
||
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); |
There was a problem hiding this comment.
Bug: Potential runtime error accessing array without null/undefined check
a.apiResources[0] is accessed without verifying that a.apiResources exists or has elements. If the aspect object doesn't have apiResources or it's empty, this will throw a TypeError.
Consider adding a safe navigation check:
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); | |
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources?.[0]?.ordId.includes("test.sai")); |
Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| expect(saiAspect.apiResources[0].ordId).toBe("test.sai:apiResource:Supplier:v1"); | ||
| expect(saiAspect.apiResources[0].minVersion).toBe("1.0.0"); | ||
|
|
||
| const s4Aspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.s4")); |
There was a problem hiding this comment.
Bug: Potential runtime error accessing array without null/undefined check
a.apiResources[0] is accessed without verifying that a.apiResources exists or has elements. If the aspect object doesn't have apiResources or it's empty, this will throw a TypeError.
Consider adding a safe navigation check:
| const s4Aspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.s4")); | |
| const s4Aspect = integrationDep.aspects.find((a) => a.apiResources?.[0]?.ordId.includes("test.s4")); |
Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| expect(saiAspect.title).toBe("Test SAI Supplier API"); | ||
| expect(saiAspect.description).toBe("Integration with Test SAI Supplier Data Product"); | ||
| expect(saiAspect.mandatory).toBe(false); | ||
| expect(saiAspect.apiResources[0].ordId).toBe("test.sai:apiResource:Supplier:v1"); |
There was a problem hiding this comment.
Bug: Array accessed before null check
Line 157 accesses saiAspect.apiResources[0].ordId before line 153 verifies saiAspect is defined. If saiAspect is undefined (e.g., if the find at line 152 returns nothing), this will throw a TypeError.
The expect(saiAspect).toBeDefined() assertion at line 153 doesn't prevent the error—it would fail the test, but only after attempting the property access at line 157. Consider restructuring the test or adding guards.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| const integrationDep = ordDocument.integrationDependencies[0]; | ||
| expect(integrationDep.aspects).toHaveLength(2); | ||
|
|
||
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); |
There was a problem hiding this comment.
Bug: Potential runtime error accessing array without null/undefined check
a.apiResources[0] is accessed without verifying that a.apiResources exists or has elements. If the aspect object doesn't have apiResources or it's empty, this will throw a TypeError.
Consider adding a safe navigation check:
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); | |
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources?.[0]?.ordId.includes("test.sai")); |
Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
| const integrationDep = ordDocument.integrationDependencies[0]; | ||
| expect(integrationDep.aspects).toHaveLength(2); | ||
|
|
||
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); |
There was a problem hiding this comment.
Bug: Potential runtime error accessing array without null/undefined check
a.apiResources[0] is accessed without verifying that a.apiResources exists or has elements. If the aspect object doesn't have apiResources or it's empty, this will throw a TypeError.
Consider adding a safe navigation check:
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources[0].ordId.includes("test.sai")); | |
| const saiAspect = integrationDep.aspects.find((a) => a.apiResources?.[0]?.ordId.includes("test.sai")); |
Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
Summary
Test plan
npm run test:integration:buildto verify IntegrationDependency tests passnpm run test:integration:basicto verify basic-auth tests still passnpm run test:integration:mtlsto verify mTLS tests still passDependencies
This PR should be merged after the base branch PR (feat/integration-dependencies) is merged.