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

@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
});
exports.toMatchAriaSnapshot = toMatchAriaSnapshot;
var _matcherHint = require("./matcherHint");
var _utilsBundle = require("playwright-core/lib/utilsBundle");
var _expectBundle = require("../common/expectBundle");
var _util = require("../util");
var _expect = require("./expect");
var _globals = require("../common/globals");
var _utils = require("playwright-core/lib/utils");
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright Microsoft Corporation. All rights reserved.
*
@@ -27,8 +29,8 @@ var _utils = require("playwright-core/lib/utils");
* limitations under the License.
*/
async function toMatchAriaSnapshot(receiver, expected, options = {}) {
var _options$timeout;
async function toMatchAriaSnapshot(receiver, expectedParam, options = {}) {
var _testInfo$_projectInt;
const matcherName = 'toMatchAriaSnapshot';
const testInfo = (0, _globals.currentTestInfo)();
if (!testInfo) throw new Error(`toMatchAriaSnapshot() must be called during the test`);
@@ -36,18 +38,41 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
pass: !this.isNot,
message: () => '',
name: 'toMatchAriaSnapshot',
expected
expected: ''
};
const updateSnapshots = testInfo.config.updateSnapshots;
const pathTemplate = (_testInfo$_projectInt = testInfo._projectInternal.expect) === null || _testInfo$_projectInt === void 0 || (_testInfo$_projectInt = _testInfo$_projectInt.toMatchAriaSnapshot) === null || _testInfo$_projectInt === void 0 ? void 0 : _testInfo$_projectInt.pathTemplate;
const defaultTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{ext}';
const matcherOptions = {
isNot: this.isNot,
promise: this.promise
};
if (typeof expected !== 'string') {
throw new Error([(0, _matcherHint.matcherHint)(this, receiver, matcherName, receiver, expected, matcherOptions), `${_utilsBundle.colors.bold('Matcher error')}: ${(0, _expectBundle.EXPECTED_COLOR)('expected')} value must be a string`, this.utils.printWithType('Expected', expected, this.utils.printExpected)].join('\n\n'));
let expected;
let timeout;
let expectedPath;
if ((0, _utils.isString)(expectedParam)) {
var _options$timeout;
expected = expectedParam;
timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : this.timeout;
} else {
var _expectedParam$timeou;
if (expectedParam !== null && expectedParam !== void 0 && expectedParam.name) {
expectedPath = testInfo._resolveSnapshotPath(pathTemplate, defaultTemplate, [(0, _util.sanitizeFilePathBeforeExtension)(expectedParam.name)]);
} else {
let snapshotNames = testInfo[snapshotNamesSymbol];
if (!snapshotNames) {
snapshotNames = {
anonymousSnapshotIndex: 0
};
testInfo[snapshotNamesSymbol] = snapshotNames;
}
const fullTitleWithoutSpec = [...testInfo.titlePath.slice(1), ++snapshotNames.anonymousSnapshotIndex].join(' ');
expectedPath = testInfo._resolveSnapshotPath(pathTemplate, defaultTemplate, [(0, _utils.sanitizeForFilePath)((0, _util.trimLongString)(fullTitleWithoutSpec)) + '.yml']);
}
expected = await _fs.default.promises.readFile(expectedPath, 'utf8').catch(() => '');
timeout = (_expectedParam$timeou = expectedParam === null || expectedParam === void 0 ? void 0 : expectedParam.timeout) !== null && _expectedParam$timeou !== void 0 ? _expectedParam$timeou : this.timeout;
}
const generateMissingBaseline = updateSnapshots === 'missing' && !expected;
const generateNewBaseline = updateSnapshots === 'all' || generateMissingBaseline;
if (generateMissingBaseline) {
if (this.isNot) {
const message = `Matchers using ".not" can't generate new baselines`;
@@ -61,7 +86,6 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
expected = `- none "Generating new baseline"`;
}
}
const timeout = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : this.timeout;
expected = unshift(expected);
const {
matches: pass,
@@ -96,15 +120,46 @@ async function toMatchAriaSnapshot(receiver, expected, options = {}) {
return messagePrefix + this.utils.printDiffOrStringify(expected, receivedText, labelExpected, 'Received', false) + (0, _util.callLogText)(log);
}
};
if (!this.isNot && pass === this.isNot && generateNewBaseline) {
// Only rebaseline failed snapshots.
const suggestedRebaseline = `toMatchAriaSnapshot(\`\n${(0, _utils.escapeTemplateString)(indent(typedReceived.regex, '{indent} '))}\n{indent}\`)`;
return {
pass: this.isNot,
message: () => '',
name: 'toMatchAriaSnapshot',
suggestedRebaseline
};
if (!this.isNot) {
if (updateSnapshots === 'all' || updateSnapshots === 'changed' && pass === this.isNot || generateMissingBaseline) {
if (expectedPath) {
await _fs.default.promises.mkdir(_path.default.dirname(expectedPath), {
recursive: true
});
await _fs.default.promises.writeFile(expectedPath, typedReceived.regex, 'utf8');
const relativePath = _path.default.relative(process.cwd(), expectedPath);
if (updateSnapshots === 'missing') {
const message = `A snapshot doesn't exist at ${relativePath}, writing actual.`;
testInfo._hasNonRetriableError = true;
testInfo._failWithError(new Error(message));
} else {
const message = `A snapshot is generated at ${relativePath}.`;
/* eslint-disable no-console */
console.log(message);
}
return {
pass: true,
message: () => '',
name: 'toMatchAriaSnapshot'
};
} else {
const suggestedRebaseline = `\`\n${(0, _utils.escapeTemplateString)(indent(typedReceived.regex, '{indent} '))}\n{indent}\``;
if (updateSnapshots === 'missing') {
const message = 'A snapshot is not provided, generating new baseline.';
testInfo._hasNonRetriableError = true;
testInfo._failWithError(new Error(message));
}
// TODO: ideally, we should return "pass: true" here because this matcher passes
// when regenerating baselines. However, we can only access suggestedRebaseline in case
// of an error, so we fail here and workaround it in the expect implementation.
return {
pass: false,
message: () => '',
name: 'toMatchAriaSnapshot',
suggestedRebaseline
};
}
}
}
return {
name: matcherName,
@@ -123,10 +178,10 @@ function unshift(snapshot) {
if (!line.trim()) continue;
const match = line.match(/^(\s*)/);
if (match && match[1].length < whitespacePrefixLength) whitespacePrefixLength = match[1].length;
break;
}
return lines.filter(t => t.trim()).map(line => line.substring(whitespacePrefixLength)).join('\n');
}
function indent(snapshot, indent) {
return snapshot.split('\n').map(line => indent + line).join('\n');
}
}
const snapshotNamesSymbol = Symbol('snapshotNames');