feat(material/dialog): Make MatTestDialogOpener better
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 活発
- 技術スタック
- angular, typescript
- 領域
- testing
調査の方向性
Start with MatTestDialogOpener and the existing dialog-opener.spec.ts, then read the referenced OverlayContainer implementation and its testing-overlay comments. Investigate how fixture querying, harness loading, and afterClosed handling currently work. Done should provide a defined, tested approach that makes dialog content queryable from the fixture and simplifies checking the closing result.
索引モデルが issue の本文から書いたものです。
説明
Feature Description
There's currently no supported way to render an overlay (and therefore a MatDialog) inside a component fixture during unit tests. Because overlays are attached to an OverlayContainer appended to document.body, they live outside the fixture's root element, which means:
fixture.debugElement.query(...) finds nothing inside the dialog.
Loading harnesses requires TestbedHarnessEnvironment.documentRootLoader rather than the standard fixture loader.
Asserting on dialog content requires reaching back to the document, e.g. getDebugNode(document.body) as DebugElement.
MatTestDialogOpener helps instantiate a dialog-hosted component (and removes the boilerplate of manually providing MatDialogRef + MAT_DIALOG_DATA mocks), but it doesn't address querying, and testing the close result still needs a manual async flush.
I prototyped a custom OverlayContainer that appends the container into the DOM, but it expects the fixture to be the first element in body:
import { OverlayContainer } from "@angular/cdk/overlay";
import { Injectable, Provider } from "@angular/core";
@Injectable()
export class FixtureOverlayContainer extends OverlayContainer {
protected override _createContainer(): void {
super._createContainer();
document.body.children[0].appendChild(this._containerElement);
}
}
export function provideFixtureOverlayContainer(): Provider[] {
return [{
provide: OverlayContainer,
useClass: FixtureOverlayContainer
}]
}
providing it in the test environment removes the need of documentRootLoader, the "simple" loader is enough, but querying the fixture still finds nothing. I found some comments about testing overlay plans I expect it could be useful in this case.
MatTestDialogOpener helps with creating the component, but testing the closing result still requires a manual await step, like
await firstValueFrom(fixture.componentInstance.dialogRef.afterClosed());. I found in the dialog-opener.spec.ts a setTimeout is awaited, there could be an async method baked into the MatTestDialogOpener class.
It would be really nice, if there would be a TestOverlay which creates the dialog in the fixture, so no const bodyDebug = getDebugNode(document.body) as DebugElement; is needed for querying components inside the dialog. Or at least have some methods getting the debugElement of the newly created component.
Use Case
Make testing components meant to be used inside MatDialogs more convenient, not like this
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 84
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
angular/components のほかの issue
-
area: material/tree docs gemini-triaged needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
angular/components#33832 ·
-
area: material/datepicker gemini-triaged P4
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/components#33763 · コメント 2 件 · リアクション 3 件 ·
-
area: material/table gemini-triaged P4
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
angular/components#33709 · コメント 1 件 ·
-
area: material/table docs gemini-triaged P4
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/components#33455 ·
-
area: material/core gemini-triaged P3
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
angular/components#33059 · コメント 2 件 ·
angular/components の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mksglu/context-mode#1200 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/claude-code#96687 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
AOSSIE-Org/DebateAI#582 · コメント 2 件 ·