forked from aws-amplify/amplify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Integration test for Auth & API (aws-amplify#77)
Cypress integration tests for Auth and API modules
- Loading branch information
Nidhi Sharma
authored
Sep 5, 2018
1 parent
1d025b9
commit 005450d
Showing
14 changed files
with
301 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
#!/bin/sh -xv | ||
cd aws-amplify-cypress-auth | ||
amplify init | ||
amplify add auth | ||
amplify push | ||
echo "executed all Amplify commands" |
This file contains 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,6 @@ | ||
#!/bin/sh -xv | ||
cd aws-amplify-cypress-api | ||
amplify init | ||
amplify add api | ||
amplify push | ||
echo "executed all Amplify commands" |
This file contains 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 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,69 @@ | ||
#!/usr/bin/expect | ||
spawn ./.circleci/com2.sh | ||
expect "Enter a name for the project" | ||
send -- "unauth\r" | ||
expect -exact "Choose your default editor:" | ||
send -- "\r" | ||
expect "Choose the type of app that you're building" | ||
send -- "\r" | ||
expect "Please tell us about your project\rWhat javascript framework are you using" | ||
send -- "\r" | ||
expect -exact "Source Directory Path:" | ||
send -- "\r" | ||
expect -exact "Distribution Directory Path:" | ||
send -- "\r" | ||
expect -exact "Build Command:" | ||
send -- "\r" | ||
expect -exact "Start Command:" | ||
send -- "\r" | ||
expect "Using default provider awscloudformation\nAWS access credentials can not be detected\n.Setup new user" | ||
send -- "n\r" | ||
expect "accessKeyId:" | ||
send -- "$env(ACCESS_KEY_ID)\r" | ||
expect "secretAccessKey:" | ||
send -- "$env(SECRET_ACCESS_KEY)\r" | ||
expect -exact "region:" | ||
send -- "\r" | ||
set timeout 70 | ||
expect "Please select from one of the below mentioned services\r" | ||
send -- "\033\[B\r" | ||
expect "Provide a friendly name for your resource to be used as a label for this category in the project:" | ||
send -- "myAPI\r" | ||
expect "Provide a path (e.g., /items)" | ||
send -- "\r" | ||
expect "Choose a Lambda source" | ||
send -- "\r" | ||
expect "Provide a friendly name for your resource to be used as a label for this category in the project:" | ||
send -- "\r" | ||
expect "Provide the AWS Lambda function name:" | ||
send -- "\r" | ||
expect "Choose the function template that you want to use:" | ||
send -- "\r" | ||
expect "Choose a DynamoDB data source option" | ||
send -- "\033\[B\r" | ||
expect "Please provide a friendly name for your resource that will be used to label this category in the project:" | ||
send -- "\r" | ||
expect "Please provide table name:" | ||
send -- "\r" | ||
expect "What would you like to name this column:" | ||
send -- "itemNo\r" | ||
expect "Please choose the data type:" | ||
send -- "\033\[B\r" | ||
expect "Would you like to add another column?" | ||
send -- "n\r" | ||
expect "Please choose partition key for the table:" | ||
send -- "\r" | ||
expect "Do you want to add a sort key to your table?" | ||
send -- "n\r" | ||
expect "Do you want to add global secondary indexes to your table?" | ||
send -- "n\r" | ||
expect "Do you want to edit the local lambda function now?" | ||
send -- "n\r" | ||
expect "Restrict API access" | ||
send -- "n\r" | ||
expect "Do you want to add another path?" | ||
send -- "N\r" | ||
set timeout 70 | ||
expect "Are you sure you want to continue?\r" | ||
send -- "Y\r" | ||
interact |
This file contains 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,33 @@ | ||
#!/usr/bin/expect | ||
spawn ./.circleci/com1.sh | ||
expect "Enter a name for the project" | ||
send -- "unauth\r" | ||
expect -exact "Choose your default editor:" | ||
send -- "\r" | ||
expect "Choose the type of app that you're building" | ||
send -- "\r" | ||
expect "Please tell us about your project\rWhat javascript framework are you using" | ||
send -- "\r" | ||
expect -exact "Source Directory Path:" | ||
send -- "\r" | ||
expect -exact "Distribution Directory Path:" | ||
send -- "\r" | ||
expect -exact "Build Command:" | ||
send -- "\r" | ||
expect -exact "Start Command:" | ||
send -- "\r" | ||
expect "Using default provider awscloudformation\nAWS access credentials can not be detected\n.Setup new user" | ||
send -- "n\r" | ||
expect "accessKeyId:" | ||
send -- "$env(ACCESS_KEY_ID)\r" | ||
expect "secretAccessKey:" | ||
send -- "$env(SECRET_ACCESS_KEY)\r" | ||
expect -exact "region:" | ||
send -- "\r" | ||
set timeout 70 | ||
expect "Do you want to use default authentication and security configuration?\r" | ||
send -- "\r" | ||
set timeout 70 | ||
expect "Are you sure you want to continue?\r" | ||
send -- "Y\r" | ||
interact |
This file contains 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 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,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000/" | ||
} |
This file contains 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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains 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,19 @@ | ||
|
||
describe('API test post and get', function() { | ||
beforeEach(function() { | ||
cy.visit('/') | ||
}) | ||
|
||
it('successfully adds data to dynamodb', function() { | ||
// Check for user not signed up | ||
cy.get('input[name=itemNo]').type('1') | ||
cy.get('.amplify-submit-put-button').contains('Put').click() | ||
cy.get('.amplify-put-result').contains('post call succeed!') | ||
}) | ||
|
||
it('successfully get data from dynamodb', function() { | ||
// Check for user not signed up | ||
cy.get('.amplify-submit-get-button').contains('Get').click() | ||
cy.get('.amplify-get-result').contains('"itemNo":1') | ||
}) | ||
}) |
This file contains 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,15 @@ | ||
|
||
describe('withAuthenticator Sign In', function() { | ||
beforeEach(function() { | ||
cy.visit('/') | ||
}) | ||
|
||
it('throws error when user is not signed up', function() { | ||
// Check for user not signed up | ||
cy.get('input[name=username]').type('testuser') | ||
cy.get('input[name=password]').type('testPassword') | ||
cy.get('.amplify-button').contains('Sign In').click() | ||
cy.get('.amplify-error-section').contains('User does not exist') | ||
}) | ||
}) | ||
|
This file contains 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,17 @@ | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
This file contains 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,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
This file contains 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,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains 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