test: add 5 more CFN synthesis fixtures for previously-uncovered code…#707
Conversation
… paths Builds on the 24-fixture suite from #704. Each new fixture targets a specific plugin code path that the existing fixtures don't exercise: - sync-config-versioned (3 tests): DynamoDB conflict resolution with OPTIMISTIC_CONCURRENCY and AUTOMERGE handlers, plus delta sync table configuration for offline-capable mobile apps. Closes a gap where syncConfig.test.ts had unit coverage but no synthesis coverage. - custom-domain-no-cfn (5 tests): The useCloudFormation: false code path on the domain config. Asserts the absence of CFN resources (DomainName, DomainNameApiAssociation, RecordSet, Certificate) that the useCloudFormation: true variant DOES create. Complements the existing custom-domain fixture. - waf-pre-existing-arn (2 tests): WAF attached via an existing ACL ARN rather than created inline via rules. Different code path in Waf.ts that emits only WebACLAssociation, not WebACL. Complements the existing waf fixture. - pipeline-resolver-with-code (3 tests): A pipeline resolver with its own top-level JS code (before/after handlers) in addition to per- function code. Different from the existing pipeline-resolvers fixture which only has function-level code. - api-key-import-existing (3 tests): Importing an existing API key via apiKeyId for stable migrations / blue-green deploys, alongside an auto-generated key. Verifies ApiKeyId is passed through faithfully. Test surface grows from 25 -> 30 suites and 68 -> 84 assertions. Real plugin behavior caught while building the fixtures: - DataSource config 'versioned: true' is silently ignored unless 'deltaSyncConfig' is ALSO provided. Without delta sync config, the CFN output omits the Versioned attribute entirely. Worth noting in docs eventually, but not breaking — included both in this fixture to demonstrate the combination that actually works.
| const keys = findResourcesByType(result.template, 'AWS::AppSync::ApiKey'); | ||
| const stable = keys.find( | ||
| (k) => | ||
| (k.resource.Properties?.Description as string) === |
There was a problem hiding this comment.
type cast is not needed here
| const keys = findResourcesByType(result.template, 'AWS::AppSync::ApiKey'); | ||
| const rotating = keys.find( | ||
| (k) => | ||
| (k.resource.Properties?.Description as string) === |
There was a problem hiding this comment.
type cast is not needed here
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds five AppSync example projects (api-key-import-existing, custom-domain-no-cfn, waf-pre-existing-arn, pipeline-resolver-with-code, sync-config-versioned) with GraphQL schemas, Serverless configs, and e2e Jest tests; updates examples README. ChangesFive new AppSync example projects with tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
examples/custom-domain-no-cfn/serverless.yml (1)
33-34: 💤 Low valueConsider simplifying
certificateArnto a plain string.Since
useCloudFormation: false, the certificate ARN is metadata for CLI commands rather than a CloudFormation template value. UsingFn::Subwith pseudo-parameters (${AWS::Partition},${AWS::AccountId}) adds unnecessary complexity for a test fixture where these won't be resolved in the CFN output.♻️ Suggested simplification
- certificateArn: - Fn::Sub: 'arn:${AWS::Partition}:acm:us-east-1:${AWS::AccountId}:certificate/abc-123' + certificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/custom-domain-no-cfn/serverless.yml` around lines 33 - 34, Replace the Fn::Sub expression used for certificateArn with a plain string literal since this stack uses useCloudFormation: false; locate the certificateArn key (currently set to Fn::Sub: 'arn:${AWS::Partition}:acm:us-east-1:${AWS::AccountId}:certificate/abc-123') and change it to a simple ARN string (e.g., 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123') so CLI tooling receives a concrete value without CloudFormation pseudo-parameters.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/pipeline-resolver-with-code/functions/fetchProfile.js`:
- Around line 3-7: In fetchProfile.request, guard against a missing previous
result by checking ctx.prev.result (and/or ctx.prev.result.id) before
constructing the DynamoDB key; if it's null/undefined, return an explicit
not-found/short-circuit response (e.g. a step that returns or signals no item)
instead of accessing ctx.prev.result.id, otherwise proceed to build the GetItem
operation and key as currently done. Ensure the change is made in the request
function for fetchProfile so downstream code won't throw on a null
ctx.prev.result.
In `@examples/sync-config-versioned/serverless.yml`:
- Around line 53-81: Add Point-In-Time Recovery to both DynamoDB table resources
by updating the PostsTable and PostsDeltaTable Properties to include
PointInTimeRecoverySpecification with PointInTimeRecoveryEnabled: true;
specifically, modify the PostsTable resource and the PostsDeltaTable resource
(which currently has TimeToLiveSpecification) to each include
PointInTimeRecoverySpecification: { PointInTimeRecoveryEnabled: true } so PITR
is enabled for both tables.
---
Nitpick comments:
In `@examples/custom-domain-no-cfn/serverless.yml`:
- Around line 33-34: Replace the Fn::Sub expression used for certificateArn with
a plain string literal since this stack uses useCloudFormation: false; locate
the certificateArn key (currently set to Fn::Sub:
'arn:${AWS::Partition}:acm:us-east-1:${AWS::AccountId}:certificate/abc-123') and
change it to a simple ARN string (e.g.,
'arn:aws:acm:us-east-1:123456789012:certificate/abc-123') so CLI tooling
receives a concrete value without CloudFormation pseudo-parameters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 82fc61e2-8208-447a-89da-507545b97388
📒 Files selected for processing (19)
e2e/api-key-import-existing.e2e.test.tse2e/custom-domain-no-cfn.e2e.test.tse2e/pipeline-resolver-with-code.e2e.test.tse2e/sync-config-versioned.e2e.test.tse2e/waf-pre-existing-arn.e2e.test.tsexamples/README.mdexamples/api-key-import-existing/schema.graphqlexamples/api-key-import-existing/serverless.ymlexamples/custom-domain-no-cfn/schema.graphqlexamples/custom-domain-no-cfn/serverless.ymlexamples/pipeline-resolver-with-code/functions/fetchProfile.jsexamples/pipeline-resolver-with-code/functions/fetchUser.jsexamples/pipeline-resolver-with-code/resolvers/getUserDetails.jsexamples/pipeline-resolver-with-code/schema.graphqlexamples/pipeline-resolver-with-code/serverless.ymlexamples/sync-config-versioned/schema.graphqlexamples/sync-config-versioned/serverless.ymlexamples/waf-pre-existing-arn/schema.graphqlexamples/waf-pre-existing-arn/serverless.yml
test: add 5 more CFN synthesis fixtures for previously-uncovered code paths
What
Builds on the 24-fixture suite from #704 with 5 targeted additions that each
exercise a plugin code path the existing fixtures don't reach.
Test surface grows from 25 → 30 suites and 68 → 84 assertions.
Why these 5 specifically
I deliberately scoped this batch to uncovered code paths, not variations
on existing fixtures. Each new fixture targets a branch in the plugin source
that no existing test touches:
sync-config-versionedSyncConfigblock on resolvers + DynamoDBVersioned+DeltaSyncConfig—syncConfig.test.tshad unit coverage but zero synthesis coveragecustom-domain-no-cfnuseCloudFormation: falsebranch inApi.ts(early return, no CFN domain resources emitted) — complements the existingcustom-domainfixture which exercises thetruebranchwaf-pre-existing-arnwaf.arnbranch inWaf.ts(emits onlyWebACLAssociation, skipsWebACLcreation entirely) — complements the existingwaffixturepipeline-resolver-with-codecode:(before/after handlers) — the existingpipeline-resolversfixture only exercises per-function codeapi-key-import-existingapiKeyIdfield on API key config (CFNApiKeyIdpass-through) for stable migrations / blue-green deploysWhat I deliberately did NOT add
To avoid procrastination-via-tests, I rejected fixtures that would only
exercise variation, not new code paths:
After this batch, I'd argue the synthesis test suite is materially complete.
Future fixtures should be added alongside the feature work that needs them
(e.g. when MERGED API support lands, add a
merged-apifixture in that PR).Real plugin behavior caught while building
While writing
sync-config-versionedI found that the plugin silentlyignores
versioned: trueon a DynamoDB data source unlessdeltaSyncConfigis also configured. The CFN output omits the
Versionedattribute entirelyin that case. The fixture deliberately demonstrates the combination that
works so users don't hit this gotcha.
Not changing plugin behavior in this PR — that's a separate question (is
this validation-warning territory, or just a docs note?). Filing it as an
observation worth knowing.
Verification
npm run test— 288 unit tests passnpm run test:e2e— 84 assertions across 30 suites pass (~85s)npm run lint— clean (0 errors, 0 warnings)npm run build— cleanOut of scope (follow-ups for future PRs)
versioned-without-deltaSyncConfigsilent ignore: should the pluginwarn at validation time? Or update docs to clarify? Separate decision.
Summary by CodeRabbit
New Features
Tests
Documentation