From 4bbe08fb5523d03ef0f899898f86efa34f65c038 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 7 May 2024 11:33:58 -0400 Subject: [PATCH] NIFI-13164: (#8760) - Moving from jsdom to happy dom for test environment execution. - Removing test for the Documentation component that was failing because it was attempting to load an iframe with the nifi documentation that wasn't available. This closes #8760 --- .../src/main/nifi/jest.config.ts | 2 +- .../src/main/nifi/package-lock.json | 33 ++++++++++++ .../src/main/nifi/package.json | 2 + .../feature/documentation.component.spec.ts | 52 ------------------- 4 files changed, 36 insertions(+), 53 deletions(-) delete mode 100644 nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/documentation/feature/documentation.component.spec.ts diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/jest.config.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/jest.config.ts index 531f03af6c..690ac2fed8 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/jest.config.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/jest.config.ts @@ -155,7 +155,7 @@ const config: Config = { // snapshotSerializers: [], // The test environment that will be used for testing - testEnvironment: 'jsdom', + testEnvironment: '@happy-dom/jest-environment', // Options that will be passed to the testEnvironment // testEnvironmentOptions: {}, diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package-lock.json b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package-lock.json index cecf36fa61..2474213a5a 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package-lock.json +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package-lock.json @@ -46,6 +46,7 @@ "@angular-eslint/template-parser": "17.2.1", "@angular/cli": "~17.1.3", "@angular/compiler-cli": "^17.1.3", + "@happy-dom/jest-environment": "^14.10.1", "@nx/angular": "18.1.3", "@nx/jest": "^18.1.3", "@nx/workspace": "18.1.3", @@ -60,6 +61,7 @@ "eslint": "^8.51.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.0.1", + "happy-dom": "^14.10.1", "jest": "^29.7.0", "jest-preset-angular": "^14.0.3", "nx": "18.1.3", @@ -4726,6 +4728,23 @@ "resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-5.0.13.tgz", "integrity": "sha512-j61DHjsdUCKMXSdNLTOxcG701FWnF0jcqNNQi2iPCDxU8seN/sMxeh62dC++UiagCWq9ghTypX+Pcy7kX+QOeQ==" }, + "node_modules/@happy-dom/jest-environment": { + "version": "14.10.1", + "resolved": "https://registry.npmjs.org/@happy-dom/jest-environment/-/jest-environment-14.10.1.tgz", + "integrity": "sha512-lKSQWyWQZYKp6xOyaUvPbW1OMp5T+eMjjfQXi5+o66MVIxv6Ej90y+89AiGf9hPQS3ryE7cNAX+/jH2mIrZqgA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.4.0", + "@jest/fake-timers": "^29.4.0", + "@jest/types": "^29.4.0", + "happy-dom": "^14.10.1", + "jest-mock": "^29.4.0", + "jest-util": "^29.4.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -15023,6 +15042,20 @@ "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==", "dev": true }, + "node_modules/happy-dom": { + "version": "14.10.1", + "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-14.10.1.tgz", + "integrity": "sha512-GRbrZYIezi8+tTtffF4v2QcF8bk1h2loUTO5VYQz3GZdrL08Vk0fI+bwf/vFEBf4C/qVf/easLJ/MY1wwdhytA==", + "dev": true, + "dependencies": { + "entities": "^4.5.0", + "webidl-conversions": "^7.0.0", + "whatwg-mimetype": "^3.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/harmony-reflect": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz", diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package.json b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package.json index d18782fa4d..7b022ff075 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package.json +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/package.json @@ -54,6 +54,7 @@ "@angular-eslint/template-parser": "17.2.1", "@angular/cli": "~17.1.3", "@angular/compiler-cli": "^17.1.3", + "@happy-dom/jest-environment": "^14.10.1", "@nx/angular": "18.1.3", "@nx/jest": "^18.1.3", "@nx/workspace": "18.1.3", @@ -68,6 +69,7 @@ "eslint": "^8.51.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.0.1", + "happy-dom": "^14.10.1", "jest": "^29.7.0", "jest-preset-angular": "^14.0.3", "nx": "18.1.3", diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/documentation/feature/documentation.component.spec.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/documentation/feature/documentation.component.spec.ts deleted file mode 100644 index d32dd36e10..0000000000 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/documentation/feature/documentation.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { Documentation } from './documentation.component'; -import { RouterModule } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; -import { Component } from '@angular/core'; -import { provideMockStore } from '@ngrx/store/testing'; -import { initialState } from '../../../state/documentation/documentation.reducer'; - -describe('Documentation', () => { - let component: Documentation; - let fixture: ComponentFixture; - - @Component({ - selector: 'navigation', - standalone: true, - template: '' - }) - class MockNavigation {} - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [Documentation], - imports: [RouterModule, RouterTestingModule, MockNavigation], - providers: [provideMockStore({ initialState })] - }); - fixture = TestBed.createComponent(Documentation); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -});