-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: electron 17 and playwright tests #1937
Conversation
if (process.env.NODE_ENV === 'test') { | ||
const path = require('path') | ||
|
||
app.setPath('home', process.env.HOME) | ||
app.setPath('userData', path.join(process.env.HOME, 'data')) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, this was somewhat on the include.js
file that we'd require using the flag -r
when booting Electron. However, for some reason, even though we used setPath('userData', ...)
there, the value wouldn't be reflected after the actual application started. Thus, I found this to be the best solution.
@@ -63,7 +64,7 @@ module.exports = async function (ctx) { | |||
} | |||
|
|||
log.end() | |||
updateStatus(STATUS.STARTING_FINISHED) | |||
updateStatus(STATUS.STARTING_FINISHED, id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not scraping the logs anymore, so we send the peer id on the event once the startup is finished.
@lidel the move is not as straightforward as I thought. Tests are failing on Ubuntu and partially failing on Windows. I will take a look on this Friday when I have more time. I left some code annotations on why I changed some things. |
Update: I will work on the Linux and Windows testing. I have to setup some VMs so it'll take a bit longer. Update 2: all tests pass locally on a Ubuntu installation. Hmm... Update 3: Windows working. It was just missing setting I think Linux is related to the test setup, as it works locally on an Ubuntu VM. |
5e6753f
to
9185743
Compare
@lidel could you please take a look into the Ubuntu tests? They all time out but I can't reproduce the problem. |
956c081
to
409ba68
Compare
Update: managed to reproduce on an Ubuntu server instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pushing here ❤️
Sadly, I've run out of time this week – will get back to this in Jan.
Just a note: the tests on macOS on the CI seem unstable, randomly failing because with the error |
bcba482
to
567b5eb
Compare
On #1961, for Electron 15.x version, we get a more specific error:
So it's definitely related to the xvfb thingy. |
3e86eba
to
d17b338
Compare
I tried different combinations of commands to run xvfb, but none of them seems to work correctly. Perhaps updating the Xvfb action would fix whatever issue is happening. When I try to update it, it says that this repository can only run very specific versions of actions. I don't have permissions to update that and check. |
f217053
to
d17b338
Compare
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This reverts commit b67a9f5.
this also solves the bug on Linux where electron.launch blocked for unknown reason – we were not passing process.env correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hacdias for doing the heavy lifting, and apologies for being slow on this one ❤️
Poked at the CI issue, and it turned out to be caused by the meaning of env
parameter passed to electron.launch
– details inline.
CI is green, I switched to Electron 17 and works as expected, merging! 🚀
@@ -100,7 +100,7 @@ jobs: | |||
run: npm run test | |||
|
|||
- name: Test end-to-end | |||
uses: GabrielBB/xvfb-action@f040be23a619e5ec34116f24098ad3626ceab681 # v1.4 | |||
uses: GabrielBB/xvfb-action@86d97bde4a65fe9b290c0b3fb92c2c4ed0e5302d # v1.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ This was not impacting build (i had the same timeout on the local Linux box), but I bumped version and safelisted this third-party action as part of investigation.
@@ -9,7 +9,7 @@ | |||
"start": "cross-env NODE_ENV=development electron .", | |||
"lint": "standard", | |||
"test": "cross-env NODE_ENV=test mocha test/unit/**/*.spec.js", | |||
"test:e2e": "xvfb-maybe cross-env NODE_ENV=test LIBP2P_ALLOW_WEAK_RSA_KEYS=1 mocha test/e2e/**/*.e2e.js --exit", | |||
"test:e2e": "xvfb-maybe cross-env NODE_ENV=test playwright test test/e2e/launch.e2e.test.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ switched to runner native to playright (just to avoid any bugs caused by legacy mocha stack)
"cross-env": "^7.0.3", | ||
"delay": "^5.0.0", | ||
"dirty-chai": "^2.0.1", | ||
"dotenv": "^14.2.0", | ||
"electron": "13.6.7", | ||
"electron": "^17.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env: Object.assign({}, process.env, { | ||
NODE_ENV: 'test', | ||
HOME: home, | ||
IPFS_PATH: repoPath | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ @hacdias this fixed the weird CI failure on Linux.
It was caused by the difference in how env
field works here.
In playwright, passed env fully replaces process.env
for greater control, so we were missing some variables created by X11/Xvfb. This restores them, solving e2 on Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Thanks for figuring it out :)
return { peerId } | ||
async function daemonReady (app) { | ||
const peerId = await app.evaluate(async ({ ipcMain }) => new Promise((resolve, reject) => { | ||
ipcMain.on('ipfsd', (status, peerId) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ really cool, switching to more sane way of reading ipfsd status makes tests run really fast now!
} | ||
|
||
it('creates a repository on startup', async function () { | ||
test('creates a repository on startup', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ this and below changes are just refactor from mocha
and chai
to modern @playwright/test
Closes #1902