Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
566916f
Add local e2e test for webpack
zxl629 Dec 27, 2024
409fd72
Fix yml error
zxl629 Dec 27, 2024
1c25d21
Fix yml error
zxl629 Dec 27, 2024
0451fc3
Fix yml error
zxl629 Dec 27, 2024
34da228
Fix yml error
zxl629 Dec 27, 2024
4da782f
Replace yarn with npm
zxl629 Dec 27, 2024
a8b5896
Fix yml
zxl629 Dec 27, 2024
b00984e
Test npm run
zxl629 Dec 27, 2024
e324477
Test npm run
zxl629 Dec 27, 2024
e6713eb
Test npm run
zxl629 Dec 27, 2024
37f5a2c
Test npm run
zxl629 Dec 27, 2024
426dcf5
Test npm run
zxl629 Dec 27, 2024
85e7299
Fix import bug
zxl629 Dec 30, 2024
65d465a
Fix broken existsSync import
zxl629 Dec 30, 2024
b2b0227
Delete unused import
zxl629 Dec 30, 2024
26ede80
Import parseArgs
zxl629 Dec 30, 2024
3331991
Add env in args
zxl629 Dec 30, 2024
f4ba407
Fix fml error
zxl629 Dec 30, 2024
93b07f5
Fix concurrently error
zxl629 Dec 30, 2024
66ee6ea
Fix concurrently empty command
zxl629 Dec 30, 2024
d0cfb80
Bug fix
zxl629 Dec 30, 2024
141dde8
Install wait-on
zxl629 Dec 30, 2024
fe4011e
Cache Cypress
zxl629 Dec 30, 2024
28413a8
Fix concurrently error handling
zxl629 Dec 30, 2024
e3af6c7
Concurrently version test
zxl629 Dec 30, 2024
390ed62
Restore concurrently version
zxl629 Dec 30, 2024
659aa8a
Fix concurrently error handling
zxl629 Dec 30, 2024
9e6ed11
Modify success condition of concurrently
zxl629 Dec 30, 2024
732ffd7
Test sigterm error handling
zxl629 Dec 31, 2024
b7e0088
Test
zxl629 Dec 31, 2024
aa1aa18
Test
zxl629 Dec 31, 2024
1e4207c
Fix error handling of concurrently
zxl629 Dec 31, 2024
df69953
Generalize e2e test workflow
zxl629 Jan 2, 2025
7716077
Bug fix
zxl629 Jan 2, 2025
95eb198
Bug fix
zxl629 Jan 2, 2025
219ae61
Bug fix
zxl629 Jan 3, 2025
3261d4b
Bug fix
zxl629 Jan 3, 2025
9cef5bc
Bug fix
zxl629 Jan 3, 2025
ec6b1b8
Fix wrong path
zxl629 Jan 3, 2025
80c46a6
Test e2e prod
zxl629 Jan 3, 2025
aa7f38b
Add serve to package dependency
zxl629 Jan 3, 2025
2e83b1b
Modify Cypress config
zxl629 Jan 3, 2025
306dfa7
Update webpack config
zxl629 Jan 3, 2025
851aa87
Bug fix
zxl629 Jan 3, 2025
61c4eb1
Modify test
zxl629 Jan 3, 2025
f505257
Modify index.html
zxl629 Jan 3, 2025
c571c9f
Test dev + prod
zxl629 Jan 4, 2025
aea7faa
Fix webpack bundle output file extension
zxl629 Jan 4, 2025
49cd570
Intentional pipeline failure
zxl629 Jan 6, 2025
0cdb7a8
Clean up
zxl629 Jan 6, 2025
974588f
Clean up
zxl629 Jan 6, 2025
551f86d
Exclude cypress from tsconfig
zxl629 Jan 6, 2025
2f3d686
Fix wrong script name
zxl629 Jan 6, 2025
d8a266e
Fix e2e runner test name
zxl629 Jan 6, 2025
8bcb65b
Move to cypress samples
zxl629 Jan 6, 2025
2a0e5e1
Update cypress samples path
zxl629 Jan 7, 2025
718c99a
Update docs
zxl629 Jan 7, 2025
bec3a18
Fix dependency conflicts
zxl629 Jan 7, 2025
10eaff5
Set changeset to empty
zxl629 Jan 7, 2025
15205b6
Delete old changesets
zxl629 Jan 7, 2025
7f9dfd8
Update e2e docs
zxl629 Jan 8, 2025
feaef09
Restore npm publish workflows
zxl629 Jan 8, 2025
a159a00
Clean up
zxl629 Jan 8, 2025
348ffa2
Clean up
zxl629 Jan 8, 2025
dfbb769
Fix e2e README
zxl629 Jan 9, 2025
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
2 changes: 2 additions & 0 deletions .changeset/heavy-brooms-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 1 addition & 0 deletions .github/actions/node-and-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ runs:
path: |
**/node_modules
**/dist/
/home/runner/.cache/Cypress
key: ${{ runner.os }}-build-artifacts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-artifacts-
Expand Down
7 changes: 7 additions & 0 deletions .github/integ-config/local-integ-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests:
- test_name: webpack_data_gen2
desc: 'Webpack 5'
framework: webpack
sample_name: basic-bundle
spec: bundle
browser: [chrome]
133 changes: 133 additions & 0 deletions .github/workflows/callable-local-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: E2E Test
run-name: e2e.${{ inputs.test_name }}

on:
workflow_call:
inputs:
test_name:
required: true
type: string
framework:
required: true
type: string
sample_name:
required: true
type: string
spec:
required: true
type: string
browser:
required: true
type: string
backend:
required: true
type: string
timeout_minutes:
required: true
type: number
retry_count:
required: true
type: number
npm_script:
required: false
type: string
npm_script_args:
required: false
type: number
env:
required: false
type: string

jobs:
e2e-test:
name: E2E ${{ inputs.test_name }}
runs-on: ubuntu-latest
strategy:
matrix:
browser:
- ${{ fromJson(inputs.browser) }}
sample_name:
- ${{ fromJson(inputs.sample_name) }}
fail-fast: false
timeout-minutes: ${{ inputs.timeout_minutes }}

steps:
- name: Checkout repository
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
path: amplify-data
- name: Setup node and build the repository
uses: ./amplify-data/.github/actions/node-and-build
- name: Load Verdaccio with AmplifyData
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we still need to use Verdaccio here since we are already pointing the @aws-amplify/data-schema dependency in our Cypress sample apps package.json file to the local package.

uses: ./amplify-data/.github/actions/load-verdaccio-with-amplify-data
- name: Make script executable
run: chmod +x ./amplify-data/scripts/retry-npm-script.sh
- name: Run cypress tests for ${{ inputs.test_name }} dev
shell: bash
working-directory: ./amplify-data
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_SAMPLE_NAME: ${{ matrix.sample_name }}
E2E_SPEC: ${{ inputs.spec }}
E2E_BROWSER: ${{ matrix.browser }}
E2E_BACKEND: ${{ inputs.backend }}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
E2E_NPM_SCRIPT: ${{ inputs.npm_script }}
E2E_ENV: ${{ inputs.env }}
run: |
if [ -z "$E2E_NPM_SCRIPT" ]; then
../amplify-data/scripts/retry-npm-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
dev \
$E2E_BACKEND \
--env $(echo $E2E_ENV | jq -r 'tostring')" \
$E2E_NPM_SCRIPT \
-n $E2E_RETRY_COUNT
else
echo "Skipping specialized yarn script execution in the dev environment."
fi
- name: Run cypress tests for ${{ inputs.test_name }} prod
shell: bash
working-directory: ./amplify-data
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_SAMPLE_NAME: ${{ matrix.sample_name }}
E2E_SPEC: ${{ inputs.spec }}
E2E_BROWSER: ${{ matrix.browser }}
E2E_BACKEND: ${{ inputs.backend }}
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
E2E_TEST_NAME: ${{ inputs.test_name }}
E2E_NPM_SCRIPT: ${{ inputs.npm_script }}
E2E_NPM_SCRIPT_ARGS: ${{ inputs.npm_script_args }}
E2E_ENV: ${{ inputs.env }}
run: |
if [ -z "$E2E_NPM_SCRIPT" ]; then
../amplify-data/scripts/retry-npm-script.sh -s \
"ci:test \
$E2E_FRAMEWORK \
$E2E_SAMPLE_NAME \
$E2E_SPEC \
$E2E_BROWSER \
prod \
$E2E_BACKEND \
--env $(echo $E2E_ENV | jq -r 'tostring')" \
$E2E_NPM_SCRIPT \
-n $E2E_RETRY_COUNT
else
npm run "$E2E_NPM_SCRIPT" "$E2E_NPM_SCRIPT_ARGS"
fi
- name: Upload artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: failure()
with:
name: ${{ inputs.test_name }}
if-no-files-found: ignore
path: |
cypress/videos
cypress/screenshots
retention-days: 14
38 changes: 38 additions & 0 deletions .github/workflows/callable-local-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,41 @@ jobs:
- name: Run tests
working-directory: ./amplify-data
run: npm run e2e-node:test

e2e-prep:
name: Get E2E test config
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: amplify-data
- name: Read integ config files
id: load_config
run: |
echo "INTEG_CONFIG=$(cat .github/integ-config/local-integ-all.yml | yq '.tests' -o=json | jq -c .)" >> $GITHUB_OUTPUT
working-directory: ./amplify-data
outputs:
integ-config: ${{ steps.load_config.outputs.INTEG_CONFIG }}

e2e-test-runner:
name: E2E test runnner
needs: e2e-prep
secrets: inherit
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config) }}
fail-fast: false
uses: ./.github/workflows/callable-local-e2e-test.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
framework: ${{ matrix.integ-config.framework }}
spec: ${{ matrix.integ-config.spec || '' }}
sample_name: ${{ toJSON(matrix.integ-config.sample_name) || '[""]' }}
browser: ${{ toJSON(matrix.integ-config.browser) || '[""]' }}
backend: ${{ matrix.integ-config.backend }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
retry_count: ${{ matrix.integ-config.retry_count || 3 }}
npm_script: ${{ matrix.integ-config.npm_script || '' }}
npm_script_args: ${{ matrix.integ-config.npm_script_args || 15 }}
env: ${{ matrix.integ-config.env && toJSON(matrix.integ-config.env) || '{}' }}
3 changes: 3 additions & 0 deletions .github/workflows/callable-release-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
needs:
- prebuild-ubuntu
uses: ./.github/workflows/callable-unit-tests.yml
# NOTE: "local-e2e" is a temporal naming to distinguish them from those pulled
# from amplify-js-samples-staging. Should be renamed once we move all e2e tests
# to the amplify-data repo.
local-e2e:
needs:
- prebuild-ubuntu
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ packages/*/temp

# rollup
**/.rollup.cache
**/buildMeta
**/buildMeta

# cypress
cypress/videos
cypress/screenshots
14 changes: 14 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'cypress';

export default defineConfig({
includeShadowDom: true,
defaultCommandTimeout: 30000,
experimentalWebKitSupport: true,
experimentalModifyObstructiveThirdPartyCode: true,
e2e: {
baseUrl: 'http://localhost:3000/',
specPattern: 'cypress/e2e/**/*.spec.cy.{ts,js}',
excludeSpecPattern: ['**/__snapshots__/*', '**/__image_snapshots__/*'],
},
chromeWebSecurity: false,
});
8 changes: 8 additions & 0 deletions cypress/e2e/webpack/bundle.spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('webpack spec', () => {
it('passes', () => {
cy.visit('http://localhost:3000');
cy.request('/main.bundle.js').then((response) => {
cy.log('main.bundle.js content:', response.body);
});
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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 will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
17 changes: 17 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.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'
8 changes: 8 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es2020",
"lib": ["esnext", "dom"],
"types": ["cypress"]
},
"include": ["**/*.ts", "../cypress.config.ts"]
}
18 changes: 9 additions & 9 deletions e2e-TEST-COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

The following table outlines the current e2e test coverage for various runtimes and environments in our project:

| Runtime/Environment | Status |
|---------------------|-----------|
| Chrome | [✅](.github/workflows/callable-e2e-test.yml) |
| Node | [✅](packages/e2e-tests/node/jest.config.ts) |
| Webpack | ⚠️ |
| Rollup | ⚠️ |
| Metro | ⚠️ |
| React Natives | ⚠️ |
| Runtime/Environment | Status |
| ------------------- | ------------------------------------------------------------------------------- |
| Chrome | [✅](.github/workflows/callable-e2e-test.yml) |
| Node | [✅](packages/e2e-tests/node/jest.config.ts) |
| Webpack | [✅](packages/e2e-tests/cypress-samples/webpack/basic-bundle/webpack.config.js) |
| Rollup | ⚠️ |
| Metro | ⚠️ |
| React Natives | ⚠️ |

Legend:

- ✅ Fully covered by e2e tests
- ⚠️ In progress
- N/A Not applicable or not planned

## Notes

- Click on the icons in the table to view relevant e2e test configurations or workflows.

Loading
Loading