Skip to content

Conversation

@nabdelgadir
Copy link
Contributor

Related to #5004.

Proposal for running acceptance and integration tests. Details can be found in SPIKE.md.

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@nabdelgadir nabdelgadir self-assigned this Apr 26, 2020
@bajtos
Copy link
Member

bajtos commented Apr 27, 2020

Thank you @nabdelgadir for looking into ways how to run tests of a LB3 app from inside LB4! I'll try to review the proposal tomorrow 🤞

@nabdelgadir nabdelgadir force-pushed the spike/lb3test branch 2 times, most recently from cd2fec6 to ff8902f Compare April 27, 2020 18:03
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

I like the proposed design 👍

Let's polish the details now and make sure the migration requires as little changes in the original test code as possible. A typical application can have dozens of test files with hundreds of tests, every additional step would create a lot of work for our users.

user,
) {
user.email.should.be.equal('new@email.com');
json('post', '/api/users/login')
Copy link
Member

Choose a reason for hiding this comment

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

Please find a way how to allow this test to call User.login directly via JavaScript API, so that users don't have to rework all their tests calling model API from JavaScript to make HTTP requests instead.

Copy link
Member

Choose a reason for hiding this comment

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

Is this perhaps trying to workaround the problem that User has unknown type? (See the discussion below.)

Copy link
Contributor

@jannyHou jannyHou Apr 29, 2020

Choose a reason for hiding this comment

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

IIUC...I think Nora tests the endpoint instead of the API here because it's acceptance test :p The APIs are tested in the integration test file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize now this file is a bit confusing because I was trying to mimic the original acceptance tests which makes this now acceptance + integration but I think I'll put the auth tests in their own file.

Copy link
Member

Choose a reason for hiding this comment

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

Here is my point of view: this acceptance test has two parts. In the first part, we want to setup data (e.g. User instance, a valid AccessToken, etc.). In the second part, we test the actual scenario.

I am arguing that for test setup, we should use the most performant solution. This part is not testing anything, it's just preparing data to enable the scenario being tested. That's why I prefer to call model methods directly via JS API. HTTP calls introduce non-negligible slow down.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am arguing that for test setup, we should use the most performant solution. This part is not testing anything, it's just preparing data to enable the scenario being tested. That's why I prefer to call model methods directly via JS API. HTTP calls introduce non-negligible slow down.

Oh I see, thanks for explanation 👍

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

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

👏 Very useful guide and good job of the spike! Mostly LGTM, a few suggestions.

"eslint:fix": "npm run eslint -- --fix",
"pretest": "npm run build",
"test": "lb-mocha \"dist/__tests__/**/*.js\"",
"test": "lb-mocha \"dist/__tests__/**/*.js\" \"lb3app/test/*.js\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


let app;

function json(verb, url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: the function name is a bit confusing, maybe call it as setContentType?
And why the test has to set the content type and Accept as application/json then send the payload? Is it also part of the migration guide?
(hmm, "migration" may not be the accurate word haha)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this was traditional lb3 naming because it's what I've seen in lb3 examples (like here and here) 🙈

And why the test has to set the content type and Accept as application/json then send the payload? Is it also part of the migration guide?

Since we want users to change as little code as possible, I maintained the function as is, but I agree we can rename the function name 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to request to match what the function does; what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I didn't realize it's from LB3...then I am ok to keep the name as it is. Since it's migration.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

The new version looks pretty good! I have few minor comments to consider, see below.

I don't want to block progress, feel free to land the changes after getting approval from @jannyHou, no need to wait for me.

@nabdelgadir nabdelgadir force-pushed the spike/lb3test branch 2 times, most recently from 0eb9c17 to 59621e7 Compare April 30, 2020 19:17
Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@nabdelgadir
Copy link
Contributor Author

Created followup stories:

These two should be completed after the first one:

Closing the spike as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants