To have a stable release for the module, we require to have automated tests.
See Comment #2909022-9: Write tests.
As entity share requires to have two different Drupal sites to work, for the automated tests there is two solutions, either:
- mock what is needed for the different features of entity share to be able to emulate another websites requests or responses,
- be able to have a CI environment that provides two Drupal sites.
For running automated tests locally it would be easier to mock requests and responses.
Also if DrupalCI prevents having two websites running, avoiding to mirror the project on another platform to have travis or gitlab CI will be better because such setup would prevent being able to run tests locally and automatically in Drupal issue queue.
The mock approach is preferred before further investigation on the two websites setup.
Features:
1: generation of endpoint /entity_share, check if:
- the channels URLs are valid: DONE
- filters: #3082518: Tests: filter, group and sort on channel
- groups of filters: #3082518: Tests: filter, group and sort on channel
- sorts: #3082518: Tests: filter, group and sort on channel
- multilingual: DONE
- UI:
- Creating channel
- Creating filter
- Creating sort
- Creating groups and filters
As this feature requires only entity_share_server, there is no need of a second website. So not concerned by the difficulty to setup test environment.
2: pull content entities:
- field types:
- Boolean #3072220: Tests: boolean field
- Content (entity reference) #3072236: Tests: content field (entity reference)
- Comment: currently not supported
- Date: #3072233: Tests: date field
- date and time
- date only
- Date range: #3072256: Tests: daterange field
- date and time
- date only
- Dynamic entity reference: currently not supported
- Email #3072234: Tests: email field
- File #3072238: Tests: file field (entity reference)
- Image #3072240: Tests: image field (entity reference)
- Link: #3072242: Tests: link field
- internal (with JSON:API Extras field enhancers at this moment)
- external
- List: #3072244: Tests: list fields
- float
- integer
- text
- Media: #3072245: Tests: media field (entity reference)
- audio
- image
- file
- remote video
- video
- Metatags #3060702: Compatibility with Metatag Fields
- Number: #3072249: Tests: number field
- decimal
- float
- integer
- Paragraphs #3072251: Tests: paragraph field
- Taxonomy #3072252: Tests: taxonomy field (entity reference)
- Telephone #3072253: Tests: telephone field
- Text: #3072255: Tests: text fields
- plain
- plain, long
- formatted
- formatted, long
- formatted, long, with summary
- Timestamp #3072254: Tests: timestamp field
- files #3072238: Tests: file field (entity reference):
- public stream wrapper
- private stream wrapper
- s3fs stream wrapper (if possible)
- physical file at the root of a stream wrapper
- physical file in a subdirectory in a stream wrapper
- file entity exists but physical file has been deleted
- infinite loop #3081103: Tests: infinite loop
- multilingual support:
- pull content in its default language then in another language #3081104: Tests: multilingual support
- pull content in a language then in its default language #3081104: Tests: multilingual support
- pull non translatable bundle of a translatable entity: #2996220: Allow nontranslatable entities to be pulled
- pull non translatable entity: #2996220: Allow nontranslatable entities to be pulled
- server website URL in a subdirectory, example: https://example.com/server_website
- JSON:API Extras:
- alias in field name #3081106: Tests: JSON:API Extras alias
- missing resource identifier #3059916: Missing resource identifier results in TypeError
- Comparison #3081107: Tests: comparison
- UI:
- Pull form
- Async feature
- Remote form: Maybe not necessarily, maybe when there will ba a plugin system
- Pagination:
- basic pager
- full pager
- CLI
Proposed workflow for the tests:
- the tests create contents, for example articles
- a fake service is used for the HTTP requests.
- a GET request is done on /entity_share and jsonapi/node/article and recursively on all the pages required (relationships, pagination) to get the data and it is stored in the fake service with a mapping URL => JSON data.
- the contents are deleted
- when making HTTP requests. the fake service returns the data corresponding to the URL requested. Therefore it can also be used to store the content of a physical file.
If this workflow is working. No need for another website.
For physical files, only need to delete it before making the requests. And for the case of having a deleted physical file, a special case in the fake service or deleting te file before putting its data in the fake service will be ok.
3: push content entities (even if currently in a POC state on a separated branch, it will be present in the future)
- field types:
- Boolean
- Content (entity reference)
- Comment: currently not supported
- Date:
- date and time
- date only
- Dynamic entity reference: currently not supported
- File
- Image
- Link:
- internal (with JSON:API Extras field enhancers at this moment)
- external
- List:
- float
- integer
- text
- Media:
- audio
- image
- file
- remote video
- video
- Metatags
- Number:
- decimal
- float
- integer
- Paragraphs
- Taxonomy
- Telephone
- Text:
- plain
- plain, long
- formatted
- formatted, long
- formatted, long, with summary
- Timestamp
- files:
- public stream wrapper
- private stream wrapper
- s3fs stream wrapper (if possible)
- physical file at the root of a stream wrapper
- physical file in a subdirectory in a stream wrapper
- file entity exists but physical file has been deleted
- multilingual support:
- push content in its default language then in another language
- push content in a language then in its default language
- push non translatable bundle of a translatable entity
- push non translatable entity
- JSON:API Extras:
- alias in field name
- missing resource identifier
Proposed workflow for the tests:
- the tests create contents, for example articles
- the contents are loaded into variables with a mapping UUID => object
- a fake service is used for loading entities when needed (for recursion and relationships for example). This will need to rework the POC on 8.x-1.x-push_form to have services mockable or swappable for the tests.
- the contents are deleted. Maybe add an event listener on kernel.request that is enough early to delete content on the fly?
Comment | File | Size | Author |
---|---|---|---|
#22 | entity_share-debug_tests-2909022-22.patch | 7.24 KB | Grimreaper |
Comments
Comment #2
GrimreaperComment #4
GrimreaperComment #5
GrimreaperAdd test about #2973972: Integration with jsonapi_extras .
Comment #6
GrimreaperComment #7
GrimreaperComment #8
GrimreaperComment #9
GrimreaperAs entity share requires to have two different Drupal sites to work, for the automated tests there is two solutions, either:
Features :
1: generation of endpoint /entity_share, check if:
As this feature requires only entity_share_server, there is no need of a second website. So not concerned by the difficulty to setup test environment.
2: pull content entities:
Proposed workflow for the tests:
If this workflow is working. No need for another website.
For physical files, only need to delete it before making the requests. And for the case of having a deleted physical file, a special case in the fake service or deleting te file before putting its data in the fake service will be ok.
3: push content entities (even if currently in a POC state on a separated branch, it will be present in the future)
Proposed workflow for the tests:
If this workflow is working. No need for another website.
For physical files, only need to delete it before making the requests, as the data could be stored in a variable.
For running automated tests locally it would be easier to mock requests and responses.
Also if DrupalCI prevents having two websites running, avoiding to mirror the project on another platform to have travis or gitlab CI will be better because such setup would prevent being able to run tests locally and automatically in Drupal issue queue.
I will test the mock approach before further investigation on the two websites setup. I would like to avoid this solution.
Comment #14
GrimreaperTests initialized!
https://www.drupal.org/node/2462927/qa
Comment #15
GrimreaperUpdating issue summary.
Comment #16
GrimreaperAdd metatag field type to test.
Comment #17
GrimreaperAdd #3059916: Missing resource identifier results in TypeError
Comment #22
GrimreaperTry to debug CI.
Comment #24
GrimreaperComment #25
GrimreaperAdd a bunch of tests.
Comment #27
GrimreaperAdd cases to test.
Comment #29
GrimreaperTagging.
Comment #30
GrimreaperAdd cases for non translatable entities and bundle.
Comment #32
GrimreaperAlso, I discovered writting tests that due to the mechanism preventing infinite loop, it is currently impossible to import the same entity in different language during the same process execution.
Comment #33
GrimreaperIssue about comment 32 created #3064794: Allows to import entities in several languages during the same process.
Comment #34
GrimreaperAdd links to child issues and add date range field.
Comment #35
GrimreaperComment #36
GrimreaperRemove links to issues in the push feature. Not implemented yet.
Comment #37
GrimreaperAdd links to dedicated issue for testing channels with filters, sorts and group of filters.
Comment #38
GrimreaperTest UI for async features later.
Comment #39
GrimreaperMarking the issue has fixed has all the remaining test case have dedicated issues.