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

feat: add e2e tests for codegen add when in a non-amplify project #705

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

alharris-at
Copy link
Contributor

@alharris-at alharris-at commented Sep 18, 2023

Description of changes

Added e2e test cases for codegen add in an uninitialized project. These don't yet include test cases where we download an existing api sdl schema.

Issue #, if available

N/A

Description of how you validated changes

E2E Tests pass

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@alharris-at alharris-at requested a review from a team as a code owner September 18, 2023 22:23
expect(existsSync(userSourceCodePath)).toBe(true);
// GraphQL statements are generated
const generatedStatementFiles = new Set(readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
console.log(`Comparing written files: ${JSON.stringify(Array.from(generatedStatementFiles))} to expected files: ${JSON.stringify(expectedFilenames)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to log both arrays here as they are compared on the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this'll make debugging easier because the comparison line below fails w/ no indication of what the mismatch was,.


// GraphQL statements are regenerated
const regeneratedStatementFiles = new Set(readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
console.log(`Comparing written files: ${JSON.stringify(Array.from(regeneratedStatementFiles))} to expected files: ${JSON.stringify(expectedFilenames)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ same


// GraphQL statements are regenerated
const regeneratedStatementFiles = new Set(readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
console.log(`Comparing written files: ${JSON.stringify(Array.from(regeneratedStatementFiles))} to expected files: ${JSON.stringify(expectedFilenames)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

+2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:D

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've pulled this into a utility method to reduce the duplication in this function.

@alharris-at alharris-at force-pushed the noinit-codegen-e2e-tests branch from 1e421b6 to 60c1225 Compare September 19, 2023 02:40
@alharris-at alharris-at merged commit ff4e221 into noinit-codegen Sep 19, 2023
3 checks passed
@alharris-at alharris-at deleted the noinit-codegen-e2e-tests branch September 19, 2023 15:38
alharris-at added a commit that referenced this pull request Sep 19, 2023
…set up locally. (#702)

* feat: codegen add --region (#683)

* fix: download introspection schema when apiId is passed (#684)

* fix: codegen --apiId broken state (#689)

* chore: get existing e2e tests passing (#704)

* feat: add e2e tests for codegen add when in a non-amplify project (#705)

* feat: add e2e tests for codegen add when in a non-amplify project

* chore: add some additional test cases

* noinit codegen from graphqlconfig (#706)

* fix: add missing awaits

* chore: fail typegen if no queries are found

---------

Co-authored-by: Dane Pilcher <[email protected]>
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