-
Notifications
You must be signed in to change notification settings - Fork 646
chore: convert bdd tests to e2e tests #7539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
smilkuri
wants to merge
1
commit into
main
Choose a base branch
from
cucumber-to-vitest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { ACM } from "@aws-sdk/client-acm"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-acm", () => { | ||
| let client: ACM; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new ACM({ region }); | ||
| }); | ||
|
|
||
| describe("Making a request to ACM service", () => { | ||
| it("should successfully list certificates", async () => { | ||
| const result = await client.listCertificates({}); | ||
|
|
||
| expect(Array.isArray(result.CertificateSummaryList)).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle ValidationException for invalid certificate ARN", async () => { | ||
| await expect( | ||
| client.describeCertificate({ | ||
| CertificateArn: "fake_arn", | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "ValidationException", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
clients/client-api-gateway/test/apigateway-features.e2e.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { APIGateway } from "@aws-sdk/client-api-gateway"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-api-gateway", () => { | ||
| let client: APIGateway; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new APIGateway({ region }); | ||
| }); | ||
|
|
||
| describe("Making a request", () => { | ||
| it("should successfully get REST APIs", async () => { | ||
| const result = await client.getRestApis({}); | ||
|
|
||
| expect(Array.isArray(result.items)).toBe(true); | ||
smilkuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle NotFoundException for invalid REST API ID", async () => { | ||
| await expect( | ||
| client.getRestApi({ | ||
| restApiId: "fake_id", | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "NotFoundException", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
clients/client-cloudformation/test/cloudformation-features.e2e.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { CloudFormation, paginateListStacks } from "@aws-sdk/client-cloudformation"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-cloudformation", () => { | ||
| let client: CloudFormation; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new CloudFormation({ region }); | ||
| }); | ||
|
|
||
| describe("Describing stacks", () => { | ||
| it("should return stacks list when describe stacks is called", async () => { | ||
| const result = await client.describeStacks({}); | ||
|
|
||
| expect(result).toBeDefined(); | ||
| expect(result.Stacks).toBeDefined(); | ||
| expect(Array.isArray(result.Stacks)).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle ValidationError for invalid stack creation", async () => { | ||
| const templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}'; | ||
|
|
||
| await expect( | ||
| client.createStack({ | ||
| TemplateBody: templateBody, | ||
| StackName: "", // Empty name should cause ValidationError | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "ValidationError", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Paginating responses", () => { | ||
| it("should paginate listStacks operation", async () => { | ||
| const paginator = paginateListStacks({ client }, {}); | ||
|
|
||
| let pageCount = 0; | ||
| let lastPage; | ||
|
|
||
| for await (const page of paginator) { | ||
| pageCount++; | ||
| lastPage = page; | ||
| } | ||
|
|
||
| expect(pageCount).toBeGreaterThanOrEqual(1); | ||
| expect(lastPage).toBeDefined(); | ||
| expect(lastPage?.NextToken).toBeUndefined(); // The last page must not contain a marker | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
clients/client-cloudfront/test/cloudfront-features.e2e.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { CloudFront } from "@aws-sdk/client-cloudfront"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-cloudfront", () => { | ||
| let client: CloudFront; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new CloudFront({ region }); | ||
| }, 60_000); | ||
|
|
||
| describe("List distributions", () => { | ||
| it("should return distribution list with quantity property", async () => { | ||
| const result = await client.listDistributions({}); | ||
|
|
||
| expect(typeof result.DistributionList?.Quantity).toBe("number"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Create a distribution", () => { | ||
| it("should handle NoSuchOrigin error for invalid origin", async () => { | ||
| const uniqueRef = `aws-js-sdk-${Date.now()}-${process.pid}-${Math.random().toString(36).substr(2, 9)}`; | ||
| const distributionConfig = { | ||
| CallerReference: uniqueRef, | ||
| Aliases: { | ||
| Quantity: 0, | ||
| }, | ||
| DefaultRootObject: "", | ||
| Origins: { | ||
| Items: [ | ||
| { | ||
| Id: "InvalidOrigin", | ||
| DomainName: "example.com", | ||
| CustomOriginConfig: { | ||
| HTTPPort: 80, | ||
| HTTPSPort: 443, | ||
| OriginProtocolPolicy: "match-viewer" as const, | ||
| }, | ||
| }, | ||
| ], | ||
| Quantity: 1, | ||
| }, | ||
| DefaultCacheBehavior: { | ||
| TargetOriginId: "NonExistentOrigin", | ||
| ForwardedValues: { | ||
| QueryString: false, | ||
| Cookies: { | ||
| Forward: "all" as const, | ||
| }, | ||
| }, | ||
| TrustedSigners: { | ||
| Items: [], | ||
| Enabled: false, | ||
| Quantity: 0, | ||
| }, | ||
| ViewerProtocolPolicy: "allow-all" as const, | ||
| MinTTL: 0, | ||
| }, | ||
| CacheBehaviors: { | ||
| Items: [], | ||
| Quantity: 0, | ||
| }, | ||
| Comment: "", | ||
| Logging: { | ||
| Enabled: false, | ||
| Bucket: "invalidbucket.s3.amazonaws.com", | ||
| Prefix: "prefix", | ||
| IncludeCookies: false, | ||
| }, | ||
| PriceClass: "PriceClass_All" as const, | ||
| Enabled: false, | ||
| }; | ||
|
|
||
| await expect( | ||
| client.createDistribution({ | ||
| DistributionConfig: distributionConfig, | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "NoSuchOrigin", | ||
| $metadata: expect.objectContaining({ | ||
| httpStatusCode: 404, | ||
| }), | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle InvalidArgument for empty name prefix", async () => { | ||
| const distributionConfig = { | ||
| CallerReference: "", | ||
| Aliases: { | ||
| Quantity: 0, | ||
| }, | ||
| DefaultRootObject: "", | ||
| Origins: { | ||
| Items: [ | ||
| { | ||
| Id: "origin", | ||
| DomainName: "example.com", | ||
| CustomOriginConfig: { | ||
| HTTPPort: 80, | ||
| HTTPSPort: 443, | ||
| OriginProtocolPolicy: "match-viewer" as const, | ||
| }, | ||
| }, | ||
| ], | ||
| Quantity: 1, | ||
| }, | ||
| DefaultCacheBehavior: { | ||
| TargetOriginId: "origin", | ||
| ForwardedValues: { | ||
| QueryString: false, | ||
| Cookies: { | ||
| Forward: "all" as const, | ||
| }, | ||
| }, | ||
| TrustedSigners: { | ||
| Items: [], | ||
| Enabled: false, | ||
| Quantity: 0, | ||
| }, | ||
| ViewerProtocolPolicy: "allow-all" as const, | ||
| MinTTL: 0, | ||
| }, | ||
| CacheBehaviors: { | ||
| Items: [], | ||
| Quantity: 0, | ||
| }, | ||
| Comment: "", | ||
| Logging: { | ||
| Enabled: false, | ||
| Bucket: "invalidbucket.s3.amazonaws.com", | ||
| Prefix: "prefix", | ||
| IncludeCookies: false, | ||
| }, | ||
| PriceClass: "PriceClass_All" as const, | ||
| Enabled: false, | ||
| }; | ||
|
|
||
| await expect( | ||
| client.createDistribution({ | ||
| DistributionConfig: distributionConfig, | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "InvalidArgument", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }, 60_000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.