Prechádzať zdrojové kódy

e2e: add tests for AWS (#3665)

Co-authored-by: Merlijn Vos <merlijn@soverin.net>
Antoine du Hamel 2 rokov pred
rodič
commit
51da2b5a79

+ 16 - 2
.env.example

@@ -14,12 +14,26 @@ COMPANION_SECRET=development
 # NOTE: Only enable this in development. Enabling it in production is a security risk
 COMPANION_ALLOW_LOCAL_URLS=true
 
-COMPANION_DROPBOX_KEY=***
-COMPANION_DROPBOX_SECRET=***
+# to enable S3
+COMPANION_AWS_KEY="YOUR AWS KEY"
+COMPANION_AWS_SECRET="YOUR AWS SECRET"
+# specifying a secret file will override a directly set secret
+# COMPANION_AWS_SECRET_FILE="PATH/TO/AWS/SECRET/FILE"
+COMPANION_AWS_BUCKET="YOUR AWS S3 BUCKET"
+COMPANION_AWS_REGION="AWS REGION"
+# to enable S3 Transfer Acceleration (default: false)
+# COMPANION_AWS_USE_ACCELERATE_ENDPOINT="false"
+# to set X-Amz-Expires query param in presigned urls (in seconds, default: 300)
+# COMPANION_AWS_EXPIRES="300"
+# to set a canned ACL for uploaded objects: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
+# COMPANION_AWS_ACL="public-read"
 
 COMPANION_BOX_KEY=***
 COMPANION_BOX_SECRET=***
 
+COMPANION_DROPBOX_KEY=***
+COMPANION_DROPBOX_SECRET=***
+
 COMPANION_GOOGLE_KEY=***
 COMPANION_GOOGLE_SECRET=***
 

+ 14 - 1
.github/workflows/e2e.yml

@@ -45,11 +45,24 @@ jobs:
         env:
           COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
           COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
+          VITE_COMPANION_URL: http://localhost:3020
           VITE_TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
           VITE_TRANSLOADIT_SECRET: ${{secrets.TRANSLOADIT_SECRET}}
           VITE_TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
           VITE_TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
-          CYPRESS_RECORD_KEY: ${{secrets.CYPRESS_RECORD_KEY}}
+          COMPANION_AWS_KEY: ${{secrets.COMPANION_AWS_KEY}}
+          COMPANION_AWS_SECRET: ${{secrets.COMPANION_AWS_SECRET}}
+          COMPANION_AWS_BUCKET: ${{secrets.COMPANION_AWS_BUCKET}}
+          COMPANION_AWS_REGION: ${{secrets.COMPANION_AWS_REGION}}
+          COMPANION_AWS_DISABLE_ACL: 'true'
+      - name: Upload videos in case of failure
+        uses: actions/upload-artifact@v3
+        if: failure()
+        with:
+          name: videos-and-screenshots
+          path: |
+            e2e/cypress/videos/
+            e2e/cypress/screenshots/
       - name: Remove 'pending end-to-end tests' label
         # Remove the 'pending end-to-end tests' label if tests ran successfully
         if: github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'pending end-to-end tests')

+ 16 - 0
e2e/clients/dashboard-aws-multipart/app.js

@@ -0,0 +1,16 @@
+import { Uppy } from '@uppy/core'
+import Dashboard from '@uppy/dashboard'
+import AwsS3 from '@uppy/aws-s3-multipart'
+
+import '@uppy/core/dist/style.css'
+import '@uppy/dashboard/dist/style.css'
+
+const uppy = new Uppy()
+  .use(Dashboard, { target: '#app', inline: true })
+  .use(AwsS3, {
+    limit: 2,
+    companionUrl: process.env.VITE_COMPANION_URL,
+  })
+
+// Keep this here to access uppy in tests
+window.uppy = uppy

+ 11 - 0
e2e/clients/dashboard-aws-multipart/index.html

@@ -0,0 +1,11 @@
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8"/>
+    <title>dashboard-aws-multipart</title>
+    <script defer type="module" src="app.js"></script>
+  </head>
+  <body>
+    <div id="app"></div>
+  </body>
+</html>

+ 16 - 0
e2e/clients/dashboard-aws/app.js

@@ -0,0 +1,16 @@
+import { Uppy } from '@uppy/core'
+import Dashboard from '@uppy/dashboard'
+import AwsS3 from '@uppy/aws-s3'
+
+import '@uppy/core/dist/style.css'
+import '@uppy/dashboard/dist/style.css'
+
+const uppy = new Uppy()
+  .use(Dashboard, { target: '#app', inline: true })
+  .use(AwsS3, {
+    limit: 2,
+    companionUrl: process.env.VITE_COMPANION_URL,
+  })
+
+// Keep this here to access uppy in tests
+window.uppy = uppy

+ 11 - 0
e2e/clients/dashboard-aws/index.html

@@ -0,0 +1,11 @@
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8"/>
+    <title>dashboard-aws</title>
+    <script defer type="module" src="app.js"></script>
+  </head>
+  <body>
+    <div id="app"></div>
+  </body>
+</html>

+ 2 - 0
e2e/clients/index.html

@@ -8,6 +8,8 @@
     <h1>Test apps</h1>
     <nav>
       <ul>
+				<li><a href="dashboard-aws/index.html">dashboard-aws</a></li>
+				<li><a href="dashboard-aws-multipart/index.html">dashboard-aws-multipart</a></li>
 				<li><a href="dashboard-compressor/index.html">dashboard-compressor</a></li>
 				<li><a href="react/index.html">react</a></li>
         <li><a href="dashboard-transloadit/index.html">dashboard-transloadit</a></li>

+ 3 - 0
e2e/cypress.config.mjs

@@ -1,5 +1,7 @@
 // eslint-disable-next-line import/no-extraneous-dependencies
 import { defineConfig } from 'cypress'
+// eslint-disable-next-line import/no-extraneous-dependencies
+import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter.js'
 
 export default defineConfig({
   defaultCommandTimeout: 16000,
@@ -11,6 +13,7 @@ export default defineConfig({
     // eslint-disable-next-line no-unused-vars
     setupNodeEvents (on, config) {
       // implement node event listeners here
+      installLogsPrinter(on)
     },
   },
 })

+ 13 - 0
e2e/cypress/integration/dashboard-aws-multipart.spec.ts

@@ -0,0 +1,13 @@
+describe('Dashboard with @uppy/aws-s3-multipart', () => {
+  beforeEach(() => {
+    cy.visit('/dashboard-aws-multipart')
+    cy.get('.uppy-Dashboard-input:first').as('file-input')
+  })
+
+  it('should upload cat image successfully', () => {
+    cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
+    cy.get('.uppy-StatusBar-actionBtn--upload').click()
+
+    cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
+  })
+})

+ 13 - 0
e2e/cypress/integration/dashboard-aws.spec.ts

@@ -0,0 +1,13 @@
+describe('Dashboard with @uppy/aws-s3', () => {
+  beforeEach(() => {
+    cy.visit('/dashboard-aws')
+    cy.get('.uppy-Dashboard-input:first').as('file-input')
+  })
+
+  it('should upload cat image successfully', () => {
+    cy.get('@file-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
+    cy.get('.uppy-StatusBar-actionBtn--upload').click()
+
+    cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete')
+  })
+})

+ 6 - 0
e2e/cypress/support/e2e.ts

@@ -18,3 +18,9 @@ import './commands'
 
 // Alternatively you can use CommonJS syntax:
 // require('./commands')
+
+// eslint-disable-next-line
+// @ts-ignore
+import installLogsCollector from  'cypress-terminal-report/src/installLogsCollector.js'
+
+installLogsCollector()

+ 1 - 0
e2e/package.json

@@ -46,6 +46,7 @@
   },
   "devDependencies": {
     "cypress": "^10.0.0",
+    "cypress-terminal-report": "^4.1.2",
     "deep-freeze": "^0.0.1",
     "parcel": "^2.0.1",
     "prompts": "^2.4.2",

+ 1 - 0
package.json

@@ -46,6 +46,7 @@
     "@babel/preset-env": "^7.14.7",
     "@babel/register": "^7.10.5",
     "@babel/types": "^7.17.0",
+    "@parcel/transformer-vue": "2.7.0",
     "@types/jasmine": "file:./private/@types/jasmine",
     "@types/jasminewd2": "file:./private/@types/jasmine",
     "@typescript-eslint/eslint-plugin": "^5.0.0",

+ 40 - 1
yarn.lock

@@ -4919,6 +4919,22 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@parcel/transformer-vue@npm:2.7.0":
+  version: 2.7.0
+  resolution: "@parcel/transformer-vue@npm:2.7.0"
+  dependencies:
+    "@parcel/diagnostic": 2.7.0
+    "@parcel/plugin": 2.7.0
+    "@parcel/source-map": ^2.0.0
+    "@parcel/utils": 2.7.0
+    "@vue/compiler-sfc": ^3.2.27
+    consolidate: ^0.16.0
+    nullthrows: ^1.1.1
+    semver: ^5.7.1
+  checksum: 564c98af47091b2a74e4419884429e66f82cda8ec589193d96c637eb670766ba8d21d1deef16c672bd2907783b7c4659ef53ae62e938da1245406b3c74edcc94
+  languageName: node
+  linkType: hard
+
 "@parcel/types@npm:2.7.0":
   version: 2.7.0
   resolution: "@parcel/types@npm:2.7.0"
@@ -7911,6 +7927,7 @@ __metadata:
     "@babel/preset-env": ^7.14.7
     "@babel/register": ^7.10.5
     "@babel/types": ^7.17.0
+    "@parcel/transformer-vue": 2.7.0
     "@types/jasmine": "file:./private/@types/jasmine"
     "@types/jasminewd2": "file:./private/@types/jasmine"
     "@typescript-eslint/eslint-plugin": ^5.0.0
@@ -9202,7 +9219,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@vue/compiler-sfc@npm:3.2.37":
+"@vue/compiler-sfc@npm:3.2.37, @vue/compiler-sfc@npm:^3.2.27":
   version: 3.2.37
   resolution: "@vue/compiler-sfc@npm:3.2.37"
   dependencies:
@@ -14296,6 +14313,20 @@ __metadata:
   languageName: node
   linkType: hard
 
+"cypress-terminal-report@npm:^4.1.2":
+  version: 4.1.2
+  resolution: "cypress-terminal-report@npm:4.1.2"
+  dependencies:
+    chalk: ^4.0.0
+    fs-extra: ^10.1.0
+    semver: ^7.3.5
+    tv4: ^1.3.0
+  peerDependencies:
+    cypress: ">=4.10.0"
+  checksum: e9ca354db3557969c87cd30d93646292d2166740d5f76995e5463779690845f51f7764e4ed405f86c46d685d8969b1dbf54d18518b4d7e08cddb60928c0825a5
+  languageName: node
+  linkType: hard
+
 "cypress@npm:^10.0.0":
   version: 10.6.0
   resolution: "cypress@npm:10.6.0"
@@ -15334,6 +15365,7 @@ __metadata:
     "@uppy/xhr-upload": "workspace:^"
     "@uppy/zoom": "workspace:^"
     cypress: ^10.0.0
+    cypress-terminal-report: ^4.1.2
     deep-freeze: ^0.0.1
     parcel: ^2.0.1
     prompts: ^2.4.2
@@ -35205,6 +35237,13 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
+"tv4@npm:^1.3.0":
+  version: 1.3.0
+  resolution: "tv4@npm:1.3.0"
+  checksum: 075096cf3bc2db5727650e16717a343954625c5fde6b2bb5553c86a9a5ca7b9fd287c0f5ab7ac03094f39e982fe9288dc715c7223a90e1684fd2263460a74bbd
+  languageName: node
+  linkType: hard
+
 "tweetnacl@npm:^0.14.3, tweetnacl@npm:~0.14.0":
   version: 0.14.5
   resolution: "tweetnacl@npm:0.14.5"