[ADF-5183] Upgrade to Angular 10 (#1506)

* upgrade preparation fixes

* remove fdescribe

* update browserlist config

* ng8

* ngrx 8

* ng9

* ngrx 9

* remove entryComponents

* unit tests

* ng 10

* latest ADF

* fix unit tests

* fix lint

* update deps and travis

* code fixes

* upgrade webdriver

* cleanup libs

* fix test

* update test

* Use browserTarget as target for lite-serve

* Use the update webdriver with CI condition

* Use version console.log('load', path

* Fix path sh

* Try to use remote env

* Add the . to export variabled

* Use hardcoded chrome version

* Remove the run remote

* Avoid to use the escape

* Skip flaky e2e and raise issue ACA-3615

* SKip failing e2e

* Skip flaky e2e and raise issue ACA-3615

* Fix close app toolbar menu and preconditions + tests of  mark-favorite.test.ts  Personal Files section

* Fix mark-favorite tests

* Fix ext-header test

* Fix new-menu tests

* Fix lint

* no message

* Fix viewer tests

Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
This commit is contained in:
Denys Vuika
2020-07-09 09:37:06 +01:00
committed by GitHub
co-authored by maurizio vitale Cristina Jalba
parent 4ac1b8d7dd
commit 2854c17cd9
139 changed files with 11641 additions and 7776 deletions
+17
View File
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
+8 -9
View File
@@ -1,7 +1,8 @@
dist: trusty dist: bionic
sudo: required sudo: required
services: services:
- docker - docker
- xvfb
addons: addons:
chrome: stable chrome: stable
language: node_js language: node_js
@@ -21,8 +22,6 @@ branches:
before_install: before_install:
- sudo /etc/init.d/postgresql stop - sudo /etc/init.d/postgresql stop
- npm install -g npm@latest - npm install -g npm@latest
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 - sleep 3
- . ./scripts/ci/job_hooks/before_install.sh - . ./scripts/ci/job_hooks/before_install.sh
@@ -74,37 +73,37 @@ jobs:
- stage: e2e - stage: e2e
name: Test Suite appNavigation&search name: Test Suite appNavigation&search
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "authentication,listViews,navigation,application,pagination,search" script: ng run app-e2e:e2elite --suite "authentication,listViews,navigation,application,pagination,search"
after_script: ./start.sh -d after_script: ./start.sh -d
- name: Test Suite actionsAvailable - name: Test Suite actionsAvailable
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "actionsAvailable" script: ng run app-e2e:e2elite --suite "actionsAvailable"
after_script: ./start.sh -d after_script: ./start.sh -d
- name: Test Suite addRemoveContent - name: Test Suite addRemoveContent
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "addRemoveContent" script: ng run app-e2e:e2elite --suite "addRemoveContent"
after_script: ./start.sh -d after_script: ./start.sh -d
- name: Test Suite manageContent - name: Test Suite manageContent
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "manageContent" script: ng run app-e2e:e2elite --suite "manageContent"
after_script: ./start.sh -d after_script: ./start.sh -d
- name: Test Suite sharingContent&markFavorite - name: Test Suite sharingContent&markFavorite
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "sharingContent" script: ng run app-e2e:e2elite --suite "sharingContent"
after_script: ./start.sh -d after_script: ./start.sh -d
- name: Test Suite viewContent&metadata&extensions - name: Test Suite viewContent&metadata&extensions
before_script: before_script:
- ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a"
- ./start.sh - ./start.sh
script: ng run app-e2e:e2elite --suite "viewer,infoDrawer,extensions" script: ng run app-e2e:e2elite --suite "viewer,infoDrawer,extensions"
after_script: ./start.sh -d after_script: ./start.sh -d
+26 -6
View File
@@ -11,6 +11,7 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"aot": true,
"outputPath": "dist/app", "outputPath": "dist/app",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
@@ -85,8 +86,7 @@
"node_modules/pdfjs-dist/build/pdf.js", "node_modules/pdfjs-dist/build/pdf.js",
"node_modules/pdfjs-dist/web/pdf_viewer.js", "node_modules/pdfjs-dist/web/pdf_viewer.js",
"node_modules/moment/min/moment.min.js" "node_modules/moment/min/moment.min.js"
], ]
"es5BrowserSupport": true
}, },
"configurations": { "configurations": {
"production": { "production": {
@@ -117,10 +117,20 @@
"name": "vendor", "name": "vendor",
"maximumWarning": "10mb", "maximumWarning": "10mb",
"maximumError": "15mb" "maximumError": "15mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
} }
] ]
}, },
"e2e": { "e2e": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true, "optimization": true,
"outputHashing": "all", "outputHashing": "all",
"sourceMap": false, "sourceMap": false,
@@ -160,7 +170,7 @@
"builder": "@angular-custom-builders/lite-serve:dist-serve", "builder": "@angular-custom-builders/lite-serve:dist-serve",
"options": { "options": {
"publicHost": "http://localhost:4200", "publicHost": "http://localhost:4200",
"outputPath": "dist/app" "browserTarget": "app:build"
} }
}, },
"extract-i18n": { "extract-i18n": {
@@ -285,7 +295,12 @@
"tsConfig": "projects/adf-office-services-ext/tsconfig.lib.json", "tsConfig": "projects/adf-office-services-ext/tsconfig.lib.json",
"project": "projects/adf-office-services-ext/ng-package.json" "project": "projects/adf-office-services-ext/ng-package.json"
} }
}, , "configurations": {
"production": {
"tsConfig": "projects/adf-office-services-ext/tsconfig.lib.prod.json"
}
}
},
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
@@ -320,7 +335,12 @@
"tsConfig": "projects/aca-shared/tsconfig.lib.json", "tsConfig": "projects/aca-shared/tsconfig.lib.json",
"project": "projects/aca-shared/ng-package.json" "project": "projects/aca-shared/ng-package.json"
} }
}, , "configurations": {
"production": {
"tsConfig": "projects/aca-shared/tsconfig.lib.prod.json"
}
}
},
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
@@ -354,7 +374,7 @@
"schematics": { "schematics": {
"@schematics/angular:component": { "@schematics/angular:component": {
"prefix": "aca", "prefix": "aca",
"styleext": "scss" "style": "scss"
}, },
"@schematics/angular:directive": { "@schematics/angular:directive": {
"prefix": "aca" "prefix": "aca"
-1
View File
@@ -51,7 +51,6 @@
"polyfill", "polyfill",
"polyfills", "polyfills",
"jsonp", "jsonp",
"hammerjs",
"pdfjs", "pdfjs",
"xpath", "xpath",
"tooltip", "tooltip",
@@ -54,7 +54,6 @@ import { EXTENSION_DATA_LOADERS } from '@alfresco/aca-shared';
@NgModule({ @NgModule({
imports: [...], imports: [...],
declarations: [...], declarations: [...],
entryComponents: [...],
providers: [ providers: [
... ...
{ {
@@ -39,18 +39,6 @@ Angular CLI automatically configures Typescript path mappings for the project, s
### Register dynamic components ### Register dynamic components
Update `my-extension.module.ts` and put all the content you plan to use at runtime dynamically to the `entryComponents` section of the module.
```typescript
@NgModule({
imports: [],
declarations: [MyExtensionComponent],
exports: [MyExtensionComponent],
entryComponents: [MyExtensionComponent]
})
export class MyExtensionModule {}
```
Now we need to register `MyExtensionComponent` as an extension component. Now we need to register `MyExtensionComponent` as an extension component.
Update the code as in the next example: Update the code as in the next example:
+1 -5
View File
@@ -18,8 +18,7 @@ import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
@NgModule({ @NgModule({
imports: [ ExtensionsModule ] imports: [ ExtensionsModule ]
declarations: [ MyComponent1, MyLayout ], declarations: [ MyComponent1, MyLayout ]
entryComponents: [ MyComponent1, MyLayout ]
}) })
export class MyExtensionModule { export class MyExtensionModule {
@@ -42,8 +41,5 @@ export class MyExtensionModule {
} }
``` ```
**Note:** According to Angular rules, all components that are created dynamically at runtime
need to be registered within the `entryComponents` section of the NgModule.
The Registration API is not limited to the custom content only. The Registration API is not limited to the custom content only.
You can replace any existing entries by replacing the values from your module. You can replace any existing entries by replacing the values from your module.
-18
View File
@@ -139,24 +139,6 @@ Please read more details on Dialog components here: [Dialog Overview](https://ma
ng g component dialogs/my-extension-dialog --module=app ng g component dialogs/my-extension-dialog --module=app
``` ```
According to Angular rules, the component needs to also be registered within the `entryComponents` section of the module.
Update the `src/app/app.module.ts` file according to the example below:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
Update `my-extension-dialog.component.ts`: Update `my-extension-dialog.component.ts`:
```ts ```ts
-2
View File
@@ -236,6 +236,4 @@ Navigation items or group of navigation items can be conditional render based on
For more informations about rules checkout [Rules](../extending/rules.md) section. For more informations about rules checkout [Rules](../extending/rules.md) section.
Note that components must be declared as entryComponents under the app module.
For more information about the content of a custom page see [Document List Layout](/features/document-list-layout) section. For more information about the content of a custom page see [Document List Layout](/features/document-list-layout) section.
@@ -40,18 +40,6 @@ Angular CLI は、プロジェクトの Typescript パスマッピングを自
### 動的コンポーネントを登録する ### 動的コンポーネントを登録する
`my-extension.module.ts` を更新し、実行時に動的に使用する予定のすべてのコンテンツをモジュールの `entryComponents` セクションに配置します。
```typescript
@NgModule({
imports: [],
declarations: [MyExtensionComponent],
exports: [MyExtensionComponent],
entryComponents: [MyExtensionComponent]
})
export class MyExtensionModule {}
```
ここで、`MyExtensionComponent` を拡張コンポーネントとして登録する必要があります。 ここで、`MyExtensionComponent` を拡張コンポーネントとして登録する必要があります。
次の例のようにコードを更新します: 次の例のようにコードを更新します:
+1 -5
View File
@@ -19,8 +19,7 @@ import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
@NgModule({ @NgModule({
imports: [ ExtensionsModule ] imports: [ ExtensionsModule ]
declarations: [ MyComponent1, MyLayout ], declarations: [ MyComponent1, MyLayout ]
entryComponents: [ MyComponent1, MyLayout ]
}) })
export class MyExtensionModule { export class MyExtensionModule {
@@ -43,8 +42,5 @@ export class MyExtensionModule {
} }
``` ```
**注:** Angular のルールによれば、実行時に動的に作成されるすべてのコンポーネントは、
NgModule の `entryComponents` セクション内に登録する必要があります。
Registration API は、カスタムコンテンツのみに限定されません。 Registration API は、カスタムコンテンツのみに限定されません。
モジュールの値を置き換えることにより、既存のエントリを置き換えることができます。 モジュールの値を置き換えることにより、既存のエントリを置き換えることができます。
-18
View File
@@ -140,24 +140,6 @@ node: 10
ng g component dialogs/my-extension-dialog --module=app ng g component dialogs/my-extension-dialog --module=app
``` ```
Angular ルールに従って、コンポーネントはモジュールの `entryComponents` セクション内にも登録する必要があります。
以下の例に従って `src/app/app.module.ts` ファイルを更新します:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
`my-extension-dialog.component.ts` を更新します: `my-extension-dialog.component.ts` を更新します:
```ts ```ts
-2
View File
@@ -209,6 +209,4 @@ export class CustomPage {
] ]
``` ```
コンポーネントは app モジュールの下で entryComponents として宣言する必要があることに注意してください。
カスタムページのコンテンツの詳細については、[ドキュメントリストのレイアウト](/ja/features/document-list-layout) セクションを参照してください。 カスタムページのコンテンツの詳細については、[ドキュメントリストのレイアウト](/ja/features/document-list-layout) セクションを参照してください。
-6
View File
@@ -15,8 +15,6 @@ nav: ja
ng g component dialogs/my-extension-dialog --module=app ng g component dialogs/my-extension-dialog --module=app
``` ```
Angular ルールに従って、コンポーネントはモジュールの `entryComponents` セクション内にも登録する必要があります。
以下の例に従って `src/app/app.module.ts` ファイルを更新します: 以下の例に従って `src/app/app.module.ts` ファイルを更新します:
```ts ```ts
@@ -25,10 +23,6 @@ Angular ルールに従って、コンポーネントはモジュールの `entr
declarations: [ declarations: [
..., ...,
MyExtensionDialogComponent MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
] ]
}) })
``` ```
-18
View File
@@ -14,24 +14,6 @@ Please read more details on Dialog components here: [Dialog Overview](https://ma
ng g component dialogs/my-extension-dialog --module=app ng g component dialogs/my-extension-dialog --module=app
``` ```
According to Angular rules, the component needs to also be registered within the `entryComponents` section of the module.
Update the `src/app/app.module.ts` file according to the example below:
```ts
@NgModule({
imports: [...],
declarations: [
...,
MyExtensionDialogComponent
],
entryComponents: [
...,
MyExtensionDialogComponent
]
})
```
Update `my-extension-dialog.component.ts`: Update `my-extension-dialog.component.ts`:
```ts ```ts
@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { BrowsingPage, SearchResultsPage, Utils } from '@alfresco/aca-testing-shared'; import { BrowsingPage, SearchResultsPage } from '@alfresco/aca-testing-shared';
import * as testData from './test-data'; import * as testData from './test-data';
import * as testUtil from '../test-util'; import * as testUtil from '../test-util';
@@ -39,14 +39,6 @@ export function viewerTests(parentName?: string) {
await page.clickPersonalFiles(); await page.clickPersonalFiles();
}); });
beforeEach(async () => {
await Utils.pressEscape();
});
afterEach(async () => {
await page.closeOpenDialogs();
});
describe('file opened from Personal Files', () => { describe('file opened from Personal Files', () => {
beforeAll(async () => { beforeAll(async () => {
@@ -117,7 +117,6 @@ export async function checkViewerActions(item: string, expectedToolbarPrimary: s
const actualMoreActions = await viewerToolbar.menu.getMenuItems(); const actualMoreActions = await viewerToolbar.menu.getMenuItems();
expect(actualMoreActions).toEqual(expectedToolbarMore); expect(actualMoreActions).toEqual(expectedToolbarMore);
await toolbar.closeMoreMenu();
await Utils.pressEscape(); await Utils.pressEscape();
} }
+10 -9
View File
@@ -100,13 +100,15 @@ describe('Mark items as favorites', () => {
fileSearchFav4Id = (await apis.user.nodes.createFile(fileSearchFav4, parentId)).entry.id; fileSearchFav4Id = (await apis.user.nodes.createFile(fileSearchFav4, parentId)).entry.id;
folderSearchId = (await apis.user.nodes.createFolder(folderSearch, parentId)).entry.id; folderSearchId = (await apis.user.nodes.createFolder(folderSearch, parentId)).entry.id;
const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems;
await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.favorites.addFavoritesByIds('file', [ fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id ]); await apis.user.favorites.addFavoritesByIds('file', [ fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id ]);
await apis.user.favorites.waitForApi({ expect: 9 }); await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles + 9 });
const currentSharedFiles = (await apis.user.shared.getSharedLinks()).list.pagination.totalItems;
await apis.user.shared.shareFilesByIds([ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.shared.shareFilesByIds([ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.shared.shareFilesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); await apis.user.shared.shareFilesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
await apis.user.shared.waitForApi({ expect: 8 }); await apis.user.shared.waitForApi({ expect: currentSharedFiles + 8 });
await loginPage.loginWith(username); await loginPage.loginWith(username);
done(); done();
@@ -135,7 +137,6 @@ describe('Mark items as favorites', () => {
}); });
beforeEach(async (done) => { beforeEach(async (done) => {
await Utils.pressEscape();
await page.clickPersonalFilesAndWait(); await page.clickPersonalFilesAndWait();
await dataTable.doubleClickOnRowByName(parent); await dataTable.doubleClickOnRowByName(parent);
done(); done();
@@ -146,6 +147,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border'); expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border');
await toolbar.closeMoreMenu();
}); });
it('[C217187] Favorite action has empty star icon for multiple selection of items when some are not favorite', async () => { it('[C217187] Favorite action has empty star icon for multiple selection of items when some are not favorite', async () => {
@@ -153,6 +155,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border'); expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border');
await toolbar.closeMoreMenu();
}); });
it('[C217188] Favorite action has full star icon for items marked as favorite', async () => { it('[C217188] Favorite action has full star icon for items marked as favorite', async () => {
@@ -160,6 +163,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star'); expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star');
await toolbar.closeMoreMenu();
}); });
it('[C217189] favorite a file', async () => { it('[C217189] favorite a file', async () => {
@@ -211,9 +215,10 @@ describe('Mark items as favorites', () => {
describe('on Recent Files', () => { describe('on Recent Files', () => {
afterAll(async (done) => { afterAll(async (done) => {
try { try {
const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems;
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
await apis.user.favorites.waitForApi({ expect: 10 }); await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles - 1 });
} catch (error) { } catch (error) {
} }
done(); done();
@@ -360,6 +365,7 @@ describe('Mark items as favorites', () => {
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star'); expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star');
await toolbar.closeMoreMenu();
}); });
}); });
@@ -373,11 +379,6 @@ describe('Mark items as favorites', () => {
done(); done();
}); });
beforeEach(async (done) => {
await Utils.pressEscape();
done();
});
afterAll(async done => { afterAll(async done => {
await page.header.expandSideNav(); await page.header.expandSideNav();
await page.clickPersonalFiles(); await page.clickPersonalFiles();
+3 -3
View File
@@ -65,7 +65,7 @@ describe('New menu', () => {
}); });
afterEach(async (done) => { afterEach(async (done) => {
await Utils.pressEscape(); await sidenav.closeNewMenu();
done(); done();
}); });
@@ -98,7 +98,7 @@ describe('New menu', () => {
expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(true, 'Create folder from template is not enabled'); expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(true, 'Create folder from template is not enabled');
}); });
it('[C280397] Actions in File Libraries - user without enough permissions', async () => { xit('[C280397] Actions in File Libraries - user without enough permissions', async () => {
await page.goToMyLibrariesAndWait(); await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin); await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu(); await sidenav.openNewMenu();
@@ -113,7 +113,7 @@ describe('New menu', () => {
expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(false, 'Create folder from template is not disabled'); expect(await menu.isCreateFolderFromTemplateEnabled()).toBe(false, 'Create folder from template is not disabled');
}); });
it('[C216342] Enabled actions tooltips', async () => { xit('[C216342] Enabled actions tooltips', async () => {
await page.clickPersonalFiles(); await page.clickPersonalFiles();
await sidenav.openNewMenu(); await sidenav.openNewMenu();
+2 -2
View File
@@ -67,8 +67,8 @@ describe('Extensions - Info Drawer', () => {
done(); done();
}); });
beforeEach(async (done) => { afterEach(async (done) => {
await Utils.pressEscape(); await header.closeMoreMenu();
done(); done();
}); });
+5 -1
View File
@@ -10,8 +10,12 @@
"jasminewd2", "jasminewd2",
"node" "node"
], ],
"skipLibCheck": true,
"paths": { "paths": {
"@alfresco/aca-testing-shared": ["../projects/aca-testing-shared"] "@alfresco/aca-testing-shared": ["../projects/aca-testing-shared"]
} }
} },
"exclude": [
"node_modules"
]
} }
+2 -3
View File
@@ -1,6 +1,6 @@
// Karma configuration file, see link for more information // Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html // https://karma-runner.github.io/1.0/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath(); // process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function(config) { module.exports = function(config) {
config.set({ config.set({
@@ -14,7 +14,6 @@ module.exports = function(config) {
require('@angular-devkit/build-angular/plugins/karma') require('@angular-devkit/build-angular/plugins/karma')
], ],
files: [ files: [
{ pattern: './node_modules/hammerjs/hammer.js', watched: false },
{ {
pattern: pattern:
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css', './node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
@@ -61,7 +60,7 @@ module.exports = function(config) {
base: 'Chrome', base: 'Chrome',
flags: [ flags: [
'--no-sandbox', '--no-sandbox',
'--headless', // '--headless',
'--disable-gpu', '--disable-gpu',
'--remote-debugging-port=9222' '--remote-debugging-port=9222'
] ]
+10950 -7103
View File
File diff suppressed because it is too large Load Diff
+51 -59
View File
@@ -4,6 +4,7 @@
"commit": "", "commit": "",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"scripts": { "scripts": {
"postinstall": "ngcc",
"ng": "ng", "ng": "ng",
"start": "npm run validate-config && ng serve --open", "start": "npm run validate-config && ng serve --open",
"start:prod": "npm run validate-config && node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng serve --prod --open", "start:prod": "npm run validate-config && node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng serve --prod --open",
@@ -20,7 +21,7 @@
"update-webdriver": "./scripts/update-webdriver.sh", "update-webdriver": "./scripts/update-webdriver.sh",
"e2e.typecheck": "tsc -p ./e2e/tsconfig.e2e.typecheck.json", "e2e.typecheck": "tsc -p ./e2e/tsconfig.e2e.typecheck.json",
"e2e": "npm run update-webdriver && protractor --baseUrl=${TEST_BASE_URL:-http://localhost:8080/content-app} $SUITE", "e2e": "npm run update-webdriver && protractor --baseUrl=${TEST_BASE_URL:-http://localhost:8080/content-app} $SUITE",
"e2e.local": "protractor --baseUrl=http://localhost:4200 $SUITE", "e2e.local": "npm run update-webdriver && protractor --baseUrl=http://localhost:4200",
"wait:app": "wait-on http://${HOST_IP:-localhost}:${HOST_PORT:-8080}/alfresco/ -t 1000000", "wait:app": "wait-on http://${HOST_IP:-localhost}:${HOST_PORT:-8080}/alfresco/ -t 1000000",
"start:docker": "./start.sh", "start:docker": "./start.sh",
"stop:docker": "./start.sh -d", "stop:docker": "./start.sh -d",
@@ -31,92 +32,83 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@alfresco/adf-content-services": "3.9.0", "@alfresco/adf-content-services": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-core": "3.9.0", "@alfresco/adf-core": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-extensions": "3.9.0", "@alfresco/adf-extensions": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/js-api": "3.9.0", "@alfresco/js-api": "3.10.0-1deb4e85760f96f550a7d6d894e4002ecd4a4c18",
"@angular-custom-builders/lite-serve": "0.0.2", "@angular-custom-builders/lite-serve": "0.2.0",
"@angular/animations": "7.2.15", "@angular/animations": "10.0.2",
"@angular/cdk": "^7.3.7", "@angular/cdk": "^10.0.1",
"@angular/common": "7.2.15", "@angular/common": "10.0.2",
"@angular/compiler": "7.2.15", "@angular/compiler": "10.0.2",
"@angular/core": "7.2.15", "@angular/core": "10.0.2",
"@angular/flex-layout": "^7.0.0-beta.24", "@angular/flex-layout": "^10.0.0-beta.32",
"@angular/forms": "7.2.15", "@angular/forms": "10.0.2",
"@angular/material": "^7.3.7", "@angular/material": "^10.0.1",
"@angular/material-moment-adapter": "^7.3.7", "@angular/material-moment-adapter": "^10.0.1",
"@angular/platform-browser": "7.2.15", "@angular/platform-browser": "10.0.2",
"@angular/platform-browser-dynamic": "7.2.15", "@angular/platform-browser-dynamic": "10.0.2",
"@angular/router": "7.2.15", "@angular/router": "10.0.2",
"@mat-datetimepicker/core": "3.1.0", "@mat-datetimepicker/core": "4.1.0",
"@mat-datetimepicker/moment": "3.1.0", "@mat-datetimepicker/moment": "4.1.0",
"@ngrx/effects": "^7.4.0", "@ngrx/effects": "^9.2.0",
"@ngrx/router-store": "^7.4.0", "@ngrx/router-store": "^9.2.0",
"@ngrx/store": "^7.4.0", "@ngrx/store": "^9.2.0",
"@ngrx/store-devtools": "^7.4.0", "@ngrx/store-devtools": "^9.2.0",
"@ngx-translate/core": "^11.0.1", "@ngx-translate/core": "^13.0.0",
"browser-sync": "^2.26.7", "browser-sync": "^2.26.7",
"core-js": "^2.5.7",
"hammerjs": "2.0.8",
"minimatch-browser": "^1.0.0", "minimatch-browser": "^1.0.0",
"moment": "^2.24.0", "moment": "^2.27.0",
"moment-es6": "1.0.0", "moment-es6": "1.0.0",
"pdfjs-dist": "2.3.200", "pdfjs-dist": "2.3.200",
"rxjs": "^6.5.5", "rxjs": "^6.6.0",
"tsickle": "0.34.0", "tslib": "^2.0.0",
"zone.js": "0.8.29" "zone.js": "~0.10.2"
}, },
"devDependencies": { "devDependencies": {
"@alfresco/adf-cli": "3.9.0", "@alfresco/adf-cli": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@alfresco/adf-testing": "3.9.0", "@alfresco/adf-testing": "3.10.0-6001ff801e211e8385966d2f2b773e59b4667dd9",
"@angular-devkit/build-angular": "~0.13.9", "@angular-devkit/build-angular": "~0.1000.1",
"@angular-devkit/build-ng-packagr": "^0.13.10", "@angular-devkit/build-ng-packagr": "~0.1000.1",
"@angular/cli": "^7.3.9", "@angular/cli": "^10.0.1",
"@angular/compiler-cli": "7.2.15", "@angular/compiler-cli": "10.0.2",
"@angular/language-service": "7.2.15", "@angular/language-service": "10.0.2",
"@types/jasmine": "3.5.10", "@types/jasmine": "3.5.11",
"@types/jasminewd2": "^2.0.8", "@types/jasminewd2": "^2.0.8",
"@types/node": "^13.11.0", "@types/node": "^14.0.14",
"@types/selenium-webdriver": "^4.0.9", "@types/selenium-webdriver": "^4.0.9",
"adf-tslint-rules": "0.0.7", "adf-tslint-rules": "0.0.7",
"ajv-cli": "^3.1.0", "ajv-cli": "^3.1.0",
"chrome-remote-interface": "^0.26.1", "chrome-remote-interface": "^0.26.1",
"codelyzer": "^5.2.2", "codelyzer": "^6.0.0",
"commander": "^5.0.0", "commander": "^5.0.0",
"cpr": "^3.0.1", "cpr": "^3.0.1",
"cspell": "^4.0.55", "cspell": "^4.0.55",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"husky": "^4.2.3", "husky": "^4.2.3",
"jasmine-core": "~2.8.0", "jasmine-core": "~2.8.0",
"jasmine-reporters": "^2.2.1",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
"jasminewd2": "^2.2.0", "karma": "^5.1.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0", "karma-chrome-launcher": "^3.1.0",
"karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^3.0.3",
"karma-coverage-istanbul-reporter": "^2.0.4", "karma-jasmine": "^3.3.1",
"karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^1.5.4",
"karma-jasmine-html-reporter": "^0.2.2", "lint-staged": "^10.2.11",
"lint-staged": "^10.1.2", "ng-packagr": "^10.0.0",
"ng-packagr": "^4.7.1",
"node-sass": "^4.14.1",
"node-stream-zip": "^1.9.1", "node-stream-zip": "^1.9.1",
"prettier": "^1.17.1", "prettier": "^1.17.1",
"protractor": "5.4.2", "protractor": "^7.0.0",
"protractor-screenshoter-plugin": "0.10.3", "protractor-screenshoter-plugin": "0.10.3",
"puppeteer": "2.1.1",
"rxjs-tslint": "^0.1.8", "rxjs-tslint": "^0.1.8",
"rxjs-tslint-rules": "^4.30.1", "rxjs-tslint-rules": "^4.30.1",
"selenium-webdriver": "4.0.0-alpha.1", "selenium-webdriver": "^4.0.0-alpha.7",
"ts-node": "^8.0.3", "ts-node": "^8.0.3",
"tsconfig-paths": "3.9.0", "tsconfig-paths": "3.9.0",
"tsickle": ">=0.34.0",
"tslib": "^1.11.1",
"tslint": "^5.20.1", "tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0", "tslint-plugin-prettier": "^2.3.0",
"typescript": "3.2.4", "typescript": "3.9.6",
"wait-on": "^4.0.1", "wait-on": "^5.0.1",
"webdriver-manager": "12.1.7" "webdriver-manager": "12.1.7"
}, },
"lint-staged": { "lint-staged": {
@@ -131,6 +123,6 @@
} }
}, },
"config": { "config": {
"chromeDriver": "80.0.3987.0" "chromeDriver": "83.0.4103.116"
} }
} }
+3 -3
View File
@@ -375,9 +375,9 @@ export function isWriteLocked(context: RuleContext): boolean {
export function isUserWriteLockOwner(context: RuleContext): boolean { export function isUserWriteLockOwner(context: RuleContext): boolean {
return ( return (
isWriteLocked(context) && isWriteLocked(context) &&
(context.selection.file.entry.properties['cm:lockOwner'] && context.selection.file.entry.properties['cm:lockOwner'] &&
context.selection.file.entry.properties['cm:lockOwner'].id === context.selection.file.entry.properties['cm:lockOwner'].id ===
context.profile.id) context.profile.id
); );
} }
@@ -74,8 +74,8 @@ describe('InfoDrawerComponent', () => {
fixture = TestBed.createComponent(InfoDrawerComponent); fixture = TestBed.createComponent(InfoDrawerComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
appExtensionService = TestBed.get(AppExtensionService); appExtensionService = TestBed.inject(AppExtensionService);
contentApiService = TestBed.get(ContentApiService); contentApiService = TestBed.inject(ContentApiService);
tab = { title: 'tab1' }; tab = { title: 'tab1' };
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]); spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);
@@ -28,7 +28,7 @@ import { CommonModule } from '@angular/common';
import { InfoDrawerComponent } from './info-drawer.component'; import { InfoDrawerComponent } from './info-drawer.component';
import { InfoDrawerModule, ToolbarModule } from '@alfresco/adf-core'; import { InfoDrawerModule, ToolbarModule } from '@alfresco/adf-core';
import { ExtensionsModule } from '@alfresco/adf-extensions'; import { ExtensionsModule } from '@alfresco/adf-extensions';
import { MatProgressBarModule } from '@angular/material'; import { MatProgressBarModule } from '@angular/material/progress-bar';
import { SharedToolbarModule } from '../tool-bar/shared-toolbar.module'; import { SharedToolbarModule } from '../tool-bar/shared-toolbar.module';
@NgModule({ @NgModule({
@@ -38,12 +38,13 @@ describe('ContextActionsDirective', () => {
directive = new ContextActionsDirective(storeMock); directive = new ContextActionsDirective(storeMock);
}); });
it('should not render context menu when `enabled` property is false', () => { it('should not render context menu when `enabled` property is false', fakeAsync(() => {
spyOn(directive, 'execute').and.stub();
directive.enabled = false; directive.enabled = false;
directive.onContextMenuEvent(new MouseEvent('contextmenu')); directive.onContextMenuEvent(new MouseEvent('contextmenu'));
expect(storeMock.dispatch).not.toHaveBeenCalled(); expect(directive.execute).not.toHaveBeenCalled();
}); }));
it('should call service to render context menu', fakeAsync(() => { it('should call service to render context menu', fakeAsync(() => {
const el = document.createElement('div'); const el = document.createElement('div');
@@ -65,10 +65,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.execute$ this.execute$
.pipe( .pipe(debounceTime(300), takeUntil(this.onDestroy$))
debounceTime(300),
takeUntil(this.onDestroy$)
)
.subscribe((event: MouseEvent) => { .subscribe((event: MouseEvent) => {
this.store.dispatch(new ContextMenu(event)); this.store.dispatch(new ContextMenu(event));
}); });
@@ -58,8 +58,8 @@ describe('PaginationDirective', () => {
] ]
}); });
preferences = TestBed.get(UserPreferencesService); preferences = TestBed.inject(UserPreferencesService);
config = TestBed.get(AppConfigService); config = TestBed.inject(AppConfigService);
fixture = TestBed.createComponent(PaginationComponent); fixture = TestBed.createComponent(PaginationComponent);
pagination = fixture.componentInstance; pagination = fixture.componentInstance;
directive = new PaginationDirective(pagination, preferences, config); directive = new PaginationDirective(pagination, preferences, config);
@@ -34,7 +34,7 @@ describe('AppRouteReuseStrategy', () => {
providers: [AppRouteReuseStrategy] providers: [AppRouteReuseStrategy]
}); });
appRouteReuse = TestBed.get(AppRouteReuseStrategy); appRouteReuse = TestBed.inject(AppRouteReuseStrategy);
}); });
it('should allow detach if route is configured to be reused', () => { it('should allow detach if route is configured to be reused', () => {
@@ -28,7 +28,7 @@ import {
DetachedRouteHandle, DetachedRouteHandle,
ActivatedRouteSnapshot ActivatedRouteSnapshot
} from '@angular/router'; } from '@angular/router';
import { ComponentRef } from '@angular/core'; import { ComponentRef, Injectable } from '@angular/core';
interface RouteData { interface RouteData {
reuse: boolean; reuse: boolean;
@@ -39,6 +39,7 @@ interface RouteInfo {
data: RouteData; data: RouteData;
} }
@Injectable()
export class AppRouteReuseStrategy implements RouteReuseStrategy { export class AppRouteReuseStrategy implements RouteReuseStrategy {
private routeCache = new Map<string, RouteInfo>(); private routeCache = new Map<string, RouteInfo>();
@@ -54,11 +54,11 @@ describe('AppExtensionService', () => {
imports: [LibTestingModule] imports: [LibTestingModule]
}); });
appConfigService = TestBed.get(AppConfigService); appConfigService = TestBed.inject(AppConfigService);
store = TestBed.get(Store); store = TestBed.inject(Store);
service = TestBed.get(AppExtensionService); service = TestBed.inject(AppExtensionService);
extensions = TestBed.get(ExtensionService); extensions = TestBed.inject(ExtensionService);
components = TestBed.get(ComponentRegisterService); components = TestBed.inject(ComponentRegisterService);
}); });
const applyConfig = (config: ExtensionConfig) => { const applyConfig = (config: ExtensionConfig) => {
@@ -54,10 +54,10 @@ describe('AppService', () => {
] ]
}); });
routeReuse = TestBed.get(AppRouteReuseStrategy); routeReuse = TestBed.inject(AppRouteReuseStrategy);
auth = TestBed.get(AuthenticationService); auth = TestBed.inject(AuthenticationService);
appConfig = TestBed.get(AppConfigService); appConfig = TestBed.inject(AppConfigService);
searchQueryBuilderService = TestBed.get(SearchQueryBuilderService); searchQueryBuilderService = TestBed.inject(SearchQueryBuilderService);
spyOn(routeReuse, 'resetCache').and.stub(); spyOn(routeReuse, 'resetCache').and.stub();
+1 -1
View File
@@ -34,7 +34,7 @@ import { ContextActionsModule } from './directives/contextmenu/contextmenu.modul
exports: [ContextActionsModule] exports: [ContextActionsModule]
}) })
export class SharedModule { export class SharedModule {
static forRoot(): ModuleWithProviders { static forRoot(): ModuleWithProviders<SharedModule> {
return { return {
ngModule: SharedModule, ngModule: SharedModule,
providers: [ContentApiService, NodePermissionService, AppService] providers: [ContentApiService, NodePermissionService, AppService]
@@ -33,15 +33,8 @@ export const getHeaderColor = createSelector(
state => state.headerColor state => state.headerColor
); );
export const getAppName = createSelector( export const getAppName = createSelector(selectApp, state => state.appName);
selectApp, export const getLogoPath = createSelector(selectApp, state => state.logoPath);
state => state.appName
);
export const getLogoPath = createSelector(
selectApp,
state => state.logoPath
);
export const getHeaderImagePath = createSelector( export const getHeaderImagePath = createSelector(
selectApp, selectApp,
@@ -53,10 +46,7 @@ export const getLanguagePickerState = createSelector(
state => state.languagePicker state => state.languagePicker
); );
export const getUserProfile = createSelector( export const getUserProfile = createSelector(selectApp, state => state.user);
selectApp,
state => state.user
);
export const getCurrentFolder = createSelector( export const getCurrentFolder = createSelector(
selectApp, selectApp,
@@ -68,10 +58,7 @@ export const getAppSelection = createSelector(
state => state.selection state => state.selection
); );
export const getSharedUrl = createSelector( export const getSharedUrl = createSelector(selectApp, state => state.sharedUrl);
selectApp,
state => state.sharedUrl
);
export const getNavigationState = createSelector( export const getNavigationState = createSelector(
selectApp, selectApp,
@@ -103,10 +90,7 @@ export const isQuickShareEnabled = createSelector(
info => info.status.isQuickShareEnabled info => info.status.isQuickShareEnabled
); );
export const isAdmin = createSelector( export const isAdmin = createSelector(selectApp, state => state.user.isAdmin);
selectApp,
state => state.user.isAdmin
);
export const getSideNavState = createSelector( export const getSideNavState = createSelector(
getAppSelection, getAppSelection,
-1
View File
@@ -25,7 +25,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files // This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'core-js/es7/reflect';
import 'zone.js/dist/zone'; import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing'; import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing'; import { getTestBed } from '@angular/core/testing';
-1
View File
@@ -18,7 +18,6 @@
} }
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true, "skipTemplateCodegen": true,
"strictMetadataEmit": true, "strictMetadataEmit": true,
"fullTemplateTypeCheck": true, "fullTemplateTypeCheck": true,
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}
@@ -30,6 +30,7 @@ import { Menu } from '../menu/menu';
import { Toolbar } from './../toolbar/toolbar'; import { Toolbar } from './../toolbar/toolbar';
import { SearchInput } from '../search/search-input'; import { SearchInput } from '../search/search-input';
import { waitElement } from '../../utilities/utils'; import { waitElement } from '../../utilities/utils';
import { BrowserActions } from '@alfresco/adf-testing';
export class Header extends Component { export class Header extends Component {
logoLink = this.byCss('.app-menu__title'); logoLink = this.byCss('.app-menu__title');
@@ -50,6 +51,11 @@ export class Header extends Component {
await this.menu.waitForMenuToOpen(); await this.menu.waitForMenuToOpen();
} }
async closeMoreMenu(): Promise<void> {
await BrowserActions.click(this.moreActions);
await this.menu.waitForMenuToClose();
}
async isSignOutDisplayed(): Promise<boolean> { async isSignOutDisplayed(): Promise<boolean> {
return this.userInfo.menu.isMenuItemPresent('Sign out'); return this.userInfo.menu.isMenuItemPresent('Sign out');
} }
@@ -24,7 +24,7 @@
*/ */
import { ElementFinder, by, element, browser } from 'protractor'; import { ElementFinder, by, element, browser } from 'protractor';
import { Logger } from '@alfresco/adf-testing'; import { Logger, BrowserActions } from '@alfresco/adf-testing';
import { SIDEBAR_LABELS, BROWSER_WAIT_TIMEOUT } from '../../configs'; import { SIDEBAR_LABELS, BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Menu } from '../menu/menu'; import { Menu } from '../menu/menu';
import { Component } from '../component'; import { Component } from '../component';
@@ -79,6 +79,13 @@ export class Sidenav extends Component {
await this.menu.waitForMenuToOpen(); await this.menu.waitForMenuToOpen();
} }
async closeNewMenu(): Promise<void> {
await BrowserActions.click(
element(by.css('button[data-automation-id="create-button"] span span'))
);
await this.menu.waitForMenuToClose();
}
async openCreateFolderDialog(): Promise<void> { async openCreateFolderDialog(): Promise<void> {
await this.openNewMenu(); await this.openNewMenu();
await this.menu.createFolderAction.click(); await this.menu.createFolderAction.click();
@@ -92,7 +92,16 @@ export class Toolbar extends Component {
await this.menu.waitForMenuToOpen(); await this.menu.waitForMenuToOpen();
} }
async closeMoreMenu() { async closeMoreMenu(): Promise<void> {
await this.isButtonPresent('More Actions');
const moreMenu = this.getButtonByTitleAttribute('More Actions');
await BrowserActions.click(moreMenu);
await this.menu.waitForMenuToClose();
}
async closeMoreMenuEscape() {
await Utils.pressEscape(); await Utils.pressEscape();
} }
@@ -53,7 +53,7 @@ export abstract class Page {
} }
async load(relativeUrl: string = '') { async load(relativeUrl: string = '') {
const hash = USE_HASH_STRATEGY ? '/#' : ''; const hash = USE_HASH_STRATEGY ? '#' : '';
const path = `${browser.baseUrl}${hash}${this.url}${relativeUrl}`; const path = `${browser.baseUrl}${hash}${this.url}${relativeUrl}`;
return browser.get(path); return browser.get(path);
} }
@@ -147,9 +147,9 @@ export class AdminActions {
// folder links are deleted automatically when original folder is deleted // folder links are deleted automatically when original folder is deleted
// Software Engineering Project is the default folder template coming from ACS, should not be deleted // Software Engineering Project is the default folder template coming from ACS, should not be deleted
const nodesToDelete = (await this.adminApi.nodes.getNodeChildren( const nodesToDelete = (
spaceTemplatesNodeId await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)
)).list.entries ).list.entries
.filter( .filter(
node => node =>
node.entry.nodeType !== 'app:folderlink' && node.entry.nodeType !== 'app:folderlink' &&
@@ -69,14 +69,12 @@ export function flattenNodeContentTree(
if (folders) { if (folders) {
const foldersData: NodeBodyCreate[] = folders const foldersData: NodeBodyCreate[] = folders
.map( .map((folder: string | NodeContentTree): NodeBodyCreate[] => {
(folder: string | NodeContentTree): NodeBodyCreate[] => { const folderData: NodeContentTree =
const folderData: NodeContentTree = typeof folder === 'string' ? { name: folder } : folder;
typeof folder === 'string' ? { name: folder } : folder;
return flattenNodeContentTree(folderData, relativePath); return flattenNodeContentTree(folderData, relativePath);
} })
)
.reduce( .reduce(
(nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => (nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) =>
nodesData.concat(folderData), nodesData.concat(folderData),
@@ -328,9 +328,9 @@ export class SitesApi extends RepoApi {
async hasMembershipRequest(siteId: string) { async hasMembershipRequest(siteId: string) {
try { try {
await this.apiAuth(); await this.apiAuth();
const requests = (await this.sitesApi.getSiteMembershipRequests( const requests = (
'-me-' await this.sitesApi.getSiteMembershipRequests('-me-')
)).list.entries.map(e => e.entry.id); ).list.entries.map(e => e.entry.id);
return requests.includes(siteId); return requests.includes(siteId);
} catch (error) { } catch (error) {
this.handleError( this.handleError(
@@ -179,9 +179,7 @@ export class Utils {
static async setSessionStorageFromConfig( static async setSessionStorageFromConfig(
configFileName: string configFileName: string
): Promise<void> { ): Promise<void> {
const configFile = `${ const configFile = `${browser.params.e2eRootPath}/resources/extensibility-configs/${configFileName}`;
browser.params.e2eRootPath
}/resources/extensibility-configs/${configFileName}`;
const fileContent = JSON.stringify( const fileContent = JSON.stringify(
fs.readFileSync(configFile, { encoding: 'utf8' }) fs.readFileSync(configFile, { encoding: 'utf8' })
); );
@@ -18,7 +18,6 @@
] ]
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true, "skipTemplateCodegen": true,
"strictMetadataEmit": true, "strictMetadataEmit": true,
"fullTemplateTypeCheck": true, "fullTemplateTypeCheck": true,
@@ -25,7 +25,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files // This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'core-js/es7/reflect';
import 'zone.js/dist/zone'; import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing'; import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing'; import { getTestBed } from '@angular/core/testing';
@@ -18,7 +18,6 @@
] ]
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true, "skipTemplateCodegen": true,
"strictMetadataEmit": true, "strictMetadataEmit": true,
"fullTemplateTypeCheck": true, "fullTemplateTypeCheck": true,
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}
+2 -13
View File
@@ -3,9 +3,9 @@
const path = require('path'); const path = require('path');
const { SpecReporter } = require('jasmine-spec-reporter'); const { SpecReporter } = require('jasmine-spec-reporter');
const jasmineReporters = require('jasmine-reporters');
const CDP = require('chrome-remote-interface'); const CDP = require('chrome-remote-interface');
const fs = require('fs'); const fs = require('fs');
require('dotenv').config();
const projectRoot = path.resolve(__dirname); const projectRoot = path.resolve(__dirname);
const downloadFolder = `${projectRoot}/e2e-downloads`; const downloadFolder = `${projectRoot}/e2e-downloads`;
@@ -108,7 +108,7 @@ exports.config = {
capabilities: { capabilities: {
browserName: 'chrome', browserName: 'chrome',
chromeOptions: { chromeOptions: {
binary: require('puppeteer').executablePath(), // binary: require('puppeteer').executablePath(),
prefs: { prefs: {
credentials_enable_service: false, credentials_enable_service: false,
download: { download: {
@@ -186,17 +186,6 @@ exports.config = {
}) })
); );
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: `${projectRoot}/e2e-output/junit-report`,
filePrefix: 'results.xml',
useDotNotation: false,
useFullTestName: false,
reportFailedUrl: true
})
);
rmDir(downloadFolder); rmDir(downloadFolder);
CDP() CDP()
+1 -1
View File
@@ -49,6 +49,6 @@ fs.readFile(program.config, (err, appConfigString) => {
} }
}); });
let appConfigReplacedJson = JSON.stringify(appConfig); let appConfigReplacedJson = JSON.stringify(appConfig, null, 4);
fs.writeFileSync(program.config, appConfigReplacedJson); fs.writeFileSync(program.config, appConfigReplacedJson);
}); });
+9 -2
View File
@@ -2,8 +2,15 @@
FROM=$1; FROM=$1;
TO=$2; TO=$2;
PARAMS=$3;
echo "Download artefact from S3 $FROM"
./scripts/ci/utils/artifact-from-s3.sh -a "$FROM" -o "$TO" ./scripts/ci/utils/artifact-from-s3.sh -a "$FROM" -o "$TO"
node "./scripts/app-config-replace.js" --config="$TO/app.config.json" -a echo "Download artefact done"
npm run update-webdriver echo "Replace app.config with options $PARAMS"
node "./scripts/app-config-replace.js" --config="$TO/app.config.json" $PARAMS
echo "Replace app.config done"
echo "Update update-webdriver"
npm run update-webdriver
+1 -3
View File
@@ -27,6 +27,4 @@ fi
echo "BASE_HASH: $BASE_HASH" echo "BASE_HASH: $BASE_HASH"
echo "S3 DBP destination: $S3_DBP_FOLDER" echo "S3 DBP destination: $S3_DBP_FOLDER"
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 3 # give xvfb some time to start
+4 -1
View File
@@ -24,5 +24,8 @@ fi
test ! -d $OUTPUT && mkdir -p $OUTPUT test ! -d $OUTPUT && mkdir -p $OUTPUT
aws s3 cp $ARTIFACT ./s3-artifact.tmp aws s3 cp $ARTIFACT ./s3-artifact.tmp
tar -xvf ./s3-artifact.tmp -C $OUTPUT echo 'artifact download done'
tar -xvf ./s3-artifact.tmp -C $OUTPUT >&/dev/null
echo 'tar the artifact done'
rm ./s3-artifact.tmp rm ./s3-artifact.tmp
echo 'remove tmp file'
+2 -2
View File
@@ -3,8 +3,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$CI" = "true" ]; then if [ "$CI" = "true" ]; then
echo "Updating wedriver-manager with chromedriver: $npm_package_config_chromeDriver." echo "Updating wedriver-manager with chromedriver: $npm_package_config_chromeDriver."
webdriver-manager update --gecko=false --versions.chrome=$npm_package_config_chromeDriver ./node_modules/protractor/bin/webdriver-manager update --gecko=false --versions.chrome=83.0.4103.116
else else
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome." echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
webdriver-manager update --gecko=false ./node_modules/protractor/bin/webdriver-manager update --gecko=false
fi fi
+3 -4
View File
@@ -56,14 +56,14 @@ describe('AppComponent', () => {
} }
}; };
beforeAll(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }]) RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }])
] ]
}); });
router = TestBed.get(Router); router = TestBed.inject(Router);
component = new AppComponent( component = new AppComponent(
null, null,
@@ -80,9 +80,7 @@ describe('AppComponent', () => {
null, null,
storageMock storageMock
); );
});
beforeEach(() => {
storeMock.dispatch = jasmine.createSpy('dispatch'); storeMock.dispatch = jasmine.createSpy('dispatch');
}); });
@@ -144,6 +142,7 @@ describe('AppComponent', () => {
describe('Routing Configuration', () => { describe('Routing Configuration', () => {
it('Should extension route be included as child of the defined parent path', () => { it('Should extension route be included as child of the defined parent path', () => {
component.mapExtensionRoutes(mockRoutesWithParentRoute); component.mapExtensionRoutes(mockRoutesWithParentRoute);
expect(router.config[0]).toEqual({ expect(router.config[0]).toEqual({
path: 'fake-path', path: 'fake-path',
children: [ children: [
+5 -14
View File
@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule, HammerModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, RouteReuseStrategy } from '@angular/router'; import { RouterModule, RouteReuseStrategy } from '@angular/router';
import { import {
@@ -37,10 +37,7 @@ import {
AppConfigService, AppConfigService,
DebugAppConfigService DebugAppConfigService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { import { ContentModule } from '@alfresco/adf-content-services';
LibraryDialogComponent,
ContentModule
} from '@alfresco/adf-content-services';
import { AppRouteReuseStrategy, SharedModule } from '@alfresco/aca-shared'; import { AppRouteReuseStrategy, SharedModule } from '@alfresco/aca-shared';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
@@ -50,7 +47,6 @@ import { FilesComponent } from './components/files/files.component';
import { LibrariesComponent } from './components/libraries/libraries.component'; import { LibrariesComponent } from './components/libraries/libraries.component';
import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component'; import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component';
import { NodeVersionsDialogComponent } from './dialogs/node-versions/node-versions.dialog'; import { NodeVersionsDialogComponent } from './dialogs/node-versions/node-versions.dialog';
import { CurrentUserComponent } from './components/current-user/current-user.component';
import { AppStoreModule } from './store/app-store.module'; import { AppStoreModule } from './store/app-store.module';
import { MaterialModule } from './material.module'; import { MaterialModule } from './material.module';
@@ -130,7 +126,7 @@ registerLocaleData(localeSv);
SharedModule.forRoot(), SharedModule.forRoot(),
AppStoreModule, AppStoreModule,
CoreExtensionsModule.forRoot(), CoreExtensionsModule.forRoot(),
ExtensionsModule, ExtensionsModule.forRoot(),
AppExtensionsModule, AppExtensionsModule,
AppLoginModule, AppLoginModule,
AppCommonModule, AppCommonModule,
@@ -147,7 +143,8 @@ registerLocaleData(localeSv);
AppSearchInputModule, AppSearchInputModule,
AppSearchResultsModule, AppSearchResultsModule,
AppHeaderModule, AppHeaderModule,
AppNodeVersionModule AppNodeVersionModule,
HammerModule
], ],
declarations: [ declarations: [
AppComponent, AppComponent,
@@ -172,12 +169,6 @@ registerLocaleData(localeSv);
} }
} }
], ],
entryComponents: [
NodeVersionsDialogComponent,
LibraryDialogComponent,
CreateFromTemplateDialogComponent,
CurrentUserComponent
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule {} export class AppModule {}
+86 -32
View File
@@ -51,12 +51,17 @@ export const APP_ROUTES: Routes = [
}, },
{ {
path: 'settings', path: 'settings',
loadChildren: './components/settings/settings.module#AppSettingsModule' loadChildren: () =>
import('./components/settings/settings.module').then(
m => m.AppSettingsModule
)
}, },
{ {
path: 'preview/s/:id', path: 'preview/s/:id',
loadChildren: loadChildren: () =>
'./components/shared-link-view/shared-link-view.module#AppSharedLinkViewModule' import('./components/shared-link-view/shared-link-view.module').then(
m => m.AppSharedLinkViewModule
)
}, },
{ {
path: 'view', path: 'view',
@@ -68,7 +73,10 @@ export const APP_ROUTES: Routes = [
children: [ children: [
{ {
path: '', path: '',
loadChildren: './components/viewer/viewer.module#AppViewerModule' loadChildren: () =>
import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -99,7 +107,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'personal-files' navigateSource: 'personal-files'
} }
@@ -113,8 +124,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'personal-files' navigateSource: 'personal-files'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -134,7 +147,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'personal-files' navigateSource: 'personal-files'
} }
@@ -142,7 +158,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: ':folderId/preview/:nodeId', path: ':folderId/preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'personal-files' navigateSource: 'personal-files'
} }
@@ -156,8 +175,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'personal-files' navigateSource: 'personal-files'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -190,7 +211,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'libraries' navigateSource: 'libraries'
} }
@@ -204,8 +228,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'libraries' navigateSource: 'libraries'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -249,8 +275,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'libraries' navigateSource: 'libraries'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -275,7 +303,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'favorites' navigateSource: 'favorites'
} }
@@ -289,8 +320,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'favorites' navigateSource: 'favorites'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -314,7 +347,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'recent-files' navigateSource: 'recent-files'
} }
@@ -328,8 +364,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'recent-files' navigateSource: 'recent-files'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -351,7 +389,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'shared' navigateSource: 'shared'
} }
@@ -365,8 +406,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'shared' navigateSource: 'shared'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -376,11 +419,15 @@ export const APP_ROUTES: Routes = [
}, },
{ {
path: 'trashcan', path: 'trashcan',
loadChildren: './components/trashcan/trashcan.module#AppTrashcanModule' loadChildren: () =>
import('./components/trashcan/trashcan.module').then(
m => m.AppTrashcanModule
)
}, },
{ {
path: 'about', path: 'about',
loadChildren: './components/about/about.module#AboutModule' loadChildren: () =>
import('./components/about/about.module').then(m => m.AboutModule)
}, },
{ {
path: 'search', path: 'search',
@@ -395,7 +442,10 @@ export const APP_ROUTES: Routes = [
// deprecated, backwards compatibility with ACA 1.8 // deprecated, backwards compatibility with ACA 1.8
{ {
path: 'preview/:nodeId', path: 'preview/:nodeId',
loadChildren: './components/preview/preview.module#PreviewModule', loadChildren: () =>
import('./components/preview/preview.module').then(
m => m.PreviewModule
),
data: { data: {
navigateSource: 'search' navigateSource: 'search'
} }
@@ -409,8 +459,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'search' navigateSource: 'search'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -435,8 +487,10 @@ export const APP_ROUTES: Routes = [
data: { data: {
navigateSource: 'search' navigateSource: 'search'
}, },
loadChildren: loadChildren: () =>
'./components/viewer/viewer.module#AppViewerModule' import('./components/viewer/viewer.module').then(
m => m.AppViewerModule
)
} }
] ]
} }
@@ -53,12 +53,6 @@ import { LogoutComponent } from './logout/logout.component';
ToggleSharedComponent, ToggleSharedComponent,
LanguagePickerComponent, LanguagePickerComponent,
LogoutComponent LogoutComponent
],
entryComponents: [
LocationLinkComponent,
ToggleSharedComponent,
LanguagePickerComponent,
LogoutComponent
] ]
}) })
export class AppCommonModule {} export class AppCommonModule {}
@@ -56,7 +56,7 @@ describe('LogoutComponent', () => {
] ]
}); });
store = TestBed.get(Store); store = TestBed.inject(Store);
fixture = TestBed.createComponent(LogoutComponent); fixture = TestBed.createComponent(LogoutComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
@@ -54,7 +54,7 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuItemComponent); fixture = TestBed.createComponent(ContextMenuItemComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
extensionsService = TestBed.get(AppExtensionService); extensionsService = TestBed.inject(AppExtensionService);
contextItem = { contextItem = {
type: 'button', type: 'button',
@@ -87,8 +87,8 @@ describe('ContextMenuComponent', () => {
fixture = TestBed.createComponent(ContextMenuComponent); fixture = TestBed.createComponent(ContextMenuComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
contextMenuOverlayRef = TestBed.get(ContextMenuOverlayRef); contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
extensionsService = TestBed.get(AppExtensionService); extensionsService = TestBed.inject(AppExtensionService);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([ spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([
contextItem contextItem
@@ -59,7 +59,6 @@ import { ContextActionsModule } from '@alfresco/aca-shared';
ContextMenuComponent, ContextMenuComponent,
ContextMenuItemComponent, ContextMenuItemComponent,
ContextActionsModule ContextActionsModule
], ]
entryComponents: [ContextMenuComponent]
}) })
export class ContextMenuModule {} export class ContextMenuModule {}
@@ -62,9 +62,9 @@ describe('ContextMenuService', () => {
] ]
}); });
injector = TestBed.get(Injector); injector = TestBed.inject(Injector);
overlay = TestBed.get(Overlay); overlay = TestBed.inject(Overlay);
userPreferencesService = TestBed.get(UserPreferencesService); userPreferencesService = TestBed.inject(UserPreferencesService);
}); });
it('should create a custom overlay', () => { it('should create a custom overlay', () => {
@@ -61,8 +61,8 @@ describe('CurrentUserComponent', () => {
}); });
fixture = TestBed.createComponent(CurrentUserComponent); fixture = TestBed.createComponent(CurrentUserComponent);
appExtensionService = TestBed.get(AppExtensionService); appExtensionService = TestBed.inject(AppExtensionService);
store = TestBed.get(Store); store = TestBed.inject(Store);
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
@@ -54,7 +54,7 @@ describe('UserMenuItemComponent', () => {
}); });
fixture = TestBed.createComponent(UserMenuItemComponent); fixture = TestBed.createComponent(UserMenuItemComponent);
appExtensionService = TestBed.get(AppExtensionService); appExtensionService = TestBed.inject(AppExtensionService);
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
@@ -40,7 +40,6 @@ import { CoreModule } from '@alfresco/adf-core';
LockedByModule LockedByModule
], ],
declarations: [CustomNameColumnComponent], declarations: [CustomNameColumnComponent],
exports: [CustomNameColumnComponent], exports: [CustomNameColumnComponent]
entryComponents: [CustomNameColumnComponent]
}) })
export class DocumentListCustomComponentsModule {} export class DocumentListCustomComponentsModule {}
@@ -83,12 +83,12 @@ describe('FavoriteLibrariesComponent', () => {
fixture = TestBed.createComponent(FavoriteLibrariesComponent); fixture = TestBed.createComponent(FavoriteLibrariesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
contentApiService = TestBed.get(ContentApiService); contentApiService = TestBed.inject(ContentApiService);
userPreference = TestBed.get(UserPreferencesService); userPreference = TestBed.inject(UserPreferencesService);
contentManagementService = TestBed.get(ContentManagementService); contentManagementService = TestBed.inject(ContentManagementService);
alfrescoApi.reset(); alfrescoApi.reset();
router = TestBed.get(Router); router = TestBed.inject(Router);
spyOn(contentApiService, 'getNode').and.returnValue( spyOn(contentApiService, 'getNode').and.returnValue(
of({ entry: { id: 'libraryId' } } as NodeEntry) of({ entry: { id: 'libraryId' } } as NodeEntry)
@@ -116,7 +116,9 @@ describe('FavoriteLibrariesComponent', () => {
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith( expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith(
'-me-', '-me-',
{ maxItems: userPreference.paginationSize } {
maxItems: userPreference.paginationSize
}
); );
}); });
@@ -101,15 +101,15 @@ describe('FavoritesComponent', () => {
fixture = TestBed.createComponent(FavoritesComponent); fixture = TestBed.createComponent(FavoritesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset(); alfrescoApi.reset();
spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue( spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(
Promise.resolve(page) Promise.resolve(page)
); );
contentApi = TestBed.get(ContentApiService); contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.get(UploadService); uploadService = TestBed.inject(UploadService);
router = TestBed.get(Router); router = TestBed.inject(Router);
}); });
describe('Node navigation', () => { describe('Node navigation', () => {
@@ -35,7 +35,9 @@ import {
NodeFavoriteDirective, NodeFavoriteDirective,
DataTableComponent, DataTableComponent,
UploadService, UploadService,
AppConfigPipe AppConfigPipe,
AlfrescoApiService,
AlfrescoApiServiceMock
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services'; import { DocumentListComponent } from '@alfresco/adf-content-services';
import { NodeActionsService } from '../../services/node-actions.service'; import { NodeActionsService } from '../../services/node-actions.service';
@@ -51,7 +53,7 @@ describe('FilesComponent', () => {
let uploadService: UploadService; let uploadService: UploadService;
let nodeActionsService: NodeActionsService; let nodeActionsService: NodeActionsService;
let contentApi: ContentApiService; let contentApi: ContentApiService;
let router = { let router: any = {
url: '', url: '',
navigate: jasmine.createSpy('navigate') navigate: jasmine.createSpy('navigate')
}; };
@@ -67,6 +69,7 @@ describe('FilesComponent', () => {
AppConfigPipe AppConfigPipe
], ],
providers: [ providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ {
provide: Router, provide: Router,
useValue: router useValue: router
@@ -85,18 +88,22 @@ describe('FilesComponent', () => {
fixture = TestBed.createComponent(FilesComponent); fixture = TestBed.createComponent(FilesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
uploadService = TestBed.get(UploadService); uploadService = TestBed.inject(UploadService);
router = TestBed.get(Router); router = TestBed.inject(Router);
nodeActionsService = TestBed.get(NodeActionsService); nodeActionsService = TestBed.inject(NodeActionsService);
contentApi = TestBed.get(ContentApiService); contentApi = TestBed.inject(ContentApiService);
}); });
beforeEach(() => { beforeEach(() => {
node = { id: 'node-id', isFolder: true }; node = { id: 'node-id', isFolder: true };
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
}); });
describe('Current page is valid', () => { describe('Current page is valid', () => {
beforeEach(() => {
fixture.detectChanges();
spyOn(component.documentList, 'loadFolder').and.callFake(() => {});
});
it('should be a valid current page', fakeAsync(() => { it('should be a valid current page', fakeAsync(() => {
spyOn(contentApi, 'getNode').and.returnValue(throwError(null)); spyOn(contentApi, 'getNode').and.returnValue(throwError(null));
@@ -111,24 +118,29 @@ describe('FilesComponent', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node })); spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
component.ngOnInit(); component.ngOnInit();
tick();
fixture.detectChanges(); fixture.detectChanges();
tick();
expect(component.isValidPath).toBe(true); expect(component.isValidPath).toBe(true);
})); }));
}); });
describe('OnInit', () => { describe('OnInit', () => {
beforeEach(() => {
router.navigate['calls'].reset();
});
it('should set current node', () => { it('should set current node', () => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node })); spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
fixture.detectChanges(); fixture.detectChanges();
expect(component.node).toBe(node); expect(component.node).toBe(node);
}); });
it('if should navigate to parent if node is not a folder', () => { it('should navigate to parent if node is not a folder', () => {
node.isFolder = false; const nodeEntry = { isFolder: false, parentId: 'parent-id' };
node.parentId = 'parent-id'; spyOn(contentApi, 'getNode').and.returnValue(
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node })); of({ entry: nodeEntry } as any)
);
fixture.detectChanges(); fixture.detectChanges();
@@ -64,7 +64,6 @@ export function components() {
SharedInfoDrawerModule SharedInfoDrawerModule
], ],
declarations: [...components()], declarations: [...components()],
exports: [...components(), SharedInfoDrawerModule], exports: [...components(), SharedInfoDrawerModule]
entryComponents: [...components()]
}) })
export class AppInfoDrawerModule {} export class AppInfoDrawerModule {}
@@ -57,7 +57,7 @@ describe('LibraryMetadataFormComponent', () => {
fixture = TestBed.createComponent(LibraryMetadataFormComponent); fixture = TestBed.createComponent(LibraryMetadataFormComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
}); });
afterEach(() => { afterEach(() => {
@@ -55,8 +55,8 @@ describe('MetadataTabComponent', () => {
describe('content-metadata configuration', () => { describe('content-metadata configuration', () => {
beforeEach(() => { beforeEach(() => {
appConfig = TestBed.get(AppConfigService); appConfig = TestBed.inject(AppConfigService);
extensions = TestBed.get(AppExtensionService); extensions = TestBed.inject(AppExtensionService);
}); });
it('should remain unchanged when metadata extension is missing', () => { it('should remain unchanged when metadata extension is missing', () => {
@@ -136,7 +136,7 @@ describe('MetadataTabComponent', () => {
describe('displayAspect', () => { describe('displayAspect', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(MetadataTabComponent); fixture = TestBed.createComponent(MetadataTabComponent);
store = TestBed.get(Store); store = TestBed.inject(Store);
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
@@ -14,7 +14,7 @@
role="heading" role="heading"
aria-level="1" aria-level="1"
*ngIf="!hideSidenav" *ngIf="!hideSidenav"
(toggleClicked)="layout.toggleMenu($event)" (toggleClicked)="layout.toggleMenu()"
[expandedSidenav]="!isMenuMinimized()" [expandedSidenav]="!isMenuMinimized()"
> >
</app-header> </app-header>
@@ -73,10 +73,10 @@ describe('AppLayoutComponent', () => {
fixture = TestBed.createComponent(AppLayoutComponent); fixture = TestBed.createComponent(AppLayoutComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
appConfig = TestBed.get(AppConfigService); appConfig = TestBed.inject(AppConfigService);
store = TestBed.get(Store); store = TestBed.inject(Store);
router = TestBed.get(Router); router = TestBed.inject(Router);
userPreference = TestBed.get(UserPreferencesService); userPreference = TestBed.inject(UserPreferencesService);
}); });
beforeEach(() => { beforeEach(() => {
@@ -55,7 +55,7 @@ import { Directionality } from '@angular/cdk/bidi';
host: { class: 'app-layout' } host: { class: 'app-layout' }
}) })
export class AppLayoutComponent implements OnInit, OnDestroy { export class AppLayoutComponent implements OnInit, OnDestroy {
@ViewChild('layout') @ViewChild('layout', { static: true })
layout: SidenavLayoutComponent; layout: SidenavLayoutComponent;
onDestroy$: Subject<boolean> = new Subject<boolean>(); onDestroy$: Subject<boolean> = new Subject<boolean>();
@@ -70,9 +70,9 @@ describe('LibrariesComponent', () => {
fixture = TestBed.createComponent(LibrariesComponent); fixture = TestBed.createComponent(LibrariesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset(); alfrescoApi.reset();
router = TestBed.get(Router); router = TestBed.inject(Router);
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue( spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue(
Promise.resolve(page) Promise.resolve(page)
@@ -50,8 +50,6 @@ import { NgModule } from '@angular/core';
MatInputModule MatInputModule
], ],
exports: [AppNodeVersionFormComponent], exports: [AppNodeVersionFormComponent],
declarations: [AppNodeVersionFormComponent], declarations: [AppNodeVersionFormComponent]
providers: [],
entryComponents: [AppNodeVersionFormComponent]
}) })
export class AppNodeVersionModule {} export class AppNodeVersionModule {}
+1 -1
View File
@@ -69,7 +69,7 @@ describe('PageComponent', () => {
providers: [ContentManagementService, AppExtensionService] providers: [ContentManagementService, AppExtensionService]
}); });
store = TestBed.get(Store); store = TestBed.inject(Store);
fixture = TestBed.createComponent(TestComponent); fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
+4 -1
View File
@@ -34,7 +34,8 @@ import {
OnInit, OnInit,
OnChanges, OnChanges,
ViewChild, ViewChild,
SimpleChanges SimpleChanges,
Directive
} from '@angular/core'; } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { import {
@@ -60,6 +61,8 @@ import {
} from '@alfresco/aca-shared/store'; } from '@alfresco/aca-shared/store';
import { isLocked, isLibrary, AppExtensionService } from '@alfresco/aca-shared'; import { isLocked, isLibrary, AppExtensionService } from '@alfresco/aca-shared';
/* tslint:disable:directive-class-suffix */
@Directive()
export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
onDestroy$: Subject<boolean> = new Subject<boolean>(); onDestroy$: Subject<boolean> = new Subject<boolean>();
@@ -40,7 +40,7 @@ import { NodePermissionsDialogComponent } from '../permission-dialog/node-permis
templateUrl: './permission-manager.component.html' templateUrl: './permission-manager.component.html'
}) })
export class PermissionsManagerComponent implements OnInit { export class PermissionsManagerComponent implements OnInit {
@ViewChild('permissionList') @ViewChild('permissionList', { static: true })
permissionList: PermissionListComponent; permissionList: PermissionListComponent;
@Input() @Input()
@@ -33,7 +33,6 @@ import { PermissionsManagerComponent } from './permission-manager/permission-man
@NgModule({ @NgModule({
imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild()], imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild()],
declarations: [PermissionsManagerComponent, NodePermissionsDialogComponent], declarations: [PermissionsManagerComponent, NodePermissionsDialogComponent],
exports: [PermissionsManagerComponent, NodePermissionsDialogComponent], exports: [PermissionsManagerComponent, NodePermissionsDialogComponent]
entryComponents: [NodePermissionsDialogComponent]
}) })
export class AppPermissionsModule {} export class AppPermissionsModule {}
@@ -80,14 +80,14 @@ describe('PreviewComponent', () => {
fixture = TestBed.createComponent(PreviewComponent); fixture = TestBed.createComponent(PreviewComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
router = TestBed.get(Router); router = TestBed.inject(Router);
route = TestBed.get(ActivatedRoute); route = TestBed.inject(ActivatedRoute);
preferences = TestBed.get(UserPreferencesService); preferences = TestBed.inject(UserPreferencesService);
contentApi = TestBed.get(ContentApiService); contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.get(UploadService); uploadService = TestBed.inject(UploadService);
alfrescoApiService = TestBed.get(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService); contentManagementService = TestBed.inject(ContentManagementService);
store = TestBed.get(Store); store = TestBed.inject(Store);
}); });
it('should extract the property path root', () => { it('should extract the property path root', () => {
@@ -84,8 +84,8 @@ describe('RecentFilesComponent', () => {
fixture = TestBed.createComponent(RecentFilesComponent); fixture = TestBed.createComponent(RecentFilesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
uploadService = TestBed.get(UploadService); uploadService = TestBed.inject(UploadService);
alfrescoApi.reset(); alfrescoApi.reset();
spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue( spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(
@@ -64,7 +64,7 @@ export class SearchInputControlComponent implements OnDestroy {
@Output() @Output()
searchChange: EventEmitter<string> = new EventEmitter(); searchChange: EventEmitter<string> = new EventEmitter();
@ViewChild('searchInput') @ViewChild('searchInput', { static: true })
searchInput: ElementRef; searchInput: ElementRef;
searchTerm = ''; searchTerm = '';
@@ -59,9 +59,9 @@ describe('SearchInputComponent', () => {
}) })
.compileComponents() .compileComponents()
.then(() => { .then(() => {
actions$ = TestBed.get(Actions); actions$ = TestBed.inject(Actions);
fixture = TestBed.createComponent(SearchInputComponent); fixture = TestBed.createComponent(SearchInputComponent);
content = TestBed.get(ContentManagementService); content = TestBed.inject(ContentManagementService);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -91,10 +91,10 @@ export class SearchInputComponent implements OnInit, OnDestroy {
} }
]; ];
@ViewChild('searchInputControl') @ViewChild('searchInputControl', { static: true })
searchInputControl: SearchInputControlComponent; searchInputControl: SearchInputControlComponent;
@ViewChild(MatMenuTrigger) @ViewChild(MatMenuTrigger, { static: true })
trigger: MatMenuTrigger; trigger: MatMenuTrigger;
constructor( constructor(
@@ -42,7 +42,7 @@ describe('SearchLibrariesQueryBuilderService', () => {
imports: [AppTestingModule] imports: [AppTestingModule]
}); });
apiService = TestBed.get(AlfrescoApiService); apiService = TestBed.inject(AlfrescoApiService);
apiService.reset(); apiService.reset();
queriesApi = apiService.getInstance().core.queriesApi; queriesApi = apiService.getInstance().core.queriesApi;
builder = new SearchLibrariesQueryBuilderService(apiService); builder = new SearchLibrariesQueryBuilderService(apiService);
@@ -93,12 +93,12 @@ describe('SearchComponent', () => {
] ]
}); });
config = TestBed.get(AppConfigService); config = TestBed.inject(AppConfigService);
store = TestBed.get(Store); store = TestBed.inject(Store);
queryBuilder = TestBed.get(SearchQueryBuilderService); queryBuilder = TestBed.inject(SearchQueryBuilderService);
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
translate = TestBed.get(TranslationService); translate = TestBed.inject(TranslationService);
router = TestBed.get(Router); router = TestBed.inject(Router);
fixture = TestBed.createComponent(SearchResultsComponent); fixture = TestBed.createComponent(SearchResultsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
@@ -54,7 +54,7 @@ import { AppExtensionService } from '@alfresco/aca-shared';
styleUrls: ['./search-results.component.scss'] styleUrls: ['./search-results.component.scss']
}) })
export class SearchResultsComponent extends PageComponent implements OnInit { export class SearchResultsComponent extends PageComponent implements OnInit {
@ViewChild('searchFilter') @ViewChild('searchFilter', { static: true })
searchFilter: SearchFilterComponent; searchFilter: SearchFilterComponent;
showFacetFilter$: Observable<boolean>; showFacetFilter$: Observable<boolean>;
@@ -62,8 +62,8 @@ describe('SettingsComponent', () => {
fixture = TestBed.createComponent(SettingsComponent); fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
storage = TestBed.get(StorageService); storage = TestBed.inject(StorageService);
appExtensions = TestBed.get(AppExtensionService); appExtensions = TestBed.inject(AppExtensionService);
stringParam = { stringParam = {
key: 'key', key: 'key',
@@ -32,6 +32,7 @@ import {
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { import {
AlfrescoApiService, AlfrescoApiService,
AlfrescoApiServiceMock,
NodeFavoriteDirective, NodeFavoriteDirective,
DataTableComponent, DataTableComponent,
AppConfigPipe, AppConfigPipe,
@@ -74,6 +75,7 @@ describe('SharedFilesComponent', () => {
AppConfigPipe AppConfigPipe
], ],
providers: [ providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ {
provide: Router, provide: Router,
useValue: mockRouter useValue: mockRouter
@@ -83,11 +85,11 @@ describe('SharedFilesComponent', () => {
}); });
fixture = TestBed.createComponent(SharedFilesComponent); fixture = TestBed.createComponent(SharedFilesComponent);
uploadService = TestBed.get(UploadService); uploadService = TestBed.inject(UploadService);
contentManagementService = TestBed.get(ContentManagementService); contentManagementService = TestBed.inject(ContentManagementService);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset(); alfrescoApi.reset();
spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue( spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(
@@ -78,8 +78,8 @@ describe('SharedLinkViewComponent', () => {
fixture = TestBed.createComponent(SharedLinkViewComponent); fixture = TestBed.createComponent(SharedLinkViewComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
appExtensionService = TestBed.get(AppExtensionService); appExtensionService = TestBed.inject(AppExtensionService);
spyGetSharedLink = spyOn( spyGetSharedLink = spyOn(
alfrescoApiService.sharedLinksApi, alfrescoApiService.sharedLinksApi,
@@ -52,7 +52,7 @@ describe('ButtonMenuComponent', () => {
fixture = TestBed.createComponent(ButtonMenuComponent); fixture = TestBed.createComponent(ButtonMenuComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
router = TestBed.get(Router); router = TestBed.inject(Router);
spyOn(router, 'navigate'); spyOn(router, 'navigate');
}); });
@@ -52,7 +52,7 @@ describe('ExpandMenuComponent', () => {
fixture = TestBed.createComponent(ExpandMenuComponent); fixture = TestBed.createComponent(ExpandMenuComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
router = TestBed.get(Router); router = TestBed.inject(Router);
spyOn(router, 'navigate'); spyOn(router, 'navigate');
}); });
@@ -26,6 +26,7 @@
import { Directive, Input, HostListener } from '@angular/core'; import { Directive, Input, HostListener } from '@angular/core';
import { PRIMARY_OUTLET, Router } from '@angular/router'; import { PRIMARY_OUTLET, Router } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppStore } from '@alfresco/aca-shared/store';
@Directive({ @Directive({
/* tslint:disable-next-line */ /* tslint:disable-next-line */
@@ -47,7 +48,7 @@ export class ActionDirective {
} }
} }
constructor(private router: Router, private store: Store<any>) {} constructor(private router: Router, private store: Store<AppStore>) {}
private getNavigationCommands(url: string): any[] { private getNavigationCommands(url: string): any[] {
const urlTree = this.router.parseUrl(url); const urlTree = this.router.parseUrl(url);
@@ -74,7 +74,7 @@ describe('ActionDirective', () => {
}); });
fixture = TestBed.createComponent(TestComponent); fixture = TestBed.createComponent(TestComponent);
router = TestBed.get(Router); router = TestBed.inject(Router);
}); });
it('should add active route class name', () => { it('should add active route class name', () => {
@@ -31,7 +31,8 @@ import {
Renderer2, Renderer2,
ContentChildren, ContentChildren,
QueryList, QueryList,
AfterContentInit AfterContentInit,
Optional
} from '@angular/core'; } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
import { filter, takeUntil } from 'rxjs/operators'; import { filter, takeUntil } from 'rxjs/operators';
@@ -53,7 +54,8 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
constructor( constructor(
private router: Router, private router: Router,
private element: ElementRef, private element: ElementRef,
private renderer: Renderer2 private renderer: Renderer2,
@Optional() private action?: ActionDirective
) {} ) {}
ngOnInit() { ngOnInit() {
@@ -68,21 +70,27 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
} }
private update(url: string) { private update(url: string) {
if (this.action) {
const itemUrl = this.resolveUrl(this.action);
this.render(url, itemUrl);
}
this.links.map(item => { this.links.map(item => {
const itemUrl = this.resolveUrl(item); const itemUrl = this.resolveUrl(item);
if (url && url.substring(1).startsWith(itemUrl)) { this.render(url, itemUrl);
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(
this.element.nativeElement,
this.acaActiveLink
);
}
}); });
} }
private render(routerUrl: string, actionUrl: string) {
if (routerUrl && routerUrl.substring(1).startsWith(actionUrl)) {
this.isLinkActive = true;
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
} else {
this.isLinkActive = false;
this.renderer.removeClass(this.element.nativeElement, this.acaActiveLink);
}
}
ngAfterContentInit() { ngAfterContentInit() {
this.links.changes.subscribe(() => this.update(this.router.url)); this.links.changes.subscribe(() => this.update(this.router.url));
this.update(this.router.url); this.update(this.router.url);
@@ -90,7 +98,7 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
private resolveUrl(item): string { private resolveUrl(item): string {
return ( return (
(item.action && (item.action.click && item.action.click.payload)) || (item.action && item.action.click && item.action.click.payload) ||
item.action.route item.action.route
); );
} }

Some files were not shown because too many files have changed in this diff Show More