forEach was being used with async-await to create documents in the crowdin-files collection.
This led to inconsistent test results. Documents from the crowdin-files collection could be retrieved before they have been created.
We now wait for all of these files to be created. The hacky comments and dummy API calls used in tests to try and wait for these files have now been removed.
Crowdin API calls were mocked using dependency injection in the filesApi and translationsApi classes.
This is removed and all tests now need to use nock to intercept all calls to the Crowdin API. Logic is retained from the mock client but refactored to provide fake Crowdin responses synchronously if needed.
This gives much greater control over tests and also provides effective documentation in that we can see exactly what Crowdin API calls are expected.
Remove custom Payload config files
By introducing another Payload dev installation under dev-alternative-config, we avoid the need to create different Payload config files under the same Payload installation.
This is preferable because:
I was struggling to get expected test results (they work individually, but when run together the tests that use a custom Payload config act as if they have the default config).
Running the test installation locally uses the same config as the tests. We now have a way to run an alternative config locally - this wasn't possible before.
Fix crowdin file creation logic
forEach
was being used withasync-await
to create documents in thecrowdin-files
collection.This led to inconsistent test results. Documents from the
crowdin-files
collection could be retrieved before they have been created.We now wait for all of these files to be created. The
hacky
comments and dummy API calls used in tests to try and wait for these files have now been removed.See https://gist.github.com/joeytwiddle/37d2085425c049629b80956d3c618971.
Remove the mock Crowdin client
Crowdin API calls were mocked using dependency injection in the
filesApi
andtranslationsApi
classes.This is removed and all tests now need to use
nock
to intercept all calls to the Crowdin API. Logic is retained from the mock client but refactored to provide fake Crowdin responses synchronously if needed.This gives much greater control over tests and also provides effective documentation in that we can see exactly what Crowdin API calls are expected.
Remove custom Payload config files
By introducing another Payload dev installation under
dev-alternative-config
, we avoid the need to create different Payload config files under the same Payload installation.This is preferable because: