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

Add e2e smoke test #156

Merged
merged 13 commits into from
May 4, 2018
Merged

Add e2e smoke test #156

merged 13 commits into from
May 4, 2018

Conversation

olizilla
Copy link
Collaborator

@olizilla olizilla commented May 3, 2018

To try and reduce the chance of another #150 event, this PR adds an end to end smoke test that'll

  • Load peerpad in a browser and create a new pad and initialise ipfs without error.
  • Load peerpad in 2 browsers and sync a pad between them.

Uses puppeteer for the headless chrome magic.

It runs in travis, so this should prevent totally broken things getting merged. I don't plan to add lot's more full integration tests like this; this is the test of last resort. The next step is to clean up the code base and add a bunch of unit tests.

@olizilla olizilla changed the title WIP add e2e smoke test Add e2e smoke test May 3, 2018
@olizilla olizilla requested review from pgte, alanshaw and victorb May 3, 2018 16:36
Copy link
Collaborator

@pgte pgte left a comment

Choose a reason for hiding this comment

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

Looking great!

@pgte
Copy link
Collaborator

pgte commented May 3, 2018

@olizilla do you think there's anything we can do to circle.ci? Otherwise, should we just remove it?

@olizilla
Copy link
Collaborator Author

olizilla commented May 3, 2018

@pgte I don't think we need both, I'd like to remove circle for now, and just use travis until jenkins is ready for all the responsibilities.

README.md Outdated
@@ -6,7 +6,7 @@
<a href="https://protocol.io"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
<a href="http://peerpad.net/"><img src="https://img.shields.io/badge/project-PeerPad-blue.svg?style=flat-square" /></a>
<a href="http://webchat.freenode.net/?channels=%23ipfs"><img src="https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square" /></a>
<a href="https://travis-ci.org/ipfs-shipyard/peerpad"><img src="https://img.shields.io/travis/ipfs-shipyard/peerpad/master.svg?style=flat-square" /></a>
[![Build Status](https://travis-ci.org/ipfs-shipyard/peer-pad.svg?branch=master)](https://travis-ci.org/ipfs-shipyard/peer-pad)
Copy link
Contributor

Choose a reason for hiding this comment

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

Markdown syntax won't render within HTML

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maaan. It renders in atom's markdown preview!


```bash
URL=https://peerpad.net npm run test:e2e
```
Copy link
Contributor

Choose a reason for hiding this comment

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

## Deploy

You can self-host your own Peerpad. For that, deploy the `build` directory (after you have run the `npm run build` command).
You can self-host your own Peerpad. For that, run `npm run build` and deploy the `build` directory to a web-server
Copy link
Contributor

Choose a reason for hiding this comment

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

...or run test:serve

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not gonna recommend people use http-server in prod, even if it does think it's production ready.

}

async function findPeerId (page) {
// wait up to 1 minute for ifps to boot
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "ifps"

expect(bobPeerId).not.toEqual(alfPeerId)
console.log('alf peerId', alfPeerId)
console.log('bob peerId', bobPeerId)
// wait for ifps to sync...
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "ifps"

browsers.forEach(b => b.close())
})

it('Create a pad', async (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to async and done. If using async and something fails, just throw.

https://facebook.github.io/jest/docs/en/asynchronous.html#async-await

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot. I was getting unhandedRejectedPromise warnings rather than test failures, which is why these tests are a weird mixture of async await and done callbacks. I need to dig into that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've tried to recreate the madness and didn't get the same issue so have fixed up the tests to be more sane as per your suggests. much nice.

done.fail(err)
}
done()
}, waitFor)
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid having to use done in this test due to callbacks you could:

await pause(waitFor)
const bobTitle = await getDocumentTitle(bob)
expect(bobTitle).toEqual(alfTitle)

function pause (ms) {
  return new Promise(resolve => setTimeout(resolve, ms))
}

await page.goto(appUrl)
await page.waitForSelector('[data-id=start-button]')
await page.click('[data-id=start-button]')
// wait up to 1 minute for ifps to boot
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "ifps"

@olizilla olizilla merged commit a12f8d7 into master May 4, 2018
@olizilla olizilla deleted the feat/integration-test branch May 4, 2018 13:22
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.

3 participants