Skip to content

Commit 07c4224

Browse files
pfaffeDevtools-frontend LUCI CQ
authored andcommitted
Revert "[test] Remove snapshot assertions"
This reverts commit 8b9f9ec. Reason for revert: Lots of flakiness and tree closures: https://ci.chromium.org/ui/p/devtools-frontend/builders/ci/Stand-alone%20Linux/19772/overview Original change's description: > [test] Remove snapshot assertions > > Only used in recorder. > > Fixed: 402422819 > Change-Id: Ia3e20ecce7e1fbaf176e856289d628c8d22d8fa7 > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6345653 > Auto-Submit: Nikolay Vitkov <[email protected]> > Reviewed-by: Alex Rudenko <[email protected]> > Commit-Queue: Nikolay Vitkov <[email protected]> No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iffc801ee90a6db66affc906fb35d3718fdb501b5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6346612 Bot-Commit: Rubber Stamper <[email protected]> Auto-Submit: Philip Pfaffe <[email protected]> Commit-Queue: Rubber Stamper <[email protected]>
1 parent 8483ee7 commit 07c4224

File tree

8 files changed

+1928
-1043
lines changed

8 files changed

+1928
-1043
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"The Application Tab shows cookies even when navigating to an unreachable page (crbug.com/1047348) - 1": [
3+
{
4+
"name": "urlencoded",
5+
"value": "Hello%2BWorld!"
6+
},
7+
{
8+
"name": "__Host-foo3",
9+
"value": "bar"
10+
},
11+
{
12+
"name": "foo2",
13+
"value": "bar"
14+
},
15+
{
16+
"name": "foo",
17+
"value": "bar"
18+
}
19+
]
20+
}

test/e2e/recorder/helpers.ts

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import {assert} from 'chai';
65
import type {ElementHandle, Page} from 'puppeteer-core';
76

87
import type {UserFlow} from '../../../front_end/panels/recorder/models/Schema.js';
@@ -20,6 +19,7 @@ import {
2019
waitFor,
2120
waitForAria,
2221
} from '../../../test/shared/helper.js';
22+
import {assertMatchesJSONSnapshot} from '../../../test/shared/snapshots.js';
2323

2424
const RECORDER_CONTROLLER_TAG_NAME = 'devtools-recorder-controller';
2525
const TEST_RECORDING_NAME = 'New Recording';
@@ -96,10 +96,10 @@ async function createRecording(name: string, selectorAttribute?: string) {
9696
}
9797

9898
export async function createAndStartRecording(
99-
name?: string,
99+
name: string,
100100
selectorAttribute?: string,
101101
) {
102-
await createRecording(name ?? TEST_RECORDING_NAME, selectorAttribute);
102+
await createRecording(name, selectorAttribute);
103103
const onRecordingStarted = onRecordingStateChanged();
104104
await click('devtools-control-button');
105105
await waitFor('devtools-recording-view');
@@ -160,71 +160,31 @@ interface RecordingSnapshotOptions {
160160
* @defaultValue `false`
161161
*/
162162
offsets?: boolean;
163-
/**
164-
* @defaultValue `true`
165-
*/
166-
expectCommon?: boolean;
167-
resource?: string;
168163
}
169164

170-
export const processAndVerifyBaseRecording = (
165+
export const preprocessRecording = (
171166
recording: unknown,
172167
options: RecordingSnapshotOptions = {},
173168
) => {
174-
const {
175-
offsets = false,
176-
expectCommon = true,
177-
resource = 'recorder/recorder.html',
178-
} = options;
179-
180169
let value = JSON.stringify(recording).replaceAll(
181170
`:${getTestServerPort()}`,
182171
':<test-port>',
183172
);
184173
value = value.replaceAll('\u200b', '');
185-
if (!offsets) {
174+
if (!options.offsets) {
186175
value = value.replaceAll(
187176
/,?"(?:offsetY|offsetX)":[0-9]+(?:\.[0-9]+)?/g,
188177
'',
189178
);
190179
}
180+
return JSON.parse(value.trim());
181+
};
191182

192-
const parsed = JSON.parse(value.trim());
193-
if (expectCommon) {
194-
assert.strictEqual(
195-
parsed.title,
196-
'New Recording',
197-
);
198-
delete parsed.title;
199-
assert.deepEqual(
200-
parsed.steps[0],
201-
{
202-
type: 'setViewport',
203-
width: 1280,
204-
height: 720,
205-
deviceScaleFactor: 1,
206-
isMobile: false,
207-
hasTouch: false,
208-
isLandscape: false
209-
},
210-
);
211-
assert.deepEqual(
212-
parsed.steps[1],
213-
{
214-
type: 'navigate',
215-
url: `https://localhost:<test-port>/test/e2e/resources/${resource}`,
216-
assertedEvents: [{
217-
type: 'navigation',
218-
url: `https://localhost:<test-port>/test/e2e/resources/${resource}`,
219-
title: '',
220-
}]
221-
},
222-
);
223-
224-
parsed.steps = parsed.steps.slice(2);
225-
}
226-
227-
return parsed;
183+
export const assertRecordingMatchesSnapshot = (
184+
recording: unknown,
185+
options: RecordingSnapshotOptions = {},
186+
) => {
187+
assertMatchesJSONSnapshot(preprocessRecording(recording, options));
228188
};
229189

230190
async function setCode(flow: string) {
@@ -297,7 +257,7 @@ export async function setupRecorderWithScriptAndReplay(
297257
await onceFinished;
298258
}
299259

300-
export async function getCurrentRecording() {
260+
export async function getCurrentRecording(): Promise<unknown> {
301261
const {frontend} = getBrowserAndPages();
302262
await frontend.bringToFront();
303263
const controller = await $(RECORDER_CONTROLLER_TAG_NAME);

0 commit comments

Comments
 (0)