Selaa lähdekoodia

Client E2E tests first step

Chocobozzz 6 vuotta sitten
vanhempi
commit
74af5a8361

+ 25 - 3
client/angular.json

@@ -50,6 +50,22 @@
                   "with": "src/environments/environment.prod.ts"
                 }
               ]
+            },
+            "hmr": {
+              "fileReplacements": [
+                {
+                  "replace": "src/environments/environment.ts",
+                  "with": "src/environments/environment.hmr.ts"
+                }
+              ]
+            },
+            "e2e": {
+              "fileReplacements": [
+                {
+                  "replace": "src/environments/environment.ts",
+                  "with": "src/environments/environment.e2e.ts"
+                }
+              ]
             }
           }
         },
@@ -61,6 +77,12 @@
           "configurations": {
             "production": {
               "browserTarget": "PeerTube:build:production"
+            },
+            "hmr": {
+              "browserTarget": "PeerTube:build:hmr"
+            },
+            "e2e": {
+              "browserTarget": "PeerTube:build:e2e"
             }
           }
         },
@@ -102,15 +124,15 @@
       }
     },
     "PeerTube-e2e": {
-      "root": "",
+      "root": "e2e/",
       "sourceRoot": "",
       "projectType": "application",
       "architect": {
         "e2e": {
           "builder": "@angular-devkit/build-angular:protractor",
           "options": {
-            "protractorConfig": "./protractor.conf.js",
-            "devServerTarget": "PeerTube:serve"
+            "protractorConfig": "e2e/protractor.conf.js",
+            "devServerTarget": "PeerTube:serve:e2e"
           }
         },
         "lint": {

+ 29 - 0
client/e2e/protractor.conf.js

@@ -0,0 +1,29 @@
+// Protractor configuration file, see link for more information
+// https://github.com/angular/protractor/blob/master/lib/config.ts
+
+const {SpecReporter} = require('jasmine-spec-reporter')
+
+exports.config = {
+  allScriptsTimeout: 11000,
+  specs: [
+    './src/**/*.e2e-spec.ts'
+  ],
+  capabilities: {
+    'browserName': 'chrome'
+  },
+  directConnect: true,
+  baseUrl: 'http://localhost:4200/',
+  framework: 'jasmine',
+  jasmineNodeOpts: {
+    showColors: true,
+    defaultTimeoutInterval: 30000,
+    print: function () {}
+  },
+
+  onPrepare () {
+    require('ts-node').register({
+      project: require('path').join(__dirname, './tsconfig.e2e.json')
+    })
+    jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}))
+  }
+}

+ 14 - 0
client/e2e/src/app.e2e-spec.ts

@@ -0,0 +1,14 @@
+import { AppPage } from './app.po'
+
+describe('PeerTube app', () => {
+  let page: AppPage
+
+  beforeEach(() => {
+    page = new AppPage()
+  })
+
+  it('should display the app title', () => {
+    page.navigateTo()
+    expect(page.getHeaderTitle()).toEqual('PeerTube')
+  })
+})

+ 12 - 0
client/e2e/src/app.po.ts

@@ -0,0 +1,12 @@
+import { browser, by, element } from 'protractor'
+
+export class AppPage {
+  navigateTo () {
+    browser.waitForAngularEnabled(false)
+    return browser.get('/')
+  }
+
+  getHeaderTitle () {
+    return element(by.css('.instance-name')).getText()
+  }
+}

+ 9 - 0
client/e2e/src/video-upload.e2e-spec.ts

@@ -0,0 +1,9 @@
+import { VideoUploadPage } from './video-upload.po'
+
+describe('Video upload', () => {
+  let page: VideoUploadPage
+
+  beforeEach(() => {
+    page = new VideoUploadPage()
+  })
+})

+ 7 - 0
client/e2e/src/video-upload.po.ts

@@ -0,0 +1,7 @@
+import { browser } from 'protractor'
+
+export class VideoUploadPage {
+  navigateTo () {
+    return browser.get('/videos/upload')
+  }
+}

+ 9 - 0
client/e2e/src/video-watch.e2e-spec.ts

@@ -0,0 +1,9 @@
+import { VideoWatchPage } from './video-watch.po'
+
+describe('Video watch', () => {
+  let page: VideoWatchPage
+
+  beforeEach(() => {
+    page = new VideoWatchPage()
+  })
+})

+ 8 - 0
client/e2e/src/video-watch.po.ts

@@ -0,0 +1,8 @@
+import { browser } from 'protractor'
+
+export class VideoWatchPage {
+  navigateTo () {
+    browser.waitForAngularEnabled(false)
+    return browser.get('/')
+  }
+}

+ 13 - 0
client/e2e/tsconfig.e2e.json

@@ -0,0 +1,13 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "outDir": "../out-tsc/app",
+    "module": "commonjs",
+    "target": "es5",
+    "types": [
+      "jasmine",
+      "jasminewd2",
+      "node"
+    ]
+  }
+}

+ 20 - 10
client/package.json

@@ -26,18 +26,18 @@
   },
   "devDependencies": {
     "@angular-devkit/build-angular": "~0.6.1",
-    "@angular/animations": "~6.0.1",
+    "@angular/animations": "~6.0.2",
     "@angular/cli": "6.0.1",
-    "@angular/common": "~6.0.1",
-    "@angular/compiler": "~6.0.1",
-    "@angular/compiler-cli": "~6.0.1",
-    "@angular/core": "~6.0.1",
-    "@angular/forms": "~6.0.1",
-    "@angular/http": "~6.0.1",
+    "@angular/common": "~6.0.2",
+    "@angular/compiler": "~6.0.2",
+    "@angular/compiler-cli": "~6.0.2",
+    "@angular/core": "~6.0.2",
+    "@angular/forms": "~6.0.2",
+    "@angular/http": "~6.0.2",
     "@angular/language-service": "^6.0.1",
-    "@angular/platform-browser": "~6.0.1",
-    "@angular/platform-browser-dynamic": "~6.0.1",
-    "@angular/router": "~6.0.1",
+    "@angular/platform-browser": "~6.0.2",
+    "@angular/platform-browser-dynamic": "~6.0.2",
+    "@angular/router": "~6.0.2",
     "@angular/service-worker": "^6.0.1",
     "@angularclass/hmr": "^2.1.3",
     "@ngx-loading-bar/core": "^1.1.1",
@@ -45,6 +45,8 @@
     "@ngx-loading-bar/router": "^1.2.0",
     "@ngx-meta/core": "^6.0.0-rc.1",
     "@types/core-js": "^0.9.28",
+    "@types/jasmine": "^2.8.7",
+    "@types/jasminewd2": "^2.0.3",
     "@types/lodash-es": "^4.17.0",
     "@types/markdown-it": "^0.0.4",
     "@types/node": "^9.3.0",
@@ -62,6 +64,13 @@
     "extract-text-webpack-plugin": "4.0.0-beta.0",
     "file-loader": "^1.1.5",
     "html-webpack-plugin": "^3.2.0",
+    "jasmine-core": "^3.1.0",
+    "jasmine-spec-reporter": "^4.2.1",
+    "karma": "^2.0.2",
+    "karma-chrome-launcher": "^2.2.0",
+    "karma-coverage-istanbul-reporter": "^1.4.2",
+    "karma-jasmine": "^1.1.2",
+    "karma-jasmine-html-reporter": "^1.1.0",
     "linkifyjs": "^2.1.5",
     "lodash-es": "^4.17.4",
     "markdown-it": "^8.4.0",
@@ -72,6 +81,7 @@
     "node-sass": "^4.1.1",
     "npm-font-source-sans-pro": "^1.0.2",
     "primeng": "^5.2.6",
+    "protractor": "^5.3.2",
     "purify-css": "^1.2.5",
     "purifycss-webpack": "^0.7.0",
     "raw-loader": "^0.5.1",

+ 16 - 16
client/src/app/app-routing.module.ts

@@ -4,22 +4,22 @@ import { RouterModule, Routes } from '@angular/router'
 import { PreloadSelectedModulesList } from './core'
 
 const routes: Routes = [
-  {
-    path: 'admin',
-    loadChildren: './+admin/admin.module#AdminModule'
-  },
-  {
-    path: 'my-account',
-    loadChildren: './+my-account/my-account.module#MyAccountModule'
-  },
-  {
-    path: 'accounts',
-    loadChildren: './+accounts/accounts.module#AccountsModule'
-  },
-  {
-    path: 'video-channels',
-    loadChildren: './+video-channels/video-channels.module#VideoChannelsModule'
-  }
+  // {
+  //   path: 'admin',
+  //   loadChildren: './+admin/admin.module#AdminModule'
+  // },
+  // {
+  //   path: 'my-account',
+  //   loadChildren: './+my-account/my-account.module#MyAccountModule'
+  // },
+  // {
+  //   path: 'accounts',
+  //   loadChildren: './+accounts/accounts.module#AccountsModule'
+  // },
+  // {
+  //   path: 'video-channels',
+  //   loadChildren: './+video-channels/video-channels.module#VideoChannelsModule'
+  // }
 ]
 
 @NgModule({

+ 5 - 0
client/src/environments/environment.e2e.ts

@@ -0,0 +1,5 @@
+export const environment = {
+  production: false,
+  hmr: false,
+  apiUrl: 'http://localhost:9001'
+}

+ 5 - 0
client/src/environments/environment.hmr.ts

@@ -0,0 +1,5 @@
+export const environment = {
+  production: false,
+  hmr: true,
+  apiUrl: 'http://localhost:9000'
+}

+ 1 - 1
client/src/environments/environment.ts

@@ -4,6 +4,6 @@
 
 export const environment = {
   production: false,
-  hmr: true,
+  hmr: false,
   apiUrl: 'http://localhost:9000'
 }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 472 - 46
client/yarn.lock


+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "url": "git://github.com/Chocobozzz/PeerTube.git"
   },
   "scripts": {
+    "e2e": "scripty",
     "build": "SCRIPTY_PARALLEL=true scripty",
     "build:server": "scripty",
     "build:client": "scripty",

+ 11 - 0
scripts/e2e.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -eu
+
+#npm run build:server
+npm run clean:server:test
+
+concurrently -k -s first \
+    "cd client && npm run ng -- e2e" \
+    "NODE_ENV=test NODE_APP_INSTANCE=1 npm start"
+

+ 1 - 1
scripts/watch/client.sh

@@ -4,4 +4,4 @@ set -eu
 
 cd client
 
-npm run ng -- serve --hmr --host 0.0.0.0 --disable-host-check --port 3000
+npm run ng -- serve --hmr --configuration hmr --host 0.0.0.0 --disable-host-check --port 3000

+ 1 - 1
server.ts

@@ -95,7 +95,7 @@ if (isTestInstance()) {
       req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
     ) {
       return (cors({
-        origin: 'http://localhost:3000',
+        origin: '*',
         exposedHeaders: 'Retry-After',
         credentials: true
       }))(req, res, next)

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä