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:

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:

  • 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
    • Email
    • 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?
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grimreaper created an issue. See original summary.

Grimreaper’s picture

Issue summary: View changes

  • Grimreaper authored b509cd8 on 8.x-1.x
    Issue #2909022 by Grimreaper: Apply schema updates when installing...
Grimreaper’s picture

Issue summary: View changes
Grimreaper’s picture

Grimreaper’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Grimreaper’s picture

Priority: Critical » Major
Grimreaper’s picture

Priority: Major » Critical
Grimreaper’s picture

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.

Features :

1: generation of endpoint /entity_share, check if:

  • the channels URLs are valid
  • filters
  • groups of filters
  • sorts
  • multilingual

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
    • Content (entity reference)
    • Comment: currently not supported
    • Date:
      • date and time
      • date only
    • Dynamic entity reference: currently not supported
    • Email
    • 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
    • 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
  • infinite loop
  • multilingual support:
    • pull content in its default language then in another language
    • pull content in a language then in its default language
  • server website URL in a subdirectory, example: https://example.com/server_website
  • JSON:API Extras:
    • alias in field name

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
    • Email
    • 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
    • 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
  • JSON:API Extras:
    • alias in field name

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?

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.

  • Grimreaper authored eb9d43b on 8.x-2.x
    Issue #2909022 by Grimreaper: Put config for tests in a root module test...

  • 200e74d committed on 8.x-2.x
    Issue #2909022 by Grimreaper: Init automated tests with some entity...

  • Grimreaper authored 14cc42e on 8.x-2.x
    Issue #2909022 by Grimreaper: Debug Drupal CI.
    

  • Grimreaper authored 5ac534d on 8.x-2.x
    Issue #2909022 by Grimreaper: Debug Drupal CI.
    
Grimreaper’s picture

Status: Active » Needs work
Grimreaper’s picture

Issue summary: View changes

Updating issue summary.

Grimreaper’s picture

Issue summary: View changes

Add metatag field type to test.

Grimreaper’s picture

  • Grimreaper authored 7b705a4 on 8.x-2.x
    Issue #2909022 by Grimreaper: Refactor tests to ease creation of other...
  • Grimreaper authored dc8280a on 8.x-2.x
    Issue #2909022 by Grimreaper: Add metatag module in require-dev.
    

  • Grimreaper authored 96e9391 on 8.x-2.x
    Issue #2909022 by Grimreaper: Add a new service and wrap http client...

  • Grimreaper authored d970945 on 8.x-2.x
    Issue #2909022 by Grimreaper: Debug D.O CI. Seems that on D.O ->getBody...

  • Grimreaper authored 7321816 on 8.x-2.x
    Issue #2909022 by Grimreaper: Emulate another website overriding Request...
Grimreaper’s picture

Status: Needs work » Needs review
FileSize
7.24 KB

Try to debug CI.

  • Grimreaper authored 5d986b5 on 8.x-2.x
    Issue #2909022 by Grimreaper: Debug D.O CI. cast ->getBody() as string...
Grimreaper’s picture

Status: Needs review » Needs work
Grimreaper’s picture

Issue summary: View changes

Add a bunch of tests.

  • Grimreaper authored 26a7bbf on 8.x-2.x
    Issue #2909022 by Grimreaper: Remove eslint, add phpstan in drupalci.
    
Grimreaper’s picture

Issue summary: View changes

Add cases to test.

  • Grimreaper authored d8b4000 on 8.x-2.x
    Issue #2909022 by Grimreaper: Refactor entity_share_client tests to...
Grimreaper’s picture

Issue tags: +DevDaysTransylvania

Tagging.

Grimreaper’s picture

Issue summary: View changes

Add cases for non translatable entities and bundle.

  • Grimreaper authored 7190f6c on 8.x-2.x
    Issue #2909022 by Grimreaper: Continue refactoring of tests to prepare...
Grimreaper’s picture

Also, 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.

Grimreaper’s picture

Grimreaper’s picture

Issue summary: View changes

Add links to child issues and add date range field.

Grimreaper’s picture

Issue summary: View changes
Grimreaper’s picture

Issue summary: View changes

Remove links to issues in the push feature. Not implemented yet.

Grimreaper’s picture

Issue summary: View changes

Add links to dedicated issue for testing channels with filters, sorts and group of filters.

Grimreaper’s picture

Issue summary: View changes

Test UI for async features later.

Grimreaper’s picture

Status: Needs work » Fixed

Marking the issue has fixed has all the remaining test case have dedicated issues.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.