Skip to content

Commit bc60e73

Browse files
committed
PD-6016 repair the six specs that discovery had been hiding
Turning spec discovery back on surfaced six component specs that had never run. They fail identically on 20.1.6, so none of this is fallout from the upgrade; they simply rotted unobserved. Most were missing TestBed imports for what their templates actually use: MatFormField/MatInput for mat-form-field and the errorStateMatcher binding, MatCard/MatCheckbox for the interstitial, ReactiveFormsModule for [formGroup], and CUSTOM_ELEMENTS_SCHEMA where a template renders a sibling app-* component. Real modules rather than NO_ERRORS_SCHEMA, so the specs keep catching template errors. Two specs stubbed FormBuilder with object literals that only looked like form controls. They passed only because ReactiveFormsModule was absent and the bindings were never evaluated; with the directives present they have to be real, so use the actual FormBuilder. ShareEmailsDomains also needed a record carrying emailDomains, since the component builds its form inside a filtered subscription and an empty record left formGroup bound to undefined.
1 parent e63bd14 commit bc60e73

6 files changed

Lines changed: 71 additions & 22 deletions

File tree

src/app/account-settings/components/settings-actions-duplicated/settings-actions-duplicated.component.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { UserService } from '../../../core'
1515
import { AccountActionsDuplicatedService } from '../../../core/account-actions-duplicated/account-actions-duplicated.service'
1616

1717
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
18+
import { MatFormFieldModule } from '@angular/material/form-field'
19+
import { MatInputModule } from '@angular/material/input'
20+
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
1821

1922
describe('SettingsActionsDuplicatedComponent', () => {
2023
let component: SettingsActionsDuplicatedComponent
@@ -27,6 +30,9 @@ describe('SettingsActionsDuplicatedComponent', () => {
2730
MatDialogModule,
2831
RouterTestingModule,
2932
ReactiveFormsModule,
33+
MatFormFieldModule,
34+
MatInputModule,
35+
NoopAnimationsModule,
3036
],
3137
declarations: [SettingsActionsDuplicatedComponent],
3238
providers: [

src/app/account-settings/components/settings-security-password/settings-security-password.component.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ import { Overlay } from '@angular/cdk/overlay'
1313
import { RouterTestingModule } from '@angular/router/testing'
1414

1515
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
16+
import { ReactiveFormsModule } from '@angular/forms'
17+
import { MatFormFieldModule } from '@angular/material/form-field'
18+
import { MatInputModule } from '@angular/material/input'
19+
import { MatIconModule } from '@angular/material/icon'
20+
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
1621

1722
describe('SettingsSecurityPasswordComponent', () => {
1823
let component: SettingsSecurityPasswordComponent
1924
let fixture: ComponentFixture<SettingsSecurityPasswordComponent>
2025

2126
beforeEach(async () => {
2227
await TestBed.configureTestingModule({
23-
imports: [HttpClientTestingModule, RouterTestingModule],
28+
imports: [
29+
HttpClientTestingModule,
30+
ReactiveFormsModule,
31+
RouterTestingModule,
32+
MatFormFieldModule,
33+
MatInputModule,
34+
MatIconModule,
35+
NoopAnimationsModule,
36+
],
2437
declarations: [SettingsSecurityPasswordComponent],
2538
providers: [
2639
WINDOW_PROVIDERS,

src/app/cdk/deep-select-input/deep-select-input/deep-select-input.component.spec.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'
22

33
import { DeepSelectInputComponent } from './deep-select-input.component'
44
import { PlatformInfoService } from '../../platform-info'
5-
import { FormBuilder } from '@angular/forms'
5+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms'
66
import { get } from 'lodash'
77
import { of } from 'rxjs'
88
import { MatMenuModule } from '@angular/material/menu'
9+
import { MatFormFieldModule } from '@angular/material/form-field'
10+
import { MatInputModule } from '@angular/material/input'
11+
import { MatIconModule } from '@angular/material/icon'
12+
import { MatDividerModule } from '@angular/material/divider'
13+
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
914

1015
describe('DeepSelectInputComponent', () => {
1116
let component: DeepSelectInputComponent
@@ -21,18 +26,16 @@ describe('DeepSelectInputComponent', () => {
2126
get: () => of({}),
2227
},
2328
},
24-
{
25-
provide: FormBuilder,
26-
useValue: {
27-
group: () => ({
28-
get: () => ({
29-
valueChanges: of(''),
30-
}),
31-
}),
32-
},
33-
},
3429
],
35-
imports: [MatMenuModule],
30+
imports: [
31+
MatMenuModule,
32+
ReactiveFormsModule,
33+
MatFormFieldModule,
34+
MatInputModule,
35+
MatIconModule,
36+
MatDividerModule,
37+
NoopAnimationsModule,
38+
],
3639
})
3740
fixture = TestBed.createComponent(DeepSelectInputComponent)
3841
component = fixture.componentInstance

src/app/cdk/interstitials/share-emails-domains/interstitial-component/share-emails-domains.component.spec.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing'
22

33
import { ShareEmailsDomainsComponent } from './share-emails-domains.component'
4-
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'
4+
import {
5+
FormBuilder,
6+
FormControl,
7+
FormGroup,
8+
ReactiveFormsModule,
9+
} from '@angular/forms'
510
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service'
611

712
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
13+
import { MatCardModule } from '@angular/material/card'
14+
import { MatCheckboxModule } from '@angular/material/checkbox'
15+
import { MatDividerModule } from '@angular/material/divider'
16+
import { MatIconModule } from '@angular/material/icon'
817
import { UserService } from 'src/app/core'
918
import { PlatformInfoService } from 'src/app/cdk/platform-info/platform-info.service'
1019
import { WINDOW_PROVIDERS } from 'src/app/cdk/window'
@@ -18,18 +27,18 @@ describe('ShareEmailsDomainsComponent', () => {
1827
beforeEach(() => {
1928
TestBed.configureTestingModule({
2029
declarations: [ShareEmailsDomainsComponent],
30+
imports: [
31+
MatCardModule,
32+
ReactiveFormsModule,
33+
MatCheckboxModule,
34+
MatDividerModule,
35+
MatIconModule,
36+
],
2137
providers: [
2238
{
2339
provide: PlatformInfoService,
2440
useValue: {},
2541
},
26-
{
27-
provide: FormBuilder,
28-
useValue: {
29-
array: () => [new FormControl({})],
30-
group: () => new FormGroup({}),
31-
},
32-
},
3342
{
3443
provide: RecordEmailsService,
3544
useValue: {},
@@ -47,7 +56,21 @@ describe('ShareEmailsDomainsComponent', () => {
4756
{
4857
provide: RecordService,
4958
useValue: {
50-
getRecord: () => of({}),
59+
// The component only builds its form once a record carrying
60+
// emailDomains arrives, so an empty record leaves `form` undefined
61+
// and `[formGroup]` with nothing to bind to.
62+
getRecord: () =>
63+
of({
64+
emails: {
65+
emailDomains: [
66+
{
67+
value: 'example.org',
68+
visibility: 'PRIVATE',
69+
createdDate: { timestamp: 1 },
70+
},
71+
],
72+
},
73+
}),
5174
},
5275
},
5376
WINDOW_PROVIDERS,

src/app/page-not-found-404/page-not-found/page-not-found.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing'
22

33
import { PageNotFoundComponent } from './page-not-found.component'
4+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
45

56
describe('PageNotFoundComponent', () => {
67
let component: PageNotFoundComponent
@@ -9,6 +10,7 @@ describe('PageNotFoundComponent', () => {
910
beforeEach(() => {
1011
TestBed.configureTestingModule({
1112
declarations: [PageNotFoundComponent],
13+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
1214
})
1315
fixture = TestBed.createComponent(PageNotFoundComponent)
1416
component = fixture.componentInstance

src/app/record/components/work-details/work-details.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
88
import { MatDialog } from '@angular/material/dialog'
99
import { MatSnackBar } from '@angular/material/snack-bar'
1010
import { MonthDayYearDateToStringPipe } from 'src/app/shared/pipes/month-day-year-date-to-string/month-day-year-date-to-string.pipe'
11+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
1112

1213
describe('WorkDetailsComponent', () => {
1314
let component: WorkDetailsComponent
@@ -18,6 +19,7 @@ describe('WorkDetailsComponent', () => {
1819
imports: [HttpClientTestingModule, RouterTestingModule],
1920
declarations: [WorkDetailsComponent, MonthDayYearDateToStringPipe],
2021
providers: [WINDOW_PROVIDERS, SnackbarService, MatSnackBar, MatDialog],
22+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
2123
})
2224
fixture = TestBed.createComponent(WorkDetailsComponent)
2325
component = fixture.componentInstance

0 commit comments

Comments
 (0)