-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-source-drupal): Add tests for meta.count support & fix bug…
… with i18n (#33423) (#33440) * feat(gatsby-source-drupal): port hot-fixes for Drupal/Gatsby customer to package * Add tests for meta.count URL creation The main guerentee that this is working is that only the first articles json file has a next href so the only way all articles are fetched is if we create the URLs upfront. * Add tests for meta.count for i18n (and fix bug for it) * Make paths windows-happy Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> (cherry picked from commit 22805bd) Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
- Loading branch information
1 parent
d0a152f
commit aae86b5
Showing
12 changed files
with
430 additions
and
11 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/gatsby-source-drupal/src/__tests__/fixtures/article-meta.count-i18n.json
This file contains 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,40 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-1", | ||
"attributes": { | ||
"id": 21, | ||
"uuid": "article-1", | ||
"title": "Article #1", | ||
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis.", | ||
"langcode": "i18n-test" | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": null | ||
}, | ||
"field_tags": { | ||
"data": [ | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-1" | ||
}, | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"links": { | ||
"next": { | ||
"href": "http://fixture/jsonapi-meta.count-i18n/node/articlemeta.count-i18n?page[limit]=3&page[offset]=1" | ||
} | ||
}, | ||
"meta": { | ||
"count": 4 | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/gatsby-source-drupal/src/__tests__/fixtures/article-meta.count.json
This file contains 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,39 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-1", | ||
"attributes": { | ||
"id": 21, | ||
"uuid": "article-1", | ||
"title": "Article #1", | ||
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": null | ||
}, | ||
"field_tags": { | ||
"data": [ | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-1" | ||
}, | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"links": { | ||
"next": { | ||
"href": "http://fixture/jsonapi/node/articlemeta.count?page[limit]=3&page[offset]=1" | ||
} | ||
}, | ||
"meta": { | ||
"count": 7 | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/__tests__/fixtures/articlemeta.count-i18n___page%5Blimit%5D=3&page%5Boffset%5D=3.json
This file contains 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,32 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-2", | ||
"attributes": { | ||
"id": 22, | ||
"uuid": "article-2", | ||
"title": "Article #2", | ||
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": null | ||
}, | ||
"field_tags": { | ||
"data": [ | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-1" | ||
}, | ||
{ | ||
"type": "taxon,omy_term--tags", | ||
"id": "tag-2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
52 changes: 52 additions & 0 deletions
52
...upal/src/__tests__/fixtures/articlemeta.count___page%5Blimit%5D=1&page%5Boffset%5D=2.json
This file contains 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,52 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-3", | ||
"attributes": { | ||
"id": 23, | ||
"uuid": "article-3", | ||
"title": "Article #3", | ||
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-1" | ||
} | ||
}, | ||
"field_secondary_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_secondary_multiple_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-3" | ||
}, | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_tertiary_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
}, | ||
"field_tags": { | ||
"data": null | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
52 changes: 52 additions & 0 deletions
52
...upal/src/__tests__/fixtures/articlemeta.count___page%5Blimit%5D=3&page%5Boffset%5D=3.json
This file contains 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,52 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-2", | ||
"attributes": { | ||
"id": 22, | ||
"uuid": "article-2", | ||
"title": "Article #2", | ||
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-1" | ||
} | ||
}, | ||
"field_secondary_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_secondary_multiple_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-3" | ||
}, | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_tertiary_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
}, | ||
"field_tags": { | ||
"data": null | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
60 changes: 60 additions & 0 deletions
60
...upal/src/__tests__/fixtures/articlemeta.count___page%5Blimit%5D=3&page%5Boffset%5D=6.json
This file contains 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,60 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-4", | ||
"attributes": { | ||
"id": 24, | ||
"uuid": "article-4", | ||
"title": "Article #4", | ||
"body": "Proin pulvinar hendrerit magna nec maximus. Donec rhoncus libero ac nisi porttitor pulvinar. Quisque semper ultricies nulla sit amet vestibulum. Ut vel libero erat. Ut ultrices eleifend scelerisque. Nam non massa sit amet magna molestie tempus vel non neque. Praesent ac est congue, euismod mi ut, tristique mi. Etiam dapibus feugiat lectus, vel condimentum nisl maximus et. Praesent et placerat magna. Sed nec risus non ipsum venenatis placerat. Vestibulum vitae felis eget nunc mattis congue. Morbi volutpat odio purus. Donec placerat massa sed neque molestie, sed finibus nibh scelerisque. In faucibus ante tortor, in efficitur lectus feugiat vitae. Aliquam sodales mollis consectetur." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-1" | ||
} | ||
}, | ||
"field_secondary_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_secondary_multiple_image": { | ||
"data": [ | ||
{ | ||
"type": "file--file", | ||
"id": "file-3" | ||
}, | ||
{ | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
] | ||
}, | ||
"field_tertiary_image": { | ||
"data": { | ||
"type": "file--file", | ||
"id": "file-4" | ||
} | ||
}, | ||
"field_tags": { | ||
"data": null | ||
} | ||
} | ||
} | ||
], | ||
"links": { | ||
"next": { | ||
"href": "http://fixture/jsonapi/node/articlemeta.count?page[limit]=1&page[offset]=1" | ||
} | ||
}, | ||
"meta": { | ||
"count": 3 | ||
} | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
packages/gatsby-source-drupal/src/__tests__/fixtures/i18n-test-article-meta.count-i18n.json
This file contains 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,41 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-1-i18n", | ||
"attributes": { | ||
"id": 31, | ||
"uuid": "article-1-i18n", | ||
"title": "Article #1 i18n", | ||
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis.", | ||
"langcode": "i18n-test" | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": null | ||
}, | ||
"field_tags": { | ||
"data": [ | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-1" | ||
}, | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"links": { | ||
"next": { | ||
"href": "http://fixture/jsonapi-meta.count-i18n/node/i18n-test-articlemeta.count-i18n?page[limit]=3&page[offset]=1" | ||
} | ||
}, | ||
"meta": { | ||
"count": 4 | ||
} | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
...es/i18n-test-i18n-test-articlemeta.count-i18n___page%5Blimit%5D=3&page%5Boffset%5D=3.json
This file contains 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,32 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "node--article", | ||
"id": "article-2-18n", | ||
"attributes": { | ||
"id": 32, | ||
"uuid": "article-2-i18n", | ||
"title": "Article #2 i18n", | ||
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan nisl nulla, a commodo neque luctus viverra. Praesent sed elit nisl. In sagittis, velit lacinia varius cursus, lectus urna aliquet tortor, in convallis lacus justo ut enim. Nullam tempus diam non mattis pulvinar. Fusce viverra vitae ex eget efficitur. Nunc sed ligula magna. Fusce ligula diam, lobortis et neque vel, finibus laoreet augue. Duis tristique lacinia odio, tincidunt lacinia nunc cursus a. Vivamus nec mauris sed lectus commodo bibendum vel a felis." | ||
}, | ||
"relationships": { | ||
"field_main_image": { | ||
"data": null | ||
}, | ||
"field_tags": { | ||
"data": [ | ||
{ | ||
"type": "taxonomy_term--tags", | ||
"id": "tag-1" | ||
}, | ||
{ | ||
"type": "taxon,omy_term--tags", | ||
"id": "tag-2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
packages/gatsby-source-drupal/src/__tests__/fixtures/jsonapi-meta.count-i18n.json
This file contains 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,14 @@ | ||
{ | ||
"data": [], | ||
"links": { | ||
"self": "http://fixture/jsonapi", | ||
"node--article": { | ||
"href": "http://fixture/jsonapi-meta.count-i18n/node/article-meta.count-i18n" | ||
}, | ||
"describedby": { | ||
"href":"http://fixture/jsonapi/schema" | ||
} | ||
} | ||
} | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
packages/gatsby-source-drupal/src/__tests__/fixtures/jsonapi-meta.count.json
This file contains 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,11 @@ | ||
{ | ||
"data": [], | ||
"links": { | ||
"self": "http://fixture/jsonapi", | ||
"node--article": "http://fixture/jsonapi/node/article-meta.count", | ||
"describedby": { | ||
"href":"http://fixture/jsonapi/schema" | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.