Skip to content

Commit

Permalink
e2e fix for auth tests using new api workflow (#7)
Browse files Browse the repository at this point in the history
* update e2e test to use new api workflow

* fix(test): update auth tests with new api workflow
  • Loading branch information
sundersc authored Oct 13, 2021
1 parent ae3c274 commit 6bed2c4
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions packages/amplify-e2e-core/src/categories/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,23 @@ export function addAuthWithGroupTrigger(cwd: string, settings: any): Promise<voi
});
}

interface AddApiOptions {
apiName: string;
testingWithLatestCodebase: boolean;
}

const defaultOptions: AddApiOptions = {
apiName: '\r',
testingWithLatestCodebase: true,
};

export function addAuthViaAPIWithTrigger(cwd: string, settings: any): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['add', 'api'], { cwd, stripColors: true })
spawn(getCLIPath(defaultOptions.testingWithLatestCodebase), ['add', 'api'], { cwd, stripColors: true })
.wait('Please select from one of the below mentioned services:')
.sendCarriageReturn()
.wait('Provide API name')
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
.sendKeyUp(2)
.sendCarriageReturn()
.wait('Choose the default authorization type for the API')
.send(KEY_DOWN_ARROW)
Expand All @@ -148,10 +159,9 @@ export function addAuthViaAPIWithTrigger(cwd: string, settings: any): Promise<vo
.sendCarriageReturn()
.wait('Do you want to edit your add-to-group function now?')
.sendConfirmNo()
.wait(/.*Do you want to configure advanced settings for the GraphQL API.*/)
.sendCarriageReturn()
.wait('Do you have an annotated GraphQL schema?')
.wait(/.*Configure additional auth types.*/)
.sendConfirmNo()
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
.sendCarriageReturn()
.wait('Choose a schema template:')
.sendCarriageReturn()
Expand All @@ -169,10 +179,11 @@ export function addAuthViaAPIWithTrigger(cwd: string, settings: any): Promise<vo

export function addAuthwithUserPoolGroupsViaAPIWithTrigger(cwd: string, settings: any): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['add', 'api'], { cwd, stripColors: true })
spawn(getCLIPath(defaultOptions.testingWithLatestCodebase), ['add', 'api'], { cwd, stripColors: true })
.wait('Please select from one of the below mentioned services:')
.sendCarriageReturn()
.wait('Provide API name')
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
.sendKeyUp(2)
.sendCarriageReturn()
.wait('Choose the default authorization type for the API')
.send(KEY_DOWN_ARROW)
Expand Down Expand Up @@ -235,10 +246,9 @@ export function addAuthwithUserPoolGroupsViaAPIWithTrigger(cwd: string, settings
.sendCarriageReturn()
.wait('Do you want to edit your add-to-group function now?')
.sendConfirmNo()
.wait(/.*Do you want to configure advanced settings for the GraphQL API.*/)
.sendCarriageReturn()
.wait('Do you have an annotated GraphQL schema?')
.wait(/.*Configure additional auth types.*/)
.sendConfirmNo()
.wait(/.*Here is the GraphQL API that we will create. Select a setting to edit or continue.*/)
.sendCarriageReturn()
.wait('Choose a schema template:')
.sendCarriageReturn()
Expand Down

0 comments on commit 6bed2c4

Please sign in to comment.