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 CLI test for blitz new #37

Open
flybayer opened this issue Jan 21, 2021 · 16 comments
Open

Add e2e CLI test for blitz new #37

flybayer opened this issue Jan 21, 2021 · 16 comments

Comments

@flybayer
Copy link
Member

What do you want and why?

We currently have a few blitz new tests, but not a complete e2e test for the new app.

We want to:

  1. Test the following for each form option
  2. Test blitz build success inside new app
  3. Test yarn test success inside new app
    1. Need to remove the .skip from app/pages/index.test.tsx to ensure that test passes
  4. Test yarn lint has no errors or warnings
  5. Start app (use blitz start --production since we already ran blitz build above)
    6. Test user sign up
    7. Test user log out
    8. Test user duplicate email signup (correct message displayed)
    8. Test user log in

Possible implementation(s)

Add Cypress to our CLI testing setup. See the Redwood CLI cypress test for a great example/starting point.

Other

You don't have to add all the above tests in one PR. You can just add as much as you have time/energy for. First person needs to add cypress and very basic initial test.

@wafuwafu13
Copy link
Contributor

@flybayer
Hi :)
I try this now at blitz-js/blitz#1846 .
Could you check it?

@markhughes
Copy link
Contributor

@flybayer was this issue resolved in blitz-js/blitz#1846?

@flybayer
Copy link
Member Author

@markhughes no, that PR just added an empty cypress set up (no tests)

@wafuwafu13
Copy link
Contributor

wafuwafu13 commented Feb 18, 2021

I want to test blitz new, so I study cypress and read redwood test (and commit redwoodjs/redwood#1780).
But it is too difficult for me to test blitz new:(

@flybayer
Copy link
Member Author

Ah, responding to prompts is a good question. Probably we should add flags like --final-form, --hook-form, etc. That will help with testing and is a good idea anyways.

@flybayer
Copy link
Member Author

I think we shouldn't have to copy the template. Running blitz new within our repo will automatically use the correct template

@wafuwafu13
Copy link
Contributor

wafuwafu13 commented Feb 20, 2021

Probably we should add flags like --final-form, --hook-form, etc. That will help with testing and is a good idea anyways.

I agree with it.
I think it is bettter to do it before blitz new test if can't find a good way to mock formChoices.

@markhughes
Copy link
Contributor

@wafuwafu13 If you get stuck with this one, i'm happy to help you out!

@wafuwafu13
Copy link
Contributor

Thank you :)
I can't find a good way to mock formChoices, so could you help me ?

@markhughes
Copy link
Contributor

@wafuwafu13 can you push up the branch in your fork so I can see your current progress and then I'll be able to make a suggestion :)

@wafuwafu13
Copy link
Contributor

Sorry, I'm very busy lately, so I don't have any current progress :-(

@flybayer
Copy link
Member Author

flybayer commented Mar 6, 2021

@markhughes go ahead and work on this if you want

@maybebored
Copy link
Contributor

Happy to take this and work on it, went through the earlier discussion and PR, seems there's a set up for cypress without any tests. I'd like to add some test cases if someone can point at what is to be tested.

@beerose
Copy link
Contributor

beerose commented Oct 4, 2021

Hey @maybebored, as Brandon mentioned in the issue, this is roughly what needs to be tested (you can only cover some of those, and that would be a huge help already!):

  1. Test the following for each form option
  2. Test blitz build success inside new app
  3. Test yarn test success inside new app
    1. Need to remove the .skip from app/pages/index.test.tsx to ensure that test passes
  4. Test yarn lint has no errors or warnings
  5. Start app (use blitz start --production since we already ran blitz build above)
    6. Test user sign up
    7. Test user log out
    8. Test user duplicate email signup (correct message displayed)
    8. Test user log in.

Here's the code of the blitz new command: https://github.com/blitz-js/blitz/blob/canary/packages/cli/src/commands/new.ts, and here you can find the Cypress setup: https://github.com/blitz-js/blitz/tree/canary/packages/cli/test/e2e/cypress.

@Redaloukil
Copy link

Hi @flybayer, I want to work on 2.Test blitz build success inside new app
I've been following the discussion and reading some of the links that you posted above, It's still unclear what are the steps to follow and how to reproduce those steps in cypress and test results. In my understanding, the testing flow for 2.Test blitz build success inside new app would be :

  1. Create a new app running blitz new app
  2. CD inside the newly created app.
  3. Run blitz build.
  4. Test build result.

I would like to get a help to know how to create a new app by the test. Can you provide more explanation please ?

@beerose
Copy link
Contributor

beerose commented Oct 15, 2021

Hey @Redaloukil, here are a few links that can be helpful:

  1. Cypress' exec command that you can use to run CLI commands https://docs.cypress.io/api/commands/exec#Usage. You can probably use this for 1. and 3. points. You'd also probably need to pass flags for forms, package manager etc, so that the command doesn't prompt to ask questions.
  2. An example of the testing flow including exec usage: https://github.com/redwoodjs/redwood/blob/c0980353d5726e37c55c4f01cc3bbfa4b5ef268e/tasks/e2e/cypress/integration/tutorial/tutorial.js.
  3. Our existing blitz new tests, which might be helpful to take a look at: https://github.com/blitz-js/blitz/blob/canary/packages/cli/test/commands/new.test.ts.

Let us know if you have any more questions!

@itsdillon itsdillon transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants