Skip to content
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

Acceptance Test POC and Setup #41

Merged
merged 42 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a058659
chore: Add tests workspace and ignore cypress gens
slaymance Jun 11, 2021
02bc418
build(acceptance-tests): setup cypress testing and typescript suppport
slaymance Jun 11, 2021
5d587af
test(acceptance-tests): add sample test for SignIn
slaymance Jun 11, 2021
68a2a84
Update cucumber and cypress tests
slaymance Jun 16, 2021
7f8825b
Revert lock file changes
slaymance Jun 16, 2021
9ee1d35
Merge remote-tracking branch 'origin/main' into acceptance-tests
slaymance Jun 16, 2021
e52c9ae
Update lock file with package changes
slaymance Jun 16, 2021
99f880e
Fix conflict
slaymance Jun 17, 2021
13ab7d5
Merge remote-tracking branch 'origin/main' into acceptance-tests
slaymance Jun 18, 2021
c5164be
Move acceptance-tests to packages/e2e
ericclemmons Jun 18, 2021
4b5fcda
Merge branch 'main' of github.com:aws-amplify/amplify-ui into accepta…
ericclemmons Jun 18, 2021
b2e29ca
Use aws-amplify@latest for all packages
ericclemmons Jun 18, 2021
1271db5
Add aws-amplify-react for testing
ericclemmons Jun 18, 2021
4deafc1
Add @aws-amplify/ui-react-v1 for explicitly testing the previous version
ericclemmons Jun 18, 2021
8a49fd6
Update yarn.lock to match
ericclemmons Jun 18, 2021
b8859e1
Sign In with valid/invalid credentials tests
ericclemmons Jun 18, 2021
1ba2ac7
Ignore .env.local
ericclemmons Jun 18, 2021
cd85c1e
Merge remote-tracking branch 'origin/acceptance-tests' into acceptanc…
slaymance Jun 21, 2021
037de1a
Prototype CONTRIBUTING.md
ericclemmons Jun 21, 2021
aec2801
Merge remote-tracking branch 'origin/acceptance-tests' into acceptanc…
slaymance Jun 21, 2021
472699d
Update ignored files and lockfile
slaymance Jun 21, 2021
f44d245
Add Cypress env variables and use scenario outline
slaymance Jun 21, 2021
6b9eb06
Remove acceptance-tests workspace
slaymance Jun 21, 2021
ad53122
Rename test to use .steps.ts and type button name
slaymance Jun 21, 2021
5dc5c34
Revert feature steps to separate explicit scenarios
slaymance Jun 22, 2021
57f75c4
Render acceptance tests by convention
ericclemmons Jun 22, 2021
22c0e05
Merge branch 'acceptance-tests' of github.com:aws-amplify/amplify-ui …
ericclemmons Jun 22, 2021
12e4708
Add `key` to prevent warnings
ericclemmons Jun 22, 2021
62e8854
Reconfigure .gitignore options
slaymance Jun 23, 2021
2be7cd7
Rename tests directory to conventional "integration"
slaymance Jun 23, 2021
5f82de6
Replace dotenv with dotenv-safe
slaymance Jun 23, 2021
743b537
Revert changes to SignIn component
slaymance Jun 23, 2021
efd55fd
Rename example env file
slaymance Jun 23, 2021
133beb6
Remove unnecessary cypress-cucumber-preprocessor config option
slaymance Jun 23, 2021
4e91365
Update lockfile
slaymance Jun 23, 2021
05aea11
Remove ignored cypress dirs from root
slaymance Jun 23, 2021
663e4db
Fix path to feature tests
ericclemmons Jun 23, 2021
71a9d67
Type featureTests
ericclemmons Jun 23, 2021
60499a9
Remove example.json from fixtuers/
slaymance Jun 23, 2021
a014113
Organize imports
ericclemmons Jun 23, 2021
aed65c9
Amplify typo
ericclemmons Jun 23, 2021
e9795ee
Merge branch 'acceptance-tests' of github.com:aws-amplify/amplify-ui …
ericclemmons Jun 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
*.log
node_modules
aws-exports.js
aws-exports.ts
aws-exports.ts

# testing
acceptance-tests/cypress/screenshots
acceptance-tests/cypress/videos
ericclemmons marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions acceptance-tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:3000/",
"testFiles": ["**/*.{feature,features}"],
"integrationFolder": "cypress/tests"
}
26 changes: 26 additions & 0 deletions acceptance-tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference types="cypress" />
// ***********************************************************
// 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
// ***********************************************************

const cucumber = require("cypress-cucumber-preprocessor").default;
const resolve = require("resolve");

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
const options = {
typescript: resolve.sync("typescript", { baseDir: config.projectRoot })
};
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on("file:preprocessor", cucumber(options));
};
22 changes: 22 additions & 0 deletions acceptance-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ***********************************************
// 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 will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import "@testing-library/cypress/add-commands";
20 changes: 20 additions & 0 deletions acceptance-tests/cypress/support/index.js
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')
12 changes: 12 additions & 0 deletions acceptance-tests/cypress/tests/acceptance/SignIn.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Authentication
ericclemmons marked this conversation as resolved.
Show resolved Hide resolved

Amplify's Authenticator is a wrapper for a developer's application.
It provides an application with authentication features using AWS Cognito.
Its features include sign in, sign up, and sign out.

Scenario: Sign in with invalid credentials
Given I'm at the sign in page
When I type an invalid email address "fake@email.com"
And I type an invalid password "fakepassword"
And I attempt to sign in
Then I see the error "User does not exist."
21 changes: 21 additions & 0 deletions acceptance-tests/cypress/tests/acceptance/SignIn/SignIn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { And, Given, Then, When } from "cypress-cucumber-preprocessor/steps";

Given("I'm at the sign in page", () => {
cy.visit("/auth");
});

When("I type an invalid email address {string}", (email: string) => {
cy.findByRole("textbox", { name: /username/i }).type(email);
});

And("I type an invalid password {string}", (password: string) => {
cy.findByLabelText(/password/i).type(password);
});

And("I attempt to sign in", () => {
cy.findByRole("button", { name: "Sign In" }).click();
});

Then("I see the error {string}", (errorMessage: string) => {
cy.findByRole("alert", { name: /error/i }).should("contain", errorMessage);
});
21 changes: 21 additions & 0 deletions acceptance-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "cypress",
"version": "0.0.1",
"license": "MIT",
"private": true,
"scripts": {
"cypress:open": "TZ=UTC cypress open",
"cypress:run": "TZ=UTC cypress run"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true,
"stepDefinitions": "cypress/tests"
},
"devDependencies": {
"@testing-library/cypress": "^7.0.6",
"@types/cypress-cucumber-preprocessor": "^4.0.0",
"cypress": "^7.5.0",
"cypress-cucumber-preprocessor": "^4.1.2",
"typescript": "^4.3.2"
}
}
8 changes: 8 additions & 0 deletions acceptance-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@testing-library/cypress"]
},
"include": ["**/*.ts"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"docs",
"vue-docs",
"angular-docs",
"packages/*"
"packages/*",
"acceptance-tests"
ericclemmons marked this conversation as resolved.
Show resolved Hide resolved
],
"resolutions": {
"@mdx-js/mdx/**/trim": "^0.0.3",
Expand Down
Loading