@lullabot/playwright-testing 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/github-a11y-summary +2 -2
- package/bin/github-failure-summary +4 -4
- package/lib/accessibility-baseline-file.d.ts +6 -6
- package/lib/accessibility-baseline-file.js +29 -23
- package/lib/accessibility-baseline.js +5 -3
- package/lib/accessible-screenshot.d.ts +4 -4
- package/lib/accessible-screenshot.js +110 -88
- package/lib/focus.js +4 -1
- package/lib/frames.js +4 -4
- package/lib/github/a11y-summary.js +74 -79
- package/lib/github/attachments.d.ts +1 -1
- package/lib/github/attachments.js +36 -34
- package/lib/github/failure-summary.d.ts +4 -4
- package/lib/github/failure-summary.js +140 -108
- package/lib/github/index.d.ts +6 -6
- package/lib/github/report-paths.js +17 -9
- package/lib/hover.js +17 -17
- package/lib/images.js +15 -12
- package/lib/index.d.ts +13 -13
- package/lib/interaction-states.d.ts +2 -2
- package/lib/interaction-states.js +7 -7
- package/lib/mock/index.d.ts +1 -1
- package/lib/mock/youtube.d.ts +1 -1
- package/lib/mock/youtube.js +1 -1
- package/lib/pseudo-state.d.ts +2 -2
- package/lib/pseudo-state.js +15 -7
- package/lib/videos.js +21 -10
- package/lib/visualdiff.d.ts +4 -4
- package/lib/visualdiff.js +35 -27
- package/package.json +3 -3
- package/src/accessibility-baseline-file.test.ts +190 -154
- package/src/accessibility-baseline-file.ts +107 -83
- package/src/accessibility-baseline.test.ts +869 -433
- package/src/accessibility-baseline.ts +41 -21
- package/src/accessible-screenshot.test.ts +551 -423
- package/src/accessible-screenshot.ts +358 -251
- package/src/focus.test.ts +23 -23
- package/src/focus.ts +7 -2
- package/src/fonts.test.ts +13 -13
- package/src/fonts.ts +1 -1
- package/src/frames.test.ts +10 -8
- package/src/frames.ts +5 -5
- package/src/github/a11y-summary.test.ts +436 -332
- package/src/github/a11y-summary.ts +189 -179
- package/src/github/attachments.test.ts +228 -167
- package/src/github/attachments.ts +144 -121
- package/src/github/failure-summary.test.ts +660 -445
- package/src/github/failure-summary.ts +376 -274
- package/src/github/index.test.ts +14 -14
- package/src/github/index.ts +6 -6
- package/src/github/report-paths.test.ts +211 -156
- package/src/github/report-paths.ts +75 -61
- package/src/hover.test.ts +50 -46
- package/src/hover.ts +18 -18
- package/src/images.test.ts +251 -206
- package/src/images.ts +52 -43
- package/src/index.ts +13 -13
- package/src/interaction-states.test.ts +72 -42
- package/src/interaction-states.ts +43 -29
- package/src/mock/index.ts +1 -1
- package/src/mock/youtube.test.ts +26 -26
- package/src/mock/youtube.ts +4 -6
- package/src/pseudo-state.test.ts +58 -51
- package/src/pseudo-state.ts +32 -27
- package/src/videos.test.ts +559 -399
- package/src/videos.ts +68 -44
- package/src/visualdiff.test.ts +416 -315
- package/src/visualdiff.ts +140 -99
package/src/github/index.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it } from
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
AttachmentUploader,
|
|
4
4
|
createPathResolver,
|
|
@@ -8,17 +8,17 @@ import {
|
|
|
8
8
|
generateFailureSummary,
|
|
9
9
|
parseA11yResults,
|
|
10
10
|
parseFailures,
|
|
11
|
-
} from
|
|
11
|
+
} from "./index";
|
|
12
12
|
|
|
13
|
-
describe(
|
|
14
|
-
it(
|
|
15
|
-
expect(parseA11yResults).toBeTypeOf(
|
|
16
|
-
expect(generateA11ySummary).toBeTypeOf(
|
|
17
|
-
expect(generateA11yAnnotations).toBeTypeOf(
|
|
18
|
-
expect(parseFailures).toBeTypeOf(
|
|
19
|
-
expect(generateFailureSummary).toBeTypeOf(
|
|
20
|
-
expect(generateFailureComment).toBeTypeOf(
|
|
21
|
-
expect(AttachmentUploader).toBeTypeOf(
|
|
22
|
-
expect(createPathResolver).toBeTypeOf(
|
|
23
|
-
})
|
|
24
|
-
})
|
|
13
|
+
describe("GitHub package entry point", () => {
|
|
14
|
+
it("exports the reporting, attachment, and path-remapping APIs", () => {
|
|
15
|
+
expect(parseA11yResults).toBeTypeOf("function");
|
|
16
|
+
expect(generateA11ySummary).toBeTypeOf("function");
|
|
17
|
+
expect(generateA11yAnnotations).toBeTypeOf("function");
|
|
18
|
+
expect(parseFailures).toBeTypeOf("function");
|
|
19
|
+
expect(generateFailureSummary).toBeTypeOf("function");
|
|
20
|
+
expect(generateFailureComment).toBeTypeOf("function");
|
|
21
|
+
expect(AttachmentUploader).toBeTypeOf("function");
|
|
22
|
+
expect(createPathResolver).toBeTypeOf("function");
|
|
23
|
+
});
|
|
24
|
+
});
|
package/src/github/index.ts
CHANGED
|
@@ -3,10 +3,10 @@ export {
|
|
|
3
3
|
generateSummary as generateA11ySummary,
|
|
4
4
|
main as runA11ySummary,
|
|
5
5
|
parseA11yResults,
|
|
6
|
-
} from
|
|
7
|
-
export type { A11yReport, A11yTestResult } from
|
|
6
|
+
} from "./a11y-summary";
|
|
7
|
+
export type { A11yReport, A11yTestResult } from "./a11y-summary";
|
|
8
8
|
|
|
9
|
-
export * from
|
|
9
|
+
export * from "./attachments";
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
FAILURE_MARKER_PREFIX,
|
|
@@ -19,7 +19,7 @@ export {
|
|
|
19
19
|
resolveImagePaths,
|
|
20
20
|
uploaderFromEnvironment,
|
|
21
21
|
uploadImages,
|
|
22
|
-
} from
|
|
22
|
+
} from "./failure-summary";
|
|
23
23
|
export type {
|
|
24
24
|
FailedTest,
|
|
25
25
|
FailureImage,
|
|
@@ -30,6 +30,6 @@ export type {
|
|
|
30
30
|
IncludeMode,
|
|
31
31
|
PathResolutionSummary,
|
|
32
32
|
SummaryOptions,
|
|
33
|
-
} from
|
|
33
|
+
} from "./failure-summary";
|
|
34
34
|
|
|
35
|
-
export * from
|
|
35
|
+
export * from "./report-paths";
|
|
@@ -1,222 +1,277 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as os from
|
|
4
|
-
import * as path from
|
|
5
|
-
import { createPathResolver, parsePathPrefix } from
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { createPathResolver, parsePathPrefix } from "./report-paths";
|
|
6
6
|
|
|
7
|
-
let tmpDir: string
|
|
7
|
+
let tmpDir: string;
|
|
8
8
|
|
|
9
9
|
beforeEach(() => {
|
|
10
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(),
|
|
11
|
-
})
|
|
10
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "report-paths-test-"));
|
|
11
|
+
});
|
|
12
12
|
|
|
13
13
|
afterEach(() => {
|
|
14
|
-
fs.rmSync(tmpDir, { recursive: true, force: true })
|
|
15
|
-
})
|
|
14
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
15
|
+
});
|
|
16
16
|
|
|
17
17
|
/** Create a file, and every directory above it, under the temporary directory. */
|
|
18
18
|
function touch(relativePath: string): string {
|
|
19
|
-
const filePath = path.join(tmpDir, relativePath)
|
|
20
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true })
|
|
21
|
-
fs.writeFileSync(filePath,
|
|
22
|
-
return filePath
|
|
19
|
+
const filePath = path.join(tmpDir, relativePath);
|
|
20
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
21
|
+
fs.writeFileSync(filePath, "png");
|
|
22
|
+
return filePath;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
27
|
-
expect(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
expect(parsePathPrefix(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
expect(resolve(filePath)).toEqual({ path: filePath, found: true })
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('re-roots a container path onto the checkout', () => {
|
|
56
|
-
touch('test/playwright/test-results/home-chromium/home-1-diff.png')
|
|
25
|
+
describe("parsePathPrefix", () => {
|
|
26
|
+
it("splits on the first colon", () => {
|
|
27
|
+
expect(
|
|
28
|
+
parsePathPrefix("/var/www/html:/home/runner/work/site/site"),
|
|
29
|
+
).toEqual({
|
|
30
|
+
from: "/var/www/html",
|
|
31
|
+
to: "/home/runner/work/site/site",
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("keeps a colon in the local path, as Windows drives have", () => {
|
|
36
|
+
expect(parsePathPrefix("/var/www/html:C:/checkout")).toEqual({
|
|
37
|
+
from: "/var/www/html",
|
|
38
|
+
to: "C:/checkout",
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("rejects a value that is not a pair", () => {
|
|
43
|
+
expect(parsePathPrefix("/var/www/html")).toBeNull();
|
|
44
|
+
expect(parsePathPrefix(":/home/runner")).toBeNull();
|
|
45
|
+
expect(parsePathPrefix("/var/www/html:")).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("createPathResolver", () => {
|
|
50
|
+
it("leaves a path that already resolves alone", () => {
|
|
51
|
+
const filePath = touch("test/playwright/test-results/diff.png");
|
|
57
52
|
const resolve = createPathResolver({
|
|
58
|
-
reportPath: path.join(tmpDir,
|
|
59
|
-
})
|
|
53
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
54
|
+
});
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
56
|
+
expect(resolve(filePath)).toEqual({ path: filePath, found: true });
|
|
57
|
+
});
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
it("re-roots a container path onto the checkout", () => {
|
|
60
|
+
touch("test/playwright/test-results/home-chromium/home-1-diff.png");
|
|
61
|
+
const resolve = createPathResolver({
|
|
62
|
+
reportPath: path.join(
|
|
63
|
+
tmpDir,
|
|
64
|
+
"test/playwright/test-results/results.json",
|
|
65
|
+
),
|
|
66
|
+
});
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
const resolution = resolve(
|
|
69
|
+
"/var/www/html/test/playwright/test-results/home-chromium/home-1-diff.png",
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(resolution.found).toBe(true);
|
|
73
|
+
expect(resolution.path).toBe(
|
|
74
|
+
path.join(
|
|
75
|
+
tmpDir,
|
|
76
|
+
"test/playwright/test-results/home-chromium/home-1-diff.png",
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
expect(resolution.prefix).toEqual({ from: "/var/www/html", to: tmpDir });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("finds the files when the report sits outside the output directory", () => {
|
|
72
83
|
// The arrangement the integration test produces: the report is written
|
|
73
84
|
// beside the Playwright config while the images go to a separate output
|
|
74
85
|
// directory, so the two share nothing but the mount point.
|
|
75
|
-
touch(
|
|
86
|
+
touch(
|
|
87
|
+
"test/playwright/test-results-visual/fixture-chromium/fixture-diff.png",
|
|
88
|
+
);
|
|
76
89
|
const resolve = createPathResolver({
|
|
77
|
-
reportPath: path.join(tmpDir,
|
|
78
|
-
})
|
|
90
|
+
reportPath: path.join(tmpDir, "test/playwright/visual-diff-results.json"),
|
|
91
|
+
});
|
|
79
92
|
|
|
80
93
|
const resolution = resolve(
|
|
81
|
-
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
expect(resolution.found).toBe(true)
|
|
85
|
-
expect(resolution.path)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
"/var/www/html/test/playwright/test-results-visual/fixture-chromium/fixture-diff.png",
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(resolution.found).toBe(true);
|
|
98
|
+
expect(resolution.path).toBe(
|
|
99
|
+
path.join(
|
|
100
|
+
tmpDir,
|
|
101
|
+
"test/playwright/test-results-visual/fixture-chromium/fixture-diff.png",
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("does not assume a fixed offset between the report and the mount point", () => {
|
|
90
107
|
// This repository's own CI creates the project under a generated directory,
|
|
91
108
|
// so its depth below the workspace differs from the container's.
|
|
92
|
-
touch(
|
|
109
|
+
touch(
|
|
110
|
+
"tmp/pwtest-abc123/test/playwright/test-results/home-chromium/home-1-diff.png",
|
|
111
|
+
);
|
|
93
112
|
const resolve = createPathResolver({
|
|
94
|
-
reportPath: path.join(
|
|
95
|
-
|
|
113
|
+
reportPath: path.join(
|
|
114
|
+
tmpDir,
|
|
115
|
+
"tmp/pwtest-abc123/test/playwright/test-results/results.json",
|
|
116
|
+
),
|
|
117
|
+
});
|
|
96
118
|
|
|
97
119
|
const resolution = resolve(
|
|
98
|
-
|
|
99
|
-
)
|
|
120
|
+
"/var/www/html/test/playwright/test-results/home-chromium/home-1-diff.png",
|
|
121
|
+
);
|
|
100
122
|
|
|
101
|
-
expect(resolution.found).toBe(true)
|
|
123
|
+
expect(resolution.found).toBe(true);
|
|
102
124
|
expect(resolution.prefix).toEqual({
|
|
103
|
-
from:
|
|
104
|
-
to: path.join(tmpDir,
|
|
105
|
-
})
|
|
106
|
-
})
|
|
125
|
+
from: "/var/www/html",
|
|
126
|
+
to: path.join(tmpDir, "tmp/pwtest-abc123"),
|
|
127
|
+
});
|
|
128
|
+
});
|
|
107
129
|
|
|
108
|
-
it(
|
|
130
|
+
it("prefers the longest tail, so the most specific match wins", () => {
|
|
109
131
|
// A shallow decoy sharing the last two components must not beat the real
|
|
110
132
|
// file, which shares many more.
|
|
111
|
-
touch(
|
|
112
|
-
touch(
|
|
133
|
+
touch("decoy/fixture-chromium/fixture-diff.png");
|
|
134
|
+
touch("test/playwright/test-results/fixture-chromium/fixture-diff.png");
|
|
113
135
|
|
|
114
136
|
const resolve = createPathResolver({
|
|
115
|
-
reportPath: path.join(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
reportPath: path.join(
|
|
138
|
+
tmpDir,
|
|
139
|
+
"test/playwright/test-results/results.json",
|
|
140
|
+
),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(
|
|
144
|
+
resolve(
|
|
145
|
+
"/var/www/html/test/playwright/test-results/fixture-chromium/fixture-diff.png",
|
|
146
|
+
).path,
|
|
147
|
+
).toBe(
|
|
148
|
+
path.join(
|
|
149
|
+
tmpDir,
|
|
150
|
+
"test/playwright/test-results/fixture-chromium/fixture-diff.png",
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("will not identify a file by its name alone", () => {
|
|
123
156
|
// One component of tail is a coincidence waiting to happen: some unrelated
|
|
124
157
|
// fixture-diff.png must not be served up as the failure's diff image.
|
|
125
|
-
touch(
|
|
126
|
-
const resolve = createPathResolver({
|
|
158
|
+
touch("fixture-diff.png");
|
|
159
|
+
const resolve = createPathResolver({
|
|
160
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
161
|
+
});
|
|
127
162
|
|
|
128
|
-
expect(resolve(
|
|
129
|
-
|
|
163
|
+
expect(resolve("/var/www/html/somewhere/else/fixture-diff.png").found).toBe(
|
|
164
|
+
false,
|
|
165
|
+
);
|
|
166
|
+
});
|
|
130
167
|
|
|
131
|
-
it(
|
|
168
|
+
it("reports a path it cannot find rather than inventing one", () => {
|
|
132
169
|
const resolve = createPathResolver({
|
|
133
|
-
reportPath: path.join(
|
|
134
|
-
|
|
170
|
+
reportPath: path.join(
|
|
171
|
+
tmpDir,
|
|
172
|
+
"test/playwright/test-results/results.json",
|
|
173
|
+
),
|
|
174
|
+
});
|
|
135
175
|
|
|
136
|
-
const resolution = resolve(
|
|
176
|
+
const resolution = resolve(
|
|
177
|
+
"/var/www/html/test/playwright/test-results/missing-diff.png",
|
|
178
|
+
);
|
|
137
179
|
|
|
138
180
|
expect(resolution).toEqual({
|
|
139
|
-
path:
|
|
181
|
+
path: "/var/www/html/test/playwright/test-results/missing-diff.png",
|
|
140
182
|
found: false,
|
|
141
|
-
})
|
|
142
|
-
})
|
|
183
|
+
});
|
|
184
|
+
});
|
|
143
185
|
|
|
144
|
-
it(
|
|
145
|
-
touch(
|
|
146
|
-
touch(
|
|
186
|
+
it("reuses a mapping it has already worked out", () => {
|
|
187
|
+
touch("test-results/one/a-diff.png");
|
|
188
|
+
touch("test-results/two/b-diff.png");
|
|
147
189
|
|
|
148
|
-
const looked: string[] = []
|
|
190
|
+
const looked: string[] = [];
|
|
149
191
|
const resolve = createPathResolver({
|
|
150
|
-
reportPath: path.join(tmpDir,
|
|
151
|
-
exists: filePath => {
|
|
152
|
-
looked.push(filePath)
|
|
153
|
-
return fs.existsSync(filePath)
|
|
192
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
193
|
+
exists: (filePath) => {
|
|
194
|
+
looked.push(filePath);
|
|
195
|
+
return fs.existsSync(filePath);
|
|
154
196
|
},
|
|
155
|
-
})
|
|
197
|
+
});
|
|
156
198
|
|
|
157
|
-
resolve(
|
|
158
|
-
const afterFirst = looked.length
|
|
159
|
-
looked.length = 0
|
|
199
|
+
resolve("/var/www/html/test-results/one/a-diff.png");
|
|
200
|
+
const afterFirst = looked.length;
|
|
201
|
+
looked.length = 0;
|
|
160
202
|
|
|
161
|
-
expect(resolve(
|
|
203
|
+
expect(resolve("/var/www/html/test-results/two/b-diff.png").found).toBe(
|
|
204
|
+
true,
|
|
205
|
+
);
|
|
162
206
|
// The learned mapping is tried straight after the original path, rather
|
|
163
207
|
// than searching the tree again.
|
|
164
|
-
expect(looked.length).toBeLessThan(afterFirst)
|
|
208
|
+
expect(looked.length).toBeLessThan(afterFirst);
|
|
165
209
|
expect(looked).toEqual([
|
|
166
|
-
|
|
167
|
-
path.join(tmpDir,
|
|
168
|
-
])
|
|
169
|
-
})
|
|
210
|
+
"/var/www/html/test-results/two/b-diff.png",
|
|
211
|
+
path.join(tmpDir, "test-results/two/b-diff.png"),
|
|
212
|
+
]);
|
|
213
|
+
});
|
|
170
214
|
|
|
171
|
-
it(
|
|
172
|
-
touch(
|
|
173
|
-
touch(
|
|
215
|
+
it("prefers an explicit prefix over anything it would work out", () => {
|
|
216
|
+
touch("elsewhere/test-results/home-1-diff.png");
|
|
217
|
+
touch("test/playwright/test-results/home-1-diff.png");
|
|
174
218
|
|
|
175
219
|
const resolve = createPathResolver({
|
|
176
|
-
reportPath: path.join(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
220
|
+
reportPath: path.join(
|
|
221
|
+
tmpDir,
|
|
222
|
+
"test/playwright/test-results/results.json",
|
|
223
|
+
),
|
|
224
|
+
prefixes: [
|
|
225
|
+
{
|
|
226
|
+
from: "/var/www/html/test/playwright",
|
|
227
|
+
to: path.join(tmpDir, "elsewhere"),
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(
|
|
233
|
+
resolve("/var/www/html/test/playwright/test-results/home-1-diff.png")
|
|
234
|
+
.path,
|
|
235
|
+
).toBe(path.join(tmpDir, "elsewhere/test-results/home-1-diff.png"));
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("ignores a prefix the path is not under", () => {
|
|
239
|
+
touch("test-results/diff.png");
|
|
186
240
|
const resolve = createPathResolver({
|
|
187
|
-
reportPath: path.join(tmpDir,
|
|
188
|
-
prefixes: [{ from:
|
|
189
|
-
})
|
|
241
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
242
|
+
prefixes: [{ from: "/somewhere/else", to: tmpDir }],
|
|
243
|
+
});
|
|
190
244
|
|
|
191
245
|
// The explicit prefix does not apply, and one component of tail is too
|
|
192
246
|
// little to search on.
|
|
193
|
-
expect(resolve(
|
|
194
|
-
})
|
|
247
|
+
expect(resolve("/var/www/html/diff.png").found).toBe(false);
|
|
248
|
+
});
|
|
195
249
|
|
|
196
|
-
it(
|
|
197
|
-
touch(
|
|
250
|
+
it("does not match a prefix part way through a directory name", () => {
|
|
251
|
+
touch("results/diff.png");
|
|
198
252
|
const resolve = createPathResolver({
|
|
199
|
-
reportPath: path.join(tmpDir,
|
|
200
|
-
prefixes: [{ from:
|
|
201
|
-
})
|
|
253
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
254
|
+
prefixes: [{ from: "/var/www/ht", to: tmpDir }],
|
|
255
|
+
});
|
|
202
256
|
|
|
203
257
|
// /var/www/html starts with the string /var/www/ht but is not under it,
|
|
204
258
|
// so the explicit mapping must not fire. The search still finds the file.
|
|
205
|
-
const resolution = resolve(
|
|
206
|
-
expect(resolution.path).toBe(path.join(tmpDir,
|
|
207
|
-
expect(resolution.prefix).toEqual({ from:
|
|
208
|
-
})
|
|
259
|
+
const resolution = resolve("/var/www/html/results/diff.png");
|
|
260
|
+
expect(resolution.path).toBe(path.join(tmpDir, "results/diff.png"));
|
|
261
|
+
expect(resolution.prefix).toEqual({ from: "/var/www/html", to: tmpDir });
|
|
262
|
+
});
|
|
209
263
|
|
|
210
|
-
it(
|
|
211
|
-
touch(
|
|
264
|
+
it("tolerates trailing slashes on the local side", () => {
|
|
265
|
+
touch("test-results/diff.png");
|
|
212
266
|
const resolve = createPathResolver({
|
|
213
|
-
reportPath: path.join(tmpDir,
|
|
267
|
+
reportPath: path.join(tmpDir, "results.json"),
|
|
214
268
|
// A run of them, not just one: the trim is an index scan rather than a
|
|
215
269
|
// regex, because `/[\\/]+$/` backtracks quadratically over exactly this.
|
|
216
|
-
prefixes: [{ from:
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
expect(resolve(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
})
|
|
270
|
+
prefixes: [{ from: "/var/www/html", to: `${tmpDir}///` }],
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
expect(resolve("/var/www/html/test-results/diff.png").path).toBe(
|
|
274
|
+
`${tmpDir}/test-results/diff.png`,
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
});
|