-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #825 from aws-amplify/feature/gen2-release
Merge feature/gen2-release to main
- Loading branch information
Showing
49 changed files
with
11,410 additions
and
78 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
17 changes: 17 additions & 0 deletions
17
packages/amplify-codegen-e2e-tests/src/__tests__/graphql-generator-app.test.ts
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 @@ | ||
import { DEFAULT_JS_CONFIG, craInstall, craBuild, cypressRun, isWindows } from '@aws-amplify/amplify-codegen-e2e-core'; | ||
import path from 'path'; | ||
|
||
describe('GraphQL documents generator e2e tests', () => { | ||
let apiName: string; | ||
const projectRoot = path.resolve('test-apps', 'graphql-generator-app'); | ||
const config = DEFAULT_JS_CONFIG; | ||
|
||
beforeAll(async () => { | ||
await craInstall(projectRoot, { ...config }); | ||
}); | ||
|
||
// skip cypress test on windows | ||
(isWindows() ? it.skip : it)('graphql generator does not crash in browser', async () => { | ||
await cypressRun(projectRoot, { componentsTesting: true }); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/.gitignore
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,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
46 changes: 46 additions & 0 deletions
46
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/README.md
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,46 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
45 changes: 45 additions & 0 deletions
45
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/config-overrides.js
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,45 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
module.exports = function override(config) { | ||
const alias = config.resolve.alias || {}; | ||
Object.assign(alias, { | ||
'fs-extra': path.resolve(__dirname, 'src/polyfills/fs-extra.js'), | ||
}); | ||
config.resolve.alias = alias; | ||
const fallback = config.resolve.fallback || {}; | ||
Object.assign(fallback, { | ||
path: require.resolve('path-browserify'), | ||
os: require.resolve('os-browserify/browser'), | ||
stream: require.resolve('stream-browserify'), | ||
crypto: require.resolve('crypto-browserify'), | ||
assert: require.resolve('assert'), | ||
'fs-extra': false, | ||
vm: false, | ||
fs: false, | ||
module: false, | ||
constants: false, | ||
}); | ||
config.resolve.fallback = fallback; | ||
config.plugins = (config.plugins || []).concat([ | ||
new webpack.ProvidePlugin({ | ||
Buffer: ['buffer', 'Buffer'], | ||
}), | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
}), | ||
new webpack.ProvidePlugin({ | ||
'process.hrtime': [path.resolve(__dirname, 'src/polyfills/process-shim.js'), 'default'], | ||
}), | ||
]); | ||
config.ignoreWarnings = [/Failed to parse source map/]; | ||
config.module.rules.push({ | ||
test: /\.(js|mjs|jsx)$/, | ||
enforce: 'pre', | ||
loader: require.resolve('source-map-loader'), | ||
resolve: { | ||
fullySpecified: false, | ||
}, | ||
}); | ||
return config; | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/cypress.config.ts
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,13 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
process.env.NODE_ENV = 'test'; | ||
process.env.BABEL_ENV = 'test'; | ||
require('react-app-rewired/config/webpack.config')('development'); | ||
export default defineConfig({ | ||
component: { | ||
devServer: { | ||
framework: 'create-react-app', | ||
bundler: 'webpack', | ||
}, | ||
}, | ||
}); |
2 changes: 2 additions & 0 deletions
2
...ges/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/cypress/support/commands.ts
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,2 @@ | ||
/// <reference types="cypress" /> | ||
// This file needs to exist for cypress tests to function |
12 changes: 12 additions & 0 deletions
12
...fy-codegen-e2e-tests/test-apps/graphql-generator-app/cypress/support/component-index.html
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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>Components App</title> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html> |
39 changes: 39 additions & 0 deletions
39
...es/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/cypress/support/component.ts
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,39 @@ | ||
// *********************************************************** | ||
// This example support/component.ts 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') | ||
|
||
import { mount } from 'cypress/react18' | ||
|
||
// Augment the Cypress namespace to include type definitions for | ||
// your custom command. | ||
// Alternatively, can be defined in cypress/support/component.d.ts | ||
// with a <reference path="./component" /> at the top of your spec. | ||
declare global { | ||
namespace Cypress { | ||
interface Chainable { | ||
mount: typeof mount | ||
} | ||
} | ||
} | ||
|
||
Cypress.Commands.add('mount', mount) | ||
|
||
// Example use: | ||
// cy.mount(<MyComponent />) |
54 changes: 54 additions & 0 deletions
54
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/package.json
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,54 @@ | ||
{ | ||
"name": "graphql-generator-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@aws-amplify/appsync-modelgen-plugin": "file:../../../appsync-modelgen-plugin", | ||
"@aws-amplify/graphql-generator": "file:../../../graphql-generator", | ||
"@testing-library/jest-dom": "^5.17.0", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/user-event": "^13.5.0", | ||
"@types/jest": "^27.5.2", | ||
"@types/node": "^16.18.91", | ||
"@types/react": "^18.2.67", | ||
"@types/react-dom": "^18.2.22", | ||
"assert": "^2.1.0", | ||
"crypto-browserify": "^3.12.0", | ||
"os-browserify": "^0.3.0", | ||
"path-browserify": "^1.0.1", | ||
"process": "^0.11.10", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-scripts": "5.0.1", | ||
"typescript": "^4.9.5", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"scripts": { | ||
"start": "react-app-rewired start", | ||
"build": "react-app-rewired build", | ||
"test": "react-app-rewired test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"cypress": "^13.7.1", | ||
"react-app-rewired": "^2.2.1" | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/public/index.html
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,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
23 changes: 23 additions & 0 deletions
23
packages/amplify-codegen-e2e-tests/test-apps/graphql-generator-app/src/App.cy.js
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,23 @@ | ||
import React from 'react'; | ||
import App from './App'; | ||
|
||
describe('graphql-generator does not crash in browser', () => { | ||
beforeEach(() => { | ||
cy.mount(<App />); | ||
}); | ||
|
||
const testCases = [ | ||
'generate-models-java', | ||
'generate-models-javascript', | ||
'generate-models-typescript', | ||
'generate-models-dart', | ||
'generate-models-introspection', | ||
]; | ||
|
||
testCases.forEach(testCase => { | ||
it(testCase, {}, () => { | ||
cy.get(`#${testCase}_button`).click(); | ||
cy.get(`#${testCase}_result`).contains('✅', { timeout: 5000 }); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.