Upgrade harbor-portal to v2.9.0 (#18525)

1.Magrate protractor to cypress as protractor has been deprecated

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2023-04-13 18:52:06 +08:00 committed by GitHub
parent d3d6e29aa3
commit de6e517136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1207 additions and 159 deletions

2
.gitignore vendored
View File

@ -41,6 +41,8 @@ src/portal/src/lib/coverage
src/portal/ng-swagger-gen
src/portal/docker-build/nginx.conf
src/portal/.angular
src/portal/cypress/videos
src/portal/cypress/screenshots
**/npm*.log
**/*ngsummary.json

View File

@ -13,7 +13,7 @@
"project": [
"server/tsconfig.json",
"tsconfig.json",
"e2e/tsconfig.json"
"cypress/tsconfig.json"
],
"createDefaultProgram": true
},

View File

@ -112,7 +112,7 @@
"ng-swagger-gen": "^1.8.1",
// For e2e test. Required
"protractor": "^7.0.0",
"cypress": "latest"
// For code grammar checking. Optional
"eslint": "^8.12.0",

View File

@ -127,33 +127,24 @@
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"cypress/**/*.ts",
"server/**/*.ts",
"src/**/*.ts",
"src/**/*.html"
]
}
}
}
},
"harbor-portal-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.config.js",
"devServerTarget": "harbor-portal:serve"
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"lintFilePatterns": [
"e2e/**/*.ts",
"e2e/**/*.html"
]
"devServerTarget": "harbor-portal:serve",
"watch": false,
"headless": true
},
"configurations": {
"production": {
"devServerTarget": "harbor-portal:serve:production"
}
}
}
}
@ -168,6 +159,11 @@
}
},
"cli": {
"analytics": false
"analytics": false,
"schematicCollections": [
"@cypress/schematic",
"@cypress/schematic",
"@schematics/angular"
]
}
}

View File

@ -0,0 +1,7 @@
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:4200',
},
});

View File

@ -0,0 +1,6 @@
describe('Should open sign-in page', () => {
it('Will be redirected to sign-in page when visiting /', () => {
cy.visit('/');
cy.get('#log_in').should('be.visible');
});
});

View File

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}

View File

@ -0,0 +1,43 @@
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// This example commands.js 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) => { ... })

View File

@ -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
// ***********************************************************
// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';

View File

@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress"]
}
}

View File

@ -1,32 +0,0 @@
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ClaritySeedAppHome } from './app.po';
fdescribe('harbor-portal app', function () {
let expectedMsg: string =
'This is a Clarity seed application. This is the default page that loads for the application.';
let page: ClaritySeedAppHome;
beforeEach(() => {
page = new ClaritySeedAppHome();
});
it('should display: ' + expectedMsg, () => {
page.navigateTo();
page.getParagraphText().then(res => {
expect(res).toEqual(expectedMsg);
});
});
});

View File

@ -1,24 +0,0 @@
// Copyright Project Harbor Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { browser, element, by } from 'protractor';
export class ClaritySeedAppHome {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('my-app p')).getText();
}
}

View File

@ -1,24 +0,0 @@
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": "../",
"baseUrl": "",
"declaration": false,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist/out-tsc-e2e",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"types": [
"jasmine"
]
},
"exclude": [
"node_modules",
"dist"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "harbor",
"version": "2.8.0",
"version": "2.9.0",
"description": "Harbor UI with Clarity",
"angular-cli": {},
"scripts": {
@ -19,7 +19,7 @@
"test:headless": "ng test --watch=false --no-progress --code-coverage --browsers=ChromeNoSandboxHeadless",
"test:chrome-debug": "ng test --code-coverage --browsers Chrome --watch",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"e2e": "ng e2e",
"build": "ng build --aot",
"release": "ng build --configuration production",
"build-mock-api-server": "tsc -p server",
@ -61,6 +61,7 @@
"@angular-eslint/template-parser": "15.1.0",
"@angular/cli": "^15.2.1",
"@angular/compiler-cli": "^15.2.1",
"@cypress/schematic": "^2.5.0",
"@types/express": "^4.17.12",
"@types/jasmine": "~4.3.1",
"@types/node": "^16.11.6",
@ -81,12 +82,12 @@
"ng-swagger-gen": "^1.8.1",
"prettier": "^2.6.2",
"prettier-eslint": "^14.0.2",
"protractor": "^7.0.0",
"stylelint": "^14.8.5",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-prettier-scss": "^0.0.1",
"stylelint-config-standard": "^25.0.0",
"stylelint-config-standard-scss": "^4.0.0",
"typescript": "~4.8.2"
"typescript": "~4.8.2",
"cypress": "latest"
}
}

View File

@ -1,32 +0,0 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
}
};

View File

@ -17,5 +17,6 @@
"dom"
],
"useDefineForClassFields": false
}
},
"exclude": ["cypress.config.ts"],
}