mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
[PM-18599] Forbid unknown property and element in tests (#13556)
Fail tests when relying on unknownProperties or unknownElements. Existing instances are whitelist and have tickets created and assigned to the relevant teams.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
import { addCustomMatchers } from "@bitwarden/common/spec";
|
import { addCustomMatchers } from "@bitwarden/common/spec";
|
||||||
|
|
||||||
addCustomMatchers();
|
addCustomMatchers();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../../libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": [
|
"@bitwarden/vault-export-core": [
|
||||||
"../../libs/tools/export/vault-export/vault-export-core/src"
|
"../../libs/tools/export/vault-export/vault-export-core/src"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../../libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": [
|
"@bitwarden/vault-export-core": [
|
||||||
"../../libs/tools/export/vault-export/vault-export-core/src"
|
"../../libs/tools/export/vault-export/vault-export-core/src"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ describe("RecoverTwoFactorComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
imports: [I18nPipe],
|
imports: [I18nPipe],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(RecoverTwoFactorComponent);
|
fixture = TestBed.createComponent(RecoverTwoFactorComponent);
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ describe("BreachReportComponent", () => {
|
|||||||
useValue: mock<I18nService>(),
|
useValue: mock<I18nService>(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
|
errorOnUnknownProperties: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ describe("ExposedPasswordsReportComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
schemas: [],
|
schemas: [],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
|
errorOnUnknownProperties: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ describe("InactiveTwoFactorReportComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
schemas: [],
|
schemas: [],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ describe("ReusedPasswordsReportComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
schemas: [],
|
schemas: [],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ describe("UnsecuredWebsitesReportComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
schemas: [],
|
schemas: [],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ describe("WeakPasswordsReportComponent", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
schemas: [],
|
schemas: [],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownElements: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../../libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": [
|
"@bitwarden/vault-export-core": [
|
||||||
"../../libs/tools/export/vault-export/vault-export-core/src"
|
"../../libs/tools/export/vault-export/vault-export-core/src"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../../libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": [
|
"@bitwarden/vault-export-core": [
|
||||||
"../../libs/tools/export/vault-export/vault-export-core/src"
|
"../../libs/tools/export/vault-export/vault-export-core/src"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"@bitwarden/key-management-ui": ["../../libs/key-management-ui/src"],
|
"@bitwarden/key-management-ui": ["../../libs/key-management-ui/src"],
|
||||||
"@bitwarden/platform": ["../../libs/platform/src"],
|
"@bitwarden/platform": ["../../libs/platform/src"],
|
||||||
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
"@bitwarden/ui-common": ["../../libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../../libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../../libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
"@bitwarden/tools-card": ["../../libs/tools/card/src"],
|
||||||
"@bitwarden/vault": ["../../libs/vault/src"],
|
"@bitwarden/vault": ["../../libs/vault/src"],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
|
|
||||||
import { addCustomMatchers } from "@bitwarden/common/spec";
|
import { addCustomMatchers } from "@bitwarden/common/spec";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
addCustomMatchers();
|
addCustomMatchers();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/common/*": ["../common/src/*"],
|
"@bitwarden/common/*": ["../common/src/*"],
|
||||||
"@bitwarden/platform": ["../platform/src"],
|
"@bitwarden/platform": ["../platform/src"],
|
||||||
"@bitwarden/ui-common": ["../ui/common/src"]
|
"@bitwarden/ui-common": ["../ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../ui/common/src/setup-jest"]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"@bitwarden/send-ui": ["../tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["../tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["../tools/card/src"],
|
"@bitwarden/tools-card": ["../tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["../ui/common/src"],
|
"@bitwarden/ui-common": ["../ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["../ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": ["../tools/export/vault-export/vault-export-core/src"],
|
"@bitwarden/vault-export-core": ["../tools/export/vault-export/vault-export-core/src"],
|
||||||
"@bitwarden/vault-export-ui": ["../tools/export/vault-export/vault-export-ui/src"],
|
"@bitwarden/vault-export-ui": ["../tools/export/vault-export/vault-export-ui/src"],
|
||||||
"@bitwarden/vault": ["../vault/src"]
|
"@bitwarden/vault": ["../vault/src"]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ describe("SendListFiltersComponent", () => {
|
|||||||
{ provide: BillingAccountProfileStateService, useValue: billingAccountProfileStateService },
|
{ provide: BillingAccountProfileStateService, useValue: billingAccountProfileStateService },
|
||||||
{ provide: AccountService, useValue: accountService },
|
{ provide: AccountService, useValue: accountService },
|
||||||
],
|
],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownProperties: false,
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(SendListFiltersComponent);
|
fixture = TestBed.createComponent(SendListFiltersComponent);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|||||||
@@ -11,5 +11,13 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/bitwarden/clients"
|
"url": "https://github.com/bitwarden/clients"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0"
|
"license": "GPL-3.0",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./src/index.ts"
|
||||||
|
},
|
||||||
|
"./setup-jest": {
|
||||||
|
"import": "./src/setup-jest.ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
libs/ui/common/src/setup-jest.ts
Normal file
12
libs/ui/common/src/setup-jest.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import "jest-preset-angular/setup-jest";
|
||||||
|
import { getTestBed } from "@angular/core/testing";
|
||||||
|
import {
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting,
|
||||||
|
} from "@angular/platform-browser-dynamic/testing";
|
||||||
|
|
||||||
|
getTestBed().resetTestEnvironment();
|
||||||
|
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
|
||||||
|
errorOnUnknownElements: true,
|
||||||
|
errorOnUnknownProperties: true,
|
||||||
|
});
|
||||||
@@ -32,6 +32,8 @@ describe("CipherFormGeneratorComponent", () => {
|
|||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [CipherFormGeneratorComponent],
|
imports: [CipherFormGeneratorComponent],
|
||||||
providers: [{ provide: I18nService, useValue: { t: (key: string) => key } }],
|
providers: [{ provide: I18nService, useValue: { t: (key: string) => key } }],
|
||||||
|
// FIXME(PM-18598): Replace unknownElements and unknownProperties with actual imports
|
||||||
|
errorOnUnknownProperties: false,
|
||||||
})
|
})
|
||||||
.overrideComponent(CipherFormGeneratorComponent, {
|
.overrideComponent(CipherFormGeneratorComponent, {
|
||||||
remove: { imports: [GeneratorModule] },
|
remove: { imports: [GeneratorModule] },
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { webcrypto } from "crypto";
|
import { webcrypto } from "crypto";
|
||||||
import "jest-preset-angular/setup-jest";
|
import "@bitwarden/ui-common/setup-jest";
|
||||||
|
|
||||||
Object.defineProperty(window, "CSS", { value: null });
|
Object.defineProperty(window, "CSS", { value: null });
|
||||||
Object.defineProperty(window, "getComputedStyle", {
|
Object.defineProperty(window, "getComputedStyle", {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"@bitwarden/send-ui": ["./libs/tools/send/send-ui/src"],
|
"@bitwarden/send-ui": ["./libs/tools/send/send-ui/src"],
|
||||||
"@bitwarden/tools-card": ["./libs/tools/card/src"],
|
"@bitwarden/tools-card": ["./libs/tools/card/src"],
|
||||||
"@bitwarden/ui-common": ["./libs/ui/common/src"],
|
"@bitwarden/ui-common": ["./libs/ui/common/src"],
|
||||||
|
"@bitwarden/ui-common/setup-jest": ["./libs/ui/common/src/setup-jest"],
|
||||||
"@bitwarden/vault-export-core": ["./libs/tools/export/vault-export/vault-export-core/src"],
|
"@bitwarden/vault-export-core": ["./libs/tools/export/vault-export/vault-export-core/src"],
|
||||||
"@bitwarden/vault-export-ui": ["./libs/tools/export/vault-export/vault-export-ui/src"],
|
"@bitwarden/vault-export-ui": ["./libs/tools/export/vault-export/vault-export-ui/src"],
|
||||||
"@bitwarden/vault": ["./libs/vault/src"],
|
"@bitwarden/vault": ["./libs/vault/src"],
|
||||||
|
|||||||
Reference in New Issue
Block a user