Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit bb81407

Browse files
committed
fix: use playwright electron to test example
1 parent 9df0d83 commit bb81407

File tree

11 files changed

+5045
-1019
lines changed

11 files changed

+5045
-1019
lines changed

examples/browser-angular/extra-webpack.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export default {
1010
// global `Buffer` until https://github.com/isaacs/core-util-is/issues/29
1111
// is fixed.
1212
new ProvidePlugin({
13-
global: ['global'],
14-
Buffer: ['buffer', 'Buffer'],
15-
process: 'process/browser',
13+
global: ['global']
1614
})
17-
],
15+
]
1816
} as Configuration;

examples/browser-angular/package.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212
"test:example": "npm run build && playwright test tests --retries=3"
1313
},
1414
"dependencies": {
15-
"@angular/animations": "~12.1.2",
16-
"@angular/common": "~12.1.2",
17-
"@angular/compiler": "~12.1.2",
18-
"@angular/core": "~12.1.2",
19-
"@angular/forms": "~12.1.2",
20-
"@angular/platform-browser": "~12.1.2",
21-
"@angular/platform-browser-dynamic": "~12.1.2",
22-
"@angular/router": "~12.1.2",
15+
"@angular/animations": "~12.2.0",
16+
"@angular/common": "~12.2.0",
17+
"@angular/compiler": "~12.2.0",
18+
"@angular/core": "~12.2.0",
19+
"@angular/forms": "~12.2.0",
20+
"@angular/platform-browser": "~12.2.0",
21+
"@angular/platform-browser-dynamic": "~12.2.0",
22+
"@angular/router": "~12.2.0",
2323
"global": "^4.4.0",
2424
"ipfs": "^0.58.0",
2525
"rxjs": "~6.6.0",
26-
"tslib": "^2.2.0",
26+
"tslib": "^2.3.0",
2727
"zone.js": "~0.11.4"
2828
},
2929
"devDependencies": {
3030
"@angular-builders/custom-webpack": "^12.1.0",
31-
"@angular-devkit/build-angular": "~12.1.2",
32-
"@angular/cli": "~12.1.2",
33-
"@angular/compiler-cli": "~12.1.2",
31+
"@angular-devkit/build-angular": "~12.2.2",
32+
"@angular/cli": "~12.2.2",
33+
"@angular/compiler-cli": "~12.2.0",
3434
"@playwright/test": "^1.12.3",
3535
"@types/jasmine": "~3.8.0",
36-
"@types/node": "^12.11.1",
36+
"@types/node": "^16.6.2",
3737
"jasmine-core": "~3.8.0",
3838
"karma": "~6.3.0",
3939
"karma-chrome-launcher": "~3.1.0",
@@ -42,9 +42,7 @@
4242
"karma-jasmine-html-reporter": "~1.7.0",
4343
"node-polyfill-webpack-plugin": "^1.1.4",
4444
"playwright": "^1.12.3",
45-
"polka": "^0.5.2",
4645
"rimraf": "^3.0.2",
47-
"sirv": "^1.0.12",
48-
"typescript": "~4.3.2"
46+
"typescript": "~4.3.5"
4947
}
5048
}

examples/browser-angular/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>BrowserAngular</title>
5+
<title>IPFS Angular</title>
66
<base href="/">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<link rel="icon" type="image/x-icon" href="favicon.ico">

examples/custom-ipld-formats/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "skipped-example-custom-ipld-formats",
2+
"name": "example-custom-ipld-formats",
33
"version": "1.0.0",
44
"private": true,
55
"license": "MIT",

examples/run-in-electron/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>IPFS Electron</title>
88

9+
<script
10+
src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"
11+
defer
12+
></script>
913
<script src="./renderer.js" defer></script>
1014
</head>
1115
<body>
1216
<h1>IPFS in electron!</h1>
1317
<h2>now check your console</h2>
18+
19+
<h3>IPFS: <span id="node" style="display: none;"></span></h3>
1420
</body>
1521
</html>

examples/run-in-electron/main.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

33
const { app, BrowserWindow } = require('electron')
4-
const IPFS = require('ipfs')
54

65
let mainWindow
76

@@ -28,14 +27,6 @@ function createWindow () {
2827

2928
app.on('ready', async () => {
3029
createWindow()
31-
32-
try {
33-
const node = await IPFS.create()
34-
const id = await node.id()
35-
console.log(id)
36-
} catch (err) {
37-
console.error(err)
38-
}
3930
})
4031

4132
// Quit when all windows are closed.

examples/run-in-electron/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
"clean": "echo 'Nothing to clean...'",
1616
"start": "electron .",
1717
"serve": "npm run start",
18-
"test:example": "node tests/test.js"
18+
"test:example": "node test.js"
1919
},
2020
"dependencies": {
2121
"ipfs": "^0.58.0"
2222
},
2323
"devDependencies": {
2424
"electron": "^13.1.9",
2525
"electron-rebuild": "^3.1.1",
26-
"ipfs": "^0.58.0",
27-
"test-util-ipfs-example": "^1.0.2"
26+
"playwright": "^1.12.3"
2827
},
2928
"greenkeeper": {
3029
"ignore": [

examples/run-in-electron/renderer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
// This file is required by the index.html file and will
22
// be executed in the renderer process for that window.
33
// All of the Node.js APIs are available in this process.
4+
5+
6+
(async () => {
7+
try {
8+
const node = await Ipfs.create();
9+
const id = await node.id();
10+
11+
const nodeDOM = document.getElementById("node");
12+
nodeDOM.innerHTML = id.id;
13+
nodeDOM.style = "";
14+
} catch (err) {
15+
console.error(err);
16+
}
17+
})();

examples/run-in-electron/test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { _electron: electron } = require("playwright");
2+
3+
(async () => {
4+
// Launch Electron app.
5+
const electronApp = await electron.launch({ args: ["main.js"] });
6+
7+
// Get the first window that the app opens, wait if necessary.
8+
const window = await electronApp.firstWindow();
9+
10+
await window.waitForTimeout(5000);
11+
12+
const content = await window.textContent("#node");
13+
14+
if (content.trim() === "") {
15+
throw new Error("It should have been created an IPFS node");
16+
}
17+
18+
// Exit app.
19+
await electronApp.close();
20+
})();

examples/run-in-electron/tests/test.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)