Skip to content
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

Migrate clicktests from nightmare to puppeteer #1336

Merged
merged 16 commits into from May 6, 2020

Conversation

campersau
Copy link
Collaborator

@campersau campersau commented Apr 28, 2020

Nighmare hasn't been updated for a while now and the chrome version is getting pretty old missing some features like Promise.prototype.finally.

Tests run fine on my machine but in CI they seem a bit flaky and need a bit more work. Might be because I removed a lot of waits and puppeteer runs a lot faster and ungit sometimes can't keep up.

It currently does not work in node 14 but that's because of this node issue which should be released in a few hours.

Also using async / await!

.github/workflows/ci.yml Show resolved Hide resolved
@@ -27,6 +27,7 @@ addons:
apt:
packages:
- xvfb
- libgbm1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -69,7 +69,7 @@ module.exports = (grunt) => {
options: {
reporter: 'spec',
require: './source/utils/winston.js',
timeout: 15000,
timeout: 35000,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puppeteer default timeout is 30000ms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the default be enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also could change the timeout to 15000 which we used before, but opted for sticking with the puppeteer defaults, that's why I have increased it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is the mocha timeout.

I thought this is setting the puppeteer timeout to 35s instead of 30s and was wondering whether not setting it would be fine.

@@ -153,6 +153,7 @@ module.exports = (grunt) => {
},
mocha: {
options: {
esversion: 8,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async / await

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does JSHint have esversion: 6?
Does it not support anything higher?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that is what esnext was before https://jshint.com/docs/options/#esnext.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but can we set it to esversion: 8 for the test files (and node files)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we will but not as part of this PR.

@@ -10,7 +10,7 @@ <h4 class="stash-toggle-text" data-bind="click: toggleShowStash">
</h4>
<div class="list-group" data-bind="foreach: stashedChanges">
<div class="list-group-item">
<a href="#" class="stash-apply octicon-circled pull-left bootstrap-tooltip" data-bind="html: applyIcon, click: apply" data-toggle="tooltip" title="Apply this stash"></a>
Copy link
Collaborator Author

@campersau campersau Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clicktest did fail on macOS because this used floats and couldn't be clicked. It now works by using display: inline-block which is nicer.

width: this.config.viewWidth,
height: this.config.viewHeight
},
headless: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to false to see the browser!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it makes sense to make that configurable for local runs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would be nice, I use to set a GUI=1 env variable for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could make them configurable via environment variables and document them because otherwise they are as hidden as this boolean.

I usually don't use environment variables to configure stuff like this, is GUI=1 unique enough? Would it clash with some other programs? What about GUI=true?

nmclicktests/environment.js Outdated Show resolved Hide resolved
.wait(200)
.type('input.name', '-4\u0028\u000d')
.wait('[data-ta-name="search-4"]')
it('search for the hidden branch', async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled this test!

fs.writeFile(req.body.file, content, () => res.json({}));
fs.writeFileAsync(req.body.file, content)
.then(() => res.json({}))
.then(emitWorkingTreeChanged.bind(null, req.body.path));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the tests more reliable trigger working tree changes manually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't particularly like the bind. Would this work too?

Suggested change
.then(emitWorkingTreeChanged.bind(null, req.body.path));
.then(() => emitWorkingTreeChanged(req.body.path));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would but I just want to keep the existing codestyle for now.
In the future we will replace all of this with async await anyway.

});
app.post(`${exports.pathPrefix}/testing/git`, ensureAuthenticated, (req, res) => {
jsonResultOrFailProm(res, gitPromise(req.body.command, req.body.repo));
jsonResultOrFailProm(res, gitPromise(req.body.command, req.body.path));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only case where the repro path variable name was repo. I just changed it to path to be consistent with the rest.

background: #55323C;
h4 {
margin-top: 0px;
}
margin-bottom: -15px;

.toggle-show-commit-diffs {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this related to some test failing now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the stash tests did fail before on macOS which is fixed by this.
The current test failures (mainly on macOS) are different, but I don't have a mac available so they are pretty hard to debug for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to note that macOS tests sometimes succeed but yes, they are currently the most flaky.
https://github.com/campersau/ungit/runs/639350614

Gruntfile.js Outdated Show resolved Hide resolved
@campersau campersau force-pushed the puppeteer branch 2 times, most recently from 252406c to 2fcb40d Compare May 5, 2020 16:30
@campersau campersau mentioned this pull request May 5, 2020
@campersau
Copy link
Collaborator Author

First green build after a long time!
macOS is still a bit flaky though don't expect that it will always be green.

@campersau campersau merged commit f866756 into FredrikNoren:master May 6, 2020
@campersau campersau deleted the puppeteer branch May 6, 2020 20:24
@campersau campersau mentioned this pull request May 6, 2020
@campersau campersau mentioned this pull request Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants