mattermost-mobile-upstream/detox/e2e/path_builder.js
yasserfaraazkhan 59ec6ae61f fix(e2e): harden Detox flakes from CI 30250131265 and bound webhook sidecar
Stabilize interactive dialogs, custom status clear, bookmarks, pin waits,
and mm_blocks long-press; soft-fail and hard-budget the Cloudflare sidecar
so tunnel DNS hangs no longer stall shards.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 21:32:23 +05:30

34 lines
1.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const path = require('path');
const sanitizeFilename = require('sanitize-filename');
const SANITIZE_OPTIONS = {replacement: '_'};
// `/` is illegal in filesystem paths. sanitize-filename turns it into `_`, which
// breaks TSIO screenshot linking (folder basename must match Jest fullName).
// Use U+2215 DIVISION SLASH so the folder stays unique and TSIO can reverse it.
const PATH_SEP_TOKEN = '\u2215';
const sanitize = (filename) => sanitizeFilename(
String(filename).replaceAll('/', PATH_SEP_TOKEN),
SANITIZE_OPTIONS,
);
class CustomPathBuilder {
constructor({rootDir}) {
this.rootDir = rootDir;
}
buildPathForTestArtifact(artifactName, testSummary = null) {
const fullName = (testSummary && testSummary.fullName) || '';
const segments = [this.rootDir, sanitize(fullName), sanitize(artifactName)];
return path.join(...segments.filter(Boolean));
}
}
module.exports = ({rootDir}) => {
return new CustomPathBuilder({rootDir});
};