build(deps): bump playwright from 1.49.1 to 1.50.1

This commit is contained in:
2025-02-21 17:22:03 -07:00
parent 79c9869e65
commit dc6d9c68a9
174 changed files with 3064 additions and 1955 deletions

View File

@@ -321,6 +321,7 @@ class JobDispatcher {
startTime: new Date(params.wallTime),
duration: -1,
steps: [],
attachments: [],
location: params.location
};
steps.set(params.stepId, step);
@@ -364,6 +365,11 @@ class JobDispatcher {
body: params.body !== undefined ? Buffer.from(params.body, 'base64') : undefined
};
data.result.attachments.push(attachment);
if (params.stepId) {
var _this$_reporter$onStd4, _this$_reporter8;
const step = data.steps.get(params.stepId);
if (step) step.attachments.push(attachment);else (_this$_reporter$onStd4 = (_this$_reporter8 = this._reporter).onStdErr) === null || _this$_reporter$onStd4 === void 0 || _this$_reporter$onStd4.call(_this$_reporter8, 'Internal error: step id not found: ' + params.stepId);
}
}
_failTestWithErrors(test, errors) {
const runData = this._dataByTestId.get(test.id);
@@ -372,9 +378,9 @@ class JobDispatcher {
if (runData) {
result = runData.result;
} else {
var _this$_reporter$onTes2, _this$_reporter8;
var _this$_reporter$onTes2, _this$_reporter9;
result = test._appendTestResult();
(_this$_reporter$onTes2 = (_this$_reporter8 = this._reporter).onTestBegin) === null || _this$_reporter$onTes2 === void 0 || _this$_reporter$onTes2.call(_this$_reporter8, test, result);
(_this$_reporter$onTes2 = (_this$_reporter9 = this._reporter).onTestBegin) === null || _this$_reporter$onTes2 === void 0 || _this$_reporter$onTes2.call(_this$_reporter9, test, result);
}
result.errors = [...errors];
result.error = result.errors[0];
@@ -396,8 +402,8 @@ class JobDispatcher {
// Let's just fail the test run.
this._failureTracker.onWorkerError();
for (const error of errors) {
var _this$_reporter$onErr2, _this$_reporter9;
(_this$_reporter$onErr2 = (_this$_reporter9 = this._reporter).onError) === null || _this$_reporter$onErr2 === void 0 || _this$_reporter$onErr2.call(_this$_reporter9, error);
var _this$_reporter$onErr2, _this$_reporter10;
(_this$_reporter$onErr2 = (_this$_reporter10 = this._reporter).onError) === null || _this$_reporter$onErr2 === void 0 || _this$_reporter$onErr2.call(_this$_reporter10, error);
}
}
}
@@ -517,9 +523,9 @@ class JobDispatcher {
const allTestsSkipped = this._job.tests.every(test => test.expectedStatus === 'skipped');
if (allTestsSkipped && !this._failureTracker.hasReachedMaxFailures()) {
for (const test of this._job.tests) {
var _this$_reporter$onTes3, _this$_reporter10;
var _this$_reporter$onTes3, _this$_reporter11;
const result = test._appendTestResult();
(_this$_reporter$onTes3 = (_this$_reporter10 = this._reporter).onTestBegin) === null || _this$_reporter$onTes3 === void 0 || _this$_reporter$onTes3.call(_this$_reporter10, test, result);
(_this$_reporter$onTes3 = (_this$_reporter11 = this._reporter).onTestBegin) === null || _this$_reporter$onTes3 === void 0 || _this$_reporter$onTes3.call(_this$_reporter11, test, result);
result.status = 'skipped';
this._reportTestEnd(test, result);
}
@@ -531,14 +537,14 @@ class JobDispatcher {
return this._currentlyRunning;
}
_reportTestEnd(test, result) {
var _this$_reporter$onTes4, _this$_reporter11;
(_this$_reporter$onTes4 = (_this$_reporter11 = this._reporter).onTestEnd) === null || _this$_reporter$onTes4 === void 0 || _this$_reporter$onTes4.call(_this$_reporter11, test, result);
var _this$_reporter$onTes4, _this$_reporter12;
(_this$_reporter$onTes4 = (_this$_reporter12 = this._reporter).onTestEnd) === null || _this$_reporter$onTes4 === void 0 || _this$_reporter$onTes4.call(_this$_reporter12, test, result);
const hadMaxFailures = this._failureTracker.hasReachedMaxFailures();
this._failureTracker.onTestEnd(test, result);
if (this._failureTracker.hasReachedMaxFailures()) {
var _this$_reporter$onErr3, _this$_reporter12;
var _this$_reporter$onErr3, _this$_reporter13;
this._stopCallback();
if (!hadMaxFailures) (_this$_reporter$onErr3 = (_this$_reporter12 = this._reporter).onError) === null || _this$_reporter$onErr3 === void 0 || _this$_reporter$onErr3.call(_this$_reporter12, {
if (!hadMaxFailures) (_this$_reporter$onErr3 = (_this$_reporter13 = this._reporter).onError) === null || _this$_reporter$onErr3 === void 0 || _this$_reporter$onErr3.call(_this$_reporter13, {
message: _utilsBundle.colors.red(`Testing stopped early after ${this._failureTracker.maxFailures()} maximum allowed failures.`)
});
}

View File

@@ -37,7 +37,7 @@ class LastRunReporter {
if (!this._lastRunFile) return;
try {
const lastRunInfo = JSON.parse(await _fs.default.promises.readFile(this._lastRunFile, 'utf8'));
this._config.testIdMatcher = id => lastRunInfo.failedTests.includes(id);
this._config.lastFailedTestIdMatcher = id => lastRunInfo.failedTests.includes(id);
} catch {}
}
version() {

View File

@@ -196,6 +196,9 @@ async function createRootSuite(testRun, errors, shouldFilterOnly, additionalFile
(0, _suiteUtils.filterTestsRemoveEmptySuites)(rootSuite, test => testsInThisShard.has(test));
}
// Explicitly apply --last-failed filter after sharding.
if (config.lastFailedTestIdMatcher) (0, _suiteUtils.filterByTestIds)(rootSuite, config.lastFailedTestIdMatcher);
// Now prepend dependency projects without filtration.
{
// Filtering 'only' and sharding might have reduced the number of top-level projects.

View File

@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.addSuggestedRebaseline = addSuggestedRebaseline;
exports.applySuggestedRebaselines = applySuggestedRebaselines;
exports.clearSuggestedRebaselines = clearSuggestedRebaselines;
var _path = _interopRequireDefault(require("path"));
var _fs = _interopRequireDefault(require("fs"));
var _babelBundle = require("../transform/babelBundle");
@@ -36,13 +37,18 @@ function addSuggestedRebaseline(location, suggestedRebaseline) {
code: suggestedRebaseline
});
}
function clearSuggestedRebaselines() {
suggestedRebaselines.clear();
}
async function applySuggestedRebaselines(config, reporter) {
if (config.config.updateSnapshots !== 'all' && config.config.updateSnapshots !== 'missing') return;
if (config.config.updateSnapshots === 'none') return;
if (!suggestedRebaselines.size) return;
const [project] = (0, _projectUtils.filterProjects)(config.projects, config.cliProjectFilter);
if (!project) return;
const patches = [];
const files = [];
const gitCache = new Map();
const patchFile = _path.default.join(project.project.outputDir, 'rebaselines.patch');
for (const fileName of [...suggestedRebaselines.keys()].sort()) {
const source = await _fs.default.promises.readFile(fileName, 'utf8');
const lines = source.split('\n');
@@ -52,21 +58,24 @@ async function applySuggestedRebaselines(config, reporter) {
(0, _babelBundle.traverse)(fileNode, {
CallExpression: path => {
const node = path.node;
if (node.arguments.length !== 1) return;
if (node.arguments.length < 1) return;
if (!t.isMemberExpression(node.callee)) return;
const argument = node.arguments[0];
if (!t.isStringLiteral(argument) && !t.isTemplateLiteral(argument)) return;
const matcher = node.callee.property;
const prop = node.callee.property;
if (!prop.loc || !argument.start || !argument.end) return;
// Replacements are anchored by the location of the call expression.
// However, replacement text is meant to only replace the first argument.
for (const replacement of replacements) {
// In Babel, rows are 1-based, columns are 0-based.
if (matcher.loc.start.line !== replacement.location.line) continue;
if (matcher.loc.start.column + 1 !== replacement.location.column) continue;
const indent = lines[matcher.loc.start.line - 1].match(/^\s*/)[0];
if (prop.loc.start.line !== replacement.location.line) continue;
if (prop.loc.start.column + 1 !== replacement.location.column) continue;
const indent = lines[prop.loc.start.line - 1].match(/^\s*/)[0];
const newText = replacement.code.replace(/\{indent\}/g, indent);
ranges.push({
start: matcher.start,
end: node.end,
oldText: source.substring(matcher.start, node.end),
start: argument.start,
end: argument.end,
oldText: source.substring(argument.start, argument.end),
newText
});
// We can have multiple, hopefully equal, replacements for the same location,
@@ -81,15 +90,25 @@ async function applySuggestedRebaselines(config, reporter) {
for (const range of ranges) result = result.substring(0, range.start) + range.newText + result.substring(range.end);
const relativeName = _path.default.relative(process.cwd(), fileName);
files.push(relativeName);
patches.push(createPatch(relativeName, source, result));
if (config.config.updateSourceMethod === 'overwrite') {
await _fs.default.promises.writeFile(fileName, result);
} else if (config.config.updateSourceMethod === '3way') {
await _fs.default.promises.writeFile(fileName, applyPatchWithConflictMarkers(source, result));
} else {
const gitFolder = findGitRoot(_path.default.dirname(fileName), gitCache);
const relativeToGit = _path.default.relative(gitFolder || process.cwd(), fileName);
patches.push(createPatch(relativeToGit, source, result));
}
}
const patchFile = _path.default.join(project.project.outputDir, 'rebaselines.patch');
await _fs.default.promises.mkdir(_path.default.dirname(patchFile), {
recursive: true
});
await _fs.default.promises.writeFile(patchFile, patches.join('\n'));
const fileList = files.map(file => ' ' + _utilsBundle.colors.dim(file)).join('\n');
reporter.onStdErr(`\nNew baselines created for:\n\n${fileList}\n\n ` + _utilsBundle.colors.cyan('git apply ' + _path.default.relative(process.cwd(), patchFile)) + '\n');
reporter.onStdErr(`\nNew baselines created for:\n\n${fileList}\n`);
if (config.config.updateSourceMethod === 'patch') {
await _fs.default.promises.mkdir(_path.default.dirname(patchFile), {
recursive: true
});
await _fs.default.promises.writeFile(patchFile, patches.join('\n'));
reporter.onStdErr(`\n ` + _utilsBundle.colors.cyan('git apply ' + _path.default.relative(process.cwd(), patchFile)) + '\n');
}
}
function createPatch(fileName, before, after) {
const file = fileName.replace(/\\/g, '/');
@@ -97,4 +116,53 @@ function createPatch(fileName, before, after) {
context: 3
});
return ['diff --git a/' + file + ' b/' + file, '--- a/' + file, '+++ b/' + file, ...text.split('\n').slice(4)].join('\n');
}
function findGitRoot(dir, cache) {
const result = cache.get(dir);
if (result !== undefined) return result;
const gitPath = _path.default.join(dir, '.git');
if (_fs.default.existsSync(gitPath) && _fs.default.lstatSync(gitPath).isDirectory()) {
cache.set(dir, dir);
return dir;
}
const parentDir = _path.default.dirname(dir);
if (dir === parentDir) {
cache.set(dir, null);
return null;
}
const parentResult = findGitRoot(parentDir, cache);
cache.set(dir, parentResult);
return parentResult;
}
function applyPatchWithConflictMarkers(oldText, newText) {
const diffResult = _utilsBundle.diff.diffLines(oldText, newText);
let result = '';
let conflict = false;
diffResult.forEach(part => {
if (part.added) {
if (conflict) {
result += part.value;
result += '>>>>>>> SNAPSHOT\n';
conflict = false;
} else {
result += '<<<<<<< HEAD\n';
result += part.value;
result += '=======\n';
conflict = true;
}
} else if (part.removed) {
result += '<<<<<<< HEAD\n';
result += part.value;
result += '=======\n';
conflict = true;
} else {
if (conflict) {
result += '>>>>>>> SNAPSHOT\n';
conflict = false;
}
result += part.value;
}
});
if (conflict) result += '>>>>>>> SNAPSHOT\n';
return result;
}

View File

@@ -87,13 +87,13 @@ async function createReporterForTestServer(file, messageSink) {
_send: messageSink
}));
}
function createErrorCollectingReporter(writeToConsole) {
function createErrorCollectingReporter(screen, writeToConsole) {
const errors = [];
return {
version: () => 'v2',
onError(error) {
errors.push(error);
if (writeToConsole) process.stdout.write((0, _base.formatError)(error, _base.colors.enabled).message + '\n');
if (writeToConsole) process.stdout.write((0, _base.formatError)(screen, error).message + '\n');
},
errors: () => errors
};
@@ -147,6 +147,6 @@ class ListModeReporter {
}
onError(error) {
// eslint-disable-next-line no-console
console.error('\n' + (0, _base.formatError)(error, false).message);
console.error('\n' + (0, _base.formatError)(_base.terminalScreen, error).message);
}
}

View File

@@ -11,6 +11,7 @@ var _tasks = require("./tasks");
var _compilationCache = require("../transform/compilationCache");
var _internalReporter = require("../reporters/internalReporter");
var _lastRun = require("./lastRun");
var _base = require("../reporters/base");
/**
* Copyright 2019 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
@@ -79,7 +80,7 @@ class Runner {
return status;
}
async findRelatedTestFiles(files) {
const errorReporter = (0, _reporters.createErrorCollectingReporter)();
const errorReporter = (0, _reporters.createErrorCollectingReporter)(_base.terminalScreen);
const reporter = new _internalReporter.InternalReporter([errorReporter]);
const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createLoadTask)('in-process', {
failOnLoadErrors: true,
@@ -95,7 +96,7 @@ class Runner {
};
}
async runDevServer() {
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(true)]);
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(_base.terminalScreen, true)]);
const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createLoadTask)('in-process', {
failOnLoadErrors: true,
filterOnly: false
@@ -108,7 +109,7 @@ class Runner {
};
}
async clearCache() {
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(true)]);
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(_base.terminalScreen, true)]);
const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createClearCacheTask)(this._config)]);
return {
status

View File

@@ -267,6 +267,9 @@ function createLoadTask(mode, options) {
function createApplyRebaselinesTask() {
return {
title: 'apply rebaselines',
setup: async () => {
(0, _rebase.clearSuggestedRebaselines)();
},
teardown: async ({
config,
reporter

View File

@@ -23,6 +23,7 @@ var _webServerPlugin = require("../plugins/webServerPlugin");
var _util = require("../util");
var _teleReceiver = require("../isomorphic/teleReceiver");
var _internalReporter = require("../reporters/internalReporter");
var _base = require("../reporters/base");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright Microsoft Corporation. All rights reserved.
@@ -353,6 +354,9 @@ class TestServerDispatcher {
...(params.updateSnapshots ? {
updateSnapshots: params.updateSnapshots
} : {}),
...(params.updateSourceMethod ? {
updateSourceMethod: params.updateSourceMethod
} : {}),
...(params.workers ? {
workers: params.workers
} : {})
@@ -400,7 +404,7 @@ class TestServerDispatcher {
await this._updateWatcher(true);
}
async findRelatedTestFiles(params) {
const errorReporter = (0, _reporters.createErrorCollectingReporter)();
const errorReporter = (0, _reporters.createErrorCollectingReporter)(_base.internalScreen);
const reporter = new _internalReporter.InternalReporter([errorReporter]);
const config = await this._loadConfigOrReportError(reporter);
if (!config) return {
@@ -528,7 +532,7 @@ async function innerRunTestServer(configLocation, configCLIOverrides, options, o
return sigintWatcher.hadSignal() ? 'interrupted' : 'passed';
}
function chunkToPayload(type, chunk) {
if (chunk instanceof Buffer) return {
if (chunk instanceof Uint8Array) return {
type,
buffer: chunk.toString('base64')
};

View File

@@ -330,7 +330,7 @@ function readCommand() {
const name = key === null || key === void 0 ? void 0 : key.name;
if (name === 'q') return 'exit';
if (name === 'h') {
process.stdout.write(`${(0, _base.separator)()}
process.stdout.write(`${(0, _base.separator)(_base.terminalScreen)}
Run tests
${_utilsBundle.colors.bold('enter')} ${_utilsBundle.colors.dim('run tests')}
${_utilsBundle.colors.bold('f')} ${_utilsBundle.colors.dim('run failed tests')}
@@ -379,14 +379,14 @@ function printConfiguration(options, title) {
if (title) tokens.push(_utilsBundle.colors.dim(`(${title})`));
tokens.push(_utilsBundle.colors.dim(`#${seq++}`));
const lines = [];
const sep = (0, _base.separator)();
const sep = (0, _base.separator)(_base.terminalScreen);
lines.push('\x1Bc' + sep);
lines.push(`${tokens.join(' ')}`);
lines.push(`${_utilsBundle.colors.dim('Show & reuse browser:')} ${_utilsBundle.colors.bold(showBrowserServer ? 'on' : 'off')}`);
process.stdout.write(lines.join('\n'));
}
function printBufferPrompt(dirtyTestFiles, rootDir) {
const sep = (0, _base.separator)();
const sep = (0, _base.separator)(_base.terminalScreen);
process.stdout.write('\x1Bc');
process.stdout.write(`${sep}\n`);
if (dirtyTestFiles.size === 0) {
@@ -398,7 +398,7 @@ function printBufferPrompt(dirtyTestFiles, rootDir) {
process.stdout.write(`\n${_utilsBundle.colors.dim(`Press`)} ${_utilsBundle.colors.bold('enter')} ${_utilsBundle.colors.dim('to run')}, ${_utilsBundle.colors.bold('q')} ${_utilsBundle.colors.dim('to quit or')} ${_utilsBundle.colors.bold('h')} ${_utilsBundle.colors.dim('for more options.')}\n\n`);
}
function printPrompt() {
const sep = (0, _base.separator)();
const sep = (0, _base.separator)(_base.terminalScreen);
process.stdout.write(`
${sep}
${_utilsBundle.colors.dim('Waiting for file changes. Press')} ${_utilsBundle.colors.bold('enter')} ${_utilsBundle.colors.dim('to run tests')}, ${_utilsBundle.colors.bold('q')} ${_utilsBundle.colors.dim('to quit or')} ${_utilsBundle.colors.bold('h')} ${_utilsBundle.colors.dim('for more options.')}