Skip to content

Commit ad9b44a

Browse files
kenossDevtools-frontend LUCI CQ
authored andcommitted
Preload: Make PreloadingView.test.ts work
Before this CL, ``` $ npm run test front_end/panels/application/preloading/PreloadingView.test.ts ``` didn't work. This CL fixes it. In addition, this CL moves `await this.#getSourceText();` call in `RuleSetDetailsView.render()`, because it prevents to call `RenderCoordinator.write()` and `RenderCoordinator.done()` can't wait the issued rendering correctly. Bug: none Change-Id: I13d39413dbda4c1805510a6d5d2663839789434c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6063701 Auto-Submit: Ken Okada <[email protected]> Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent 0e37636 commit ad9b44a

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

front_end/panels/application/preloading/PreloadingView.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ function createSummaryView(target: SDK.Target.Target): Resources.PreloadingView.
289289
}
290290

291291
describeWithMockConnection('PreloadingRuleSetView', () => {
292+
beforeEach(() => {
293+
SDK.ChildTargetManager.ChildTargetManager.install();
294+
});
295+
292296
it('renders grid and details', async () => {
293297
const emulator = new NavigationEmulator();
294298
await emulator.openDevTools();
@@ -494,6 +498,10 @@ describeWithMockConnection('PreloadingRuleSetView', () => {
494498
});
495499

496500
describeWithMockConnection('PreloadingAttemptView', () => {
501+
beforeEach(() => {
502+
SDK.ChildTargetManager.ChildTargetManager.install();
503+
});
504+
497505
it('renders grid and details', async () => {
498506
const emulator = new NavigationEmulator();
499507
await emulator.openDevTools();
@@ -941,6 +949,10 @@ describeWithMockConnection('PreloadingAttemptView', () => {
941949
});
942950

943951
describeWithMockConnection('PreloadingSummaryView', () => {
952+
beforeEach(() => {
953+
SDK.ChildTargetManager.ChildTargetManager.install();
954+
});
955+
944956
it('shows information of preloading of the last page', async () => {
945957
const emulator = new NavigationEmulator();
946958
await emulator.openDevTools();
@@ -1006,6 +1018,10 @@ async function testWarnings(
10061018
}
10071019

10081020
describeWithMockConnection('PreloadingWarningsView', () => {
1021+
beforeEach(() => {
1022+
SDK.ChildTargetManager.ChildTargetManager.install();
1023+
});
1024+
10091025
it('shows no warnings if holdback flags are disabled', async () => {
10101026
await testWarnings(
10111027
{

front_end/panels/application/preloading/components/RuleSetDetailsView.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describeWithEnvironment('RuleSetDetailsView', () => {
3232
const data = null;
3333

3434
const component = await renderRuleSetDetailsView(data, false);
35-
await coordinator.done({waitForWork: true});
3635
assert.isNotNull(component.shadowRoot);
3736
assert.strictEqual(component.shadowRoot.textContent, '');
3837
});
@@ -54,7 +53,6 @@ describeWithEnvironment('RuleSetDetailsView', () => {
5453
backendNodeId: 1 as Protocol.DOM.BackendNodeId,
5554
};
5655
const component = await renderRuleSetDetailsView(data, false);
57-
await coordinator.done({waitForWork: true});
5856
assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined);
5957

6058
const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor;
@@ -79,13 +77,12 @@ describeWithEnvironment('RuleSetDetailsView', () => {
7977
requestId: 'reqeustId' as Protocol.Network.RequestId,
8078
};
8179
const component = await renderRuleSetDetailsView(data, false);
82-
await coordinator.done({waitForWork: true});
8380
assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined);
8481
const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor;
8582
assert.strictEqual(textEditor.state.doc.toString(), data.sourceText);
8683
});
8784

88-
it('renders invalid rule set', async () => {
85+
it('renders invalid rule set, broken JSON', async () => {
8986
const data: Protocol.Preload.RuleSet = {
9087
id: 'ruleSetId:1' as Protocol.Preload.RuleSetId,
9188
loaderId: 'loaderId:1' as Protocol.Network.LoaderId,
@@ -100,14 +97,13 @@ describeWithEnvironment('RuleSetDetailsView', () => {
10097
errorMessage: 'Line: 6, column: 1, Syntax error.',
10198
};
10299
const component = await renderRuleSetDetailsView(data, false);
103-
await coordinator.done({waitForWork: true});
104100
assert.deepEqual(
105101
component.shadowRoot?.getElementById('error-message-text')?.textContent, 'Line: 6, column: 1, Syntax error.');
106102
const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor;
107103
assert.strictEqual(textEditor.state.doc.toString(), data.sourceText);
108104
});
109105

110-
it('renders invalid rule set', async () => {
106+
it('renders invalid rule set, lacking `urls`', async () => {
111107
const data: Protocol.Preload.RuleSet = {
112108
id: 'ruleSetId:1' as Protocol.Preload.RuleSetId,
113109
loaderId: 'loaderId:1' as Protocol.Network.LoaderId,
@@ -125,7 +121,6 @@ describeWithEnvironment('RuleSetDetailsView', () => {
125121
errorMessage: 'A list rule must have a "urls" array.',
126122
};
127123
const component = await renderRuleSetDetailsView(data, false);
128-
await coordinator.done({waitForWork: true});
129124
assert.deepEqual(
130125
component.shadowRoot?.getElementById('error-message-text')?.textContent,
131126
'A list rule must have a "urls" array.');
@@ -141,7 +136,6 @@ describeWithEnvironment('RuleSetDetailsView', () => {
141136
backendNodeId: 1 as Protocol.DOM.BackendNodeId,
142137
};
143138
const component = await renderRuleSetDetailsView(data, true);
144-
await coordinator.done({waitForWork: true});
145139
assert.deepEqual(component.shadowRoot?.getElementById('error-message-text')?.textContent, undefined);
146140

147141
const textEditor = component.shadowRoot?.querySelector('devtools-text-editor') as TextEditor.TextEditor.TextEditor;

front_end/panels/application/preloading/components/RuleSetDetailsView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ export class RuleSetDetailsView extends LegacyWrapper.LegacyWrapper.WrappableCom
4545
}
4646

4747
async #render(): Promise<void> {
48-
const sourceText = await this.#getSourceText();
49-
50-
await coordinator.write('RuleSetDetailsView render', () => {
48+
await coordinator.write('RuleSetDetailsView render', async () => {
5149
if (this.#data === null) {
5250
LitHtml.render(LitHtml.nothing, this.#shadow, {host: this});
5351
return;
5452
}
5553

54+
const sourceText = await this.#getSourceText();
55+
5656
// Disabled until https://crbug.com/1079231 is fixed.
5757
// clang-format off
5858
LitHtml.render(html`

0 commit comments

Comments
 (0)