-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathbrowserstack-app-validation.test.ts
More file actions
66 lines (59 loc) · 1.92 KB
/
Copy pathbrowserstack-app-validation.test.ts
File metadata and controls
66 lines (59 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
const {
assertBrowserStackAppUrl,
assertBrowserStackCustomId,
writeGithubOutputs,
} = require('./browserstack-app-validation.cjs');
describe('browserstack-app-validation', () => {
it('accepts valid BrowserStack app URLs', () => {
expect(assertBrowserStackAppUrl('bs://abc123DEF', 'test')).toBe(
'bs://abc123DEF',
);
});
it('rejects malformed BrowserStack app URLs', () => {
expect(() =>
assertBrowserStackAppUrl('https://evil.example/app', 'test'),
).toThrow('Invalid test');
expect(() =>
assertBrowserStackAppUrl('bs://bad chars', 'test'),
).toThrow('Invalid test');
});
it('accepts expected custom_id formats with branch slug', () => {
expect(
assertBrowserStackCustomId(
'MetaMask-Android-With-SRP-main-123',
'with-srp',
),
).toBe('MetaMask-Android-With-SRP-main-123');
expect(
assertBrowserStackCustomId(
'MetaMask-Android-Without-SRP-main-456',
'without-srp',
),
).toBe('MetaMask-Android-Without-SRP-main-456');
expect(
assertBrowserStackCustomId(
'MetaMask-Android-With-SRP-feature_x-789',
'with-srp',
),
).toBe('MetaMask-Android-With-SRP-feature_x-789');
});
it('rejects legacy custom_id formats without branch slug', () => {
expect(() =>
assertBrowserStackCustomId('MetaMask-Android-With-SRP-123', 'with-srp'),
).toThrow('Invalid with-srp custom_id');
});
it('writes only validated single-line GitHub outputs', () => {
const outputPath = path.join(os.tmpdir(), `gh-output-${Date.now()}.txt`);
writeGithubOutputs(outputPath, {
found: 'true',
'with-srp-browserstack-url': 'bs://abc123',
});
expect(fs.readFileSync(outputPath, 'utf8')).toBe(
'found=true\nwith-srp-browserstack-url=bs://abc123\n',
);
fs.unlinkSync(outputPath);
});
});