Skip to content

Commit 2b69381

Browse files
Merge branch 'main' of github.com:CyborgTests/cyborg-test into feature/pip
2 parents f8b44b4 + dabb009 commit 2b69381

File tree

6 files changed

+60
-19
lines changed

6 files changed

+60
-19
lines changed

package-lock.json

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cyborgtests/test",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Powerfull extension for Playwright, that allows you to include manual verification steps in your automated test flow",
55
"main": "dist/index.umd.js",
66
"module": "dist/index.es.js",
@@ -52,5 +52,8 @@
5252
"package.json",
5353
"package-lock.json",
5454
"src"
55-
]
55+
],
56+
"dependencies": {
57+
"os": "^0.1.2"
58+
}
5659
}

src/test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { chromium } from "playwright";
88
import { config } from "./config";
99
import { startServer } from "./utils/server";
10+
import openInDefaultBrowser from "./utils/openInDefaultBrowser";
1011

1112
class TestFailedError extends Error {
1213
constructor(message: string) {
@@ -35,6 +36,14 @@ const test = pwTest.extend<{
3536
});
3637

3738
await tcPage.goto(`http://localhost:${config.uiPort}`);
39+
40+
await tcPage.exposeFunction('openInMainBrowser', (link: string) => {
41+
openInDefaultBrowser(link);
42+
});
43+
await tcPage.evaluate(() => {
44+
(window as any).testUtils.openInMainBrowser = (window as any).openInMainBrowser;
45+
});
46+
3847
await tcPage.bringToFront();
3948

4049
await use({

src/ui/components/Footer.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ export default function Footer() {
88

99
return (
1010
<footer className="footer">
11-
<a
12-
href="https://github.com/CyborgTests/cyborg-test"
13-
target="_blank"
14-
rel="noopener noreferrer nofollow"
15-
onClick={() => trackButtonClick('github')}
11+
<button
12+
className="footer-link"
13+
onClick={() => {
14+
trackButtonClick('github');
15+
(window as any).openInMainBrowser('https://github.com/CyborgTests/cyborg-test');
16+
}}
1617
>
1718
Github
18-
</a>
19-
<a
20-
href="https://cyborgtests.com"
21-
target="_blank"
22-
rel="noopener noreferrer nofollow"
23-
onClick={() => trackButtonClick('discord')}
19+
</button>
20+
<button
21+
className="footer-link"
22+
onClick={() => {
23+
trackButtonClick('discord');
24+
(window as any).openInMainBrowser('https://discord.com/invite/rNZCd3MHDx');
25+
}}
2426
>
2527
Discord
26-
</a>
28+
</button>
2729
</footer>
2830
);
2931
}

src/ui/styles/general.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ body {
1212
justify-content: center;
1313
flex-wrap: wrap;
1414
}
15-
.footer a {
15+
.footer-link {
1616
color: #7f8c8d;
17-
margin: 0 10px;
1817
text-decoration: none;
1918
font-size: 12px;
19+
width: unset;
20+
background-color: transparent;
21+
font-weight: 400;
2022
}
21-
.footer a:hover {
23+
.footer-link:hover {
2224
color: #3498db;
2325
}
2426
.header {

src/utils/openInDefaultBrowser.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function openInDefaultBrowser(url: string) {
2+
const { exec } = require('child_process');
3+
const os = require('os');
4+
5+
const currentPlatform = os.platform();
6+
const commands = {
7+
darwin: `open "${url}"`,
8+
win32: `start "" "${url}"`,
9+
linux: `xdg-open "${url}"`,
10+
};
11+
12+
const command = commands[currentPlatform as keyof typeof commands];
13+
if (command) exec(command);
14+
}
15+
16+
export default openInDefaultBrowser;

0 commit comments

Comments
 (0)