Skip to content

Conversation

onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Aug 20, 2024

Adds utilities for E2E testing wizard CLI

Non-testing updates

  • This PR adds new CLI arguments to provide pre-selected project data. This is required to run tests with dummy Auth Tokens / DSNs without opening browser / signing in. Looking at the comments, I got the impression that, this feature was already planned. Please let me know if that's not the case, and I'll try to figure out another way.

Testing utilities

The flow of the initial e2e test structure is:

  • Create a new git repo in the local test application
  • Run the wizard on it with pre-provided auth token / dsn.
    • Optionally check for the stdout for expected prompts / messages, provide conditional stdin
  • Check for the file contents / file existences in the application after the wizard is finished.
  • Check if the project builds successfully
  • Check if the project runs on production mode successfully
  • Check if the project runs in development mode successfully

In the future, we can also add new utilities to check if the events/transaction from the created example page are sent successfully to Sentry

@onurtemizkan onurtemizkan force-pushed the onur/e2e-tests branch 10 times, most recently from 83d2cc5 to f2bf4f4 Compare August 22, 2024 08:13
@onurtemizkan onurtemizkan force-pushed the onur/e2e-tests branch 3 times, most recently from 8ad89ee to 074ec99 Compare August 27, 2024 21:13
@onurtemizkan onurtemizkan requested review from Lms24 and lforst August 28, 2024 10:55
@onurtemizkan onurtemizkan marked this pull request as ready for review August 28, 2024 10:55
@lforst lforst self-assigned this Aug 29, 2024
package.json Outdated
"xcode": "3.0.1",
"xml-js": "^1.6.11",
"yargs": "^16.2.0"
"yargs": "^17.7.2"
Copy link

Choose a reason for hiding this comment

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

Yargs 17 dropped support for Node 14 in yargs/yargs#2384 which is why we didn't bump it earlier. I'd say though that bumping it is probably fine, I would just do it in a separate PR and cut a major release for the wizard (no big deal imo). Does that make sense?

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 had to update it when I was experimenting but it seems we can stay at the current version with what I ended up. So just reverted the version update 👍

Copy link

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Just a first quick pass. Generally love it. I think we should address the two comments I left above and then we can iterate more (although I don't think there is much more necessary).

* @param integration
* @param projectDir
*/
export async function runWizard(integration: Integration, projectDir: string) {
Copy link

Choose a reason for hiding this comment

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

What if, instead of having all of this functionality in this function, we call this function something like startWizardInstance and it returns the wizardTestEnv so you can call stuff on it inside the jest tests? That way, we're a little more dynamic in what we can test and the various permutations we can test for more complicated wizards.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated and moved to Jest runner 👍

Comment on lines +39 to +49
preSelectedProject?: {
authToken: string;
selfHosted: boolean;
dsn: string;
projectId: string;
projectSlug: string;
projectName: string;
orgId: string;
orgName: string;
orgSlug: string;
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: This overlaps with #671. So if preSelectedProject is provided, the newly added --orgSlug and --projectSlug will not have any effect on the wizard behaviour.

wizardInstance.sendStdin(KEYS.ENTER);
}

const examplePagePrompted = await wizardInstance.waitForOutput(
Copy link

Choose a reason for hiding this comment

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

I don't fully understand why we need the optional configuration... Would you mind explaining it to me? I feel like I'm missing something. 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's primarily for local development where the test flows can be fragile, for example when the package manager is detected somehow and it's not prompted, or the leftovers from the example page exist and it's not prompted.

I think we can improve the utils in follow-up PRs to make them more debuggable, but this makes writing / debugging tests slightly easier in the meantime.

Copy link

Choose a reason for hiding this comment

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

Seems good! 👍

Copy link

@lforst lforst left a comment

Choose a reason for hiding this comment

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

The tests run suspicously fast 😂 but otherwise lgtm. Would you mind going over the changes I made one more time and make sure that I didn't do anything dumb? Then we can ship this! Sorry for the insane delay - totally on me.

@onurtemizkan
Copy link
Collaborator Author

@lforst, the updates look good to me, I just increased the timeout after yarn install. That was timing out for me locally. Thanks for the review!

@lforst lforst merged commit 6b580f5 into master Oct 3, 2024
14 checks passed
@lforst lforst deleted the onur/e2e-tests branch October 3, 2024 13:23
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.

2 participants