-
Notifications
You must be signed in to change notification settings - Fork 10.3k
test(create-gatsby): snapshot plugins-options-form and tiny refactoring #28366
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
packages/create-gatsby/src/__tests__/plugin-options-form.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| import { makePluginConfigQuestions } from "../plugin-options-form" | ||
| import pluginSchemas from "../plugin-schemas.json" | ||
|
|
||
| describe(`plugin-options-form`, () => { | ||
| it(`returns an empty array when nothing is passed`, () => { | ||
| const plugins = [] | ||
| expect(makePluginConfigQuestions(plugins)).toEqual([]) | ||
| }) | ||
|
|
||
| it(`returns an empty array when the plugin is not available for config`, () => { | ||
| const plugins = [`not-valid-plugin`] | ||
| expect(makePluginConfigQuestions(plugins)).toEqual([]) | ||
| }) | ||
|
|
||
| it(`returns an array containing only the wordpress options (choices are included)`, () => { | ||
| const plugins = [`gatsby-source-wordpress-experimental`] | ||
| expect(makePluginConfigQuestions(plugins)).toEqual([ | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-wordpress-experimental`, | ||
| multiple: true, | ||
| message: `Configure the WordPress plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-wordpress-experimental/\u001b[39m for help.`, | ||
| choices: [ | ||
| { | ||
| name: `url`, | ||
| message: `url`, | ||
| hint: `This should be the full url of your GraphQL endpoint set up by WP GraphQL`, | ||
| }, | ||
| ], | ||
| }, | ||
| ]) | ||
| }) | ||
|
|
||
| it(`returns an array with all the plugins schemas`, () => { | ||
| expect(makePluginConfigQuestions(Object.keys(pluginSchemas))).toEqual([ | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-wordpress-experimental`, | ||
| multiple: true, | ||
| message: `Configure the WordPress plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-wordpress-experimental/\u001b[39m for help.`, | ||
| choices: [ | ||
| { | ||
| name: `url`, | ||
| message: `url`, | ||
| hint: `This should be the full url of your GraphQL endpoint set up by WP GraphQL`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-contentful`, | ||
| multiple: true, | ||
| message: `Configure the Contentful plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-contentful/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, | ||
| choices: [ | ||
| { | ||
| name: `accessToken`, | ||
| message: `accessToken`, | ||
| hint: `Contentful delivery api key, when using the Preview API use your Preview API key`, | ||
| }, | ||
| { name: `spaceId`, message: `spaceId`, hint: `Contentful spaceId` }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-sanity`, | ||
| multiple: true, | ||
| message: `Configure the Sanity plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-sanity/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, | ||
| choices: [ | ||
| { | ||
| name: `projectId`, | ||
| message: `projectId`, | ||
| hint: `Your Sanity project's ID`, | ||
| }, | ||
| { | ||
| name: `dataset`, | ||
| message: `dataset`, | ||
| hint: `The dataset to fetch from`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-shopify`, | ||
| multiple: true, | ||
| message: `Configure the Shopify plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-shopify/\u001b[39m for help.\n\u001b[32mUse arrow keys to move between fields, and enter to finish\u001b[39m`, | ||
| choices: [ | ||
| { | ||
| name: `shopName`, | ||
| message: `shopName`, | ||
| hint: `The domain name of your Shopify shop`, | ||
| }, | ||
| { | ||
| name: `accessToken`, | ||
| message: `accessToken`, | ||
| hint: `An API access token to your Shopify shop`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-datocms`, | ||
| multiple: true, | ||
| message: `Configure the DatoCMS plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-datocms/\u001b[39m for help.`, | ||
| choices: [ | ||
| { | ||
| name: `apiToken`, | ||
| message: `apiToken`, | ||
| hint: `Your read-only API token under the Settings > API tokens section of your administrative area in DatoCMS`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-source-agility`, | ||
| multiple: true, | ||
| message: `Configure the gatsby-source-agility plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-source-agility/\u001b[39m for help.`, | ||
| choices: [ | ||
| { | ||
| name: `guid`, | ||
| message: `guid`, | ||
| hint: `your Agility Content Fetch API Guid`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: `forminput`, | ||
| name: `gatsby-plugin-google-analytics`, | ||
| multiple: true, | ||
| message: `Configure the gatsby-plugin-google-analytics plugin.\nSee \u001b[94mhttps://www.gatsbyjs.com/plugins/gatsby-plugin-google-analytics/\u001b[39m for help.`, | ||
| choices: [ | ||
| { | ||
| name: `trackingId`, | ||
| message: `trackingId`, | ||
| hint: `The property ID; the tracking code won't be generated without it`, | ||
| }, | ||
| ], | ||
| }, | ||
| ]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise this was how it was before, but I do wonder if there's a better way to do this, using the schema rather than checking the type of the default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a side note on that: right now, IIRC, none of the elements that are required have a default value 🤔 . This is a computation that lives there "for nothing" for now I would say :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Most of them aren't likely to either, because if there's a default it won't need to be required