Skip to content

Commit a28d2ab

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Reland "[test] Remove snapshot assertions"
This is a reland of commit 8b9f9ec 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]> Change-Id: I779ee739f2e11a07934d42d048d49a46d8c7717e Bug: 402422819 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6346912 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 4108f27 commit a28d2ab

File tree

8 files changed

+1047
-1930
lines changed

8 files changed

+1047
-1930
lines changed

test/e2e/application/cookies_test.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/e2e/recorder/helpers.ts

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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';
56
import type {ElementHandle, Page} from 'puppeteer-core';
67

78
import type {UserFlow} from '../../../front_end/panels/recorder/models/Schema.js';
@@ -19,7 +20,6 @@ import {
1920
waitFor,
2021
waitForAria,
2122
} 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, selectorAttribute);
102+
await createRecording(name ?? TEST_RECORDING_NAME, selectorAttribute);
103103
const onRecordingStarted = onRecordingStateChanged();
104104
await click('devtools-control-button');
105105
await waitFor('devtools-recording-view');
@@ -160,31 +160,71 @@ interface RecordingSnapshotOptions {
160160
* @defaultValue `false`
161161
*/
162162
offsets?: boolean;
163+
/**
164+
* @defaultValue `true`
165+
*/
166+
expectCommon?: boolean;
167+
resource?: string;
163168
}
164169

165-
export const preprocessRecording = (
170+
export const processAndVerifyBaseRecording = (
166171
recording: unknown,
167172
options: RecordingSnapshotOptions = {},
168173
) => {
174+
const {
175+
offsets = false,
176+
expectCommon = true,
177+
resource = 'recorder/recorder.html',
178+
} = options;
179+
169180
let value = JSON.stringify(recording).replaceAll(
170181
`:${getTestServerPort()}`,
171182
':<test-port>',
172183
);
173184
value = value.replaceAll('\u200b', '');
174-
if (!options.offsets) {
185+
if (!offsets) {
175186
value = value.replaceAll(
176187
/,?"(?:offsetY|offsetX)":[0-9]+(?:\.[0-9]+)?/g,
177188
'',
178189
);
179190
}
180-
return JSON.parse(value.trim());
181-
};
182191

183-
export const assertRecordingMatchesSnapshot = (
184-
recording: unknown,
185-
options: RecordingSnapshotOptions = {},
186-
) => {
187-
assertMatchesJSONSnapshot(preprocessRecording(recording, options));
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;
188228
};
189229

190230
async function setCode(flow: string) {
@@ -257,7 +297,7 @@ export async function setupRecorderWithScriptAndReplay(
257297
await onceFinished;
258298
}
259299

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

0 commit comments

Comments
 (0)