Skip to content
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

Enable integration tests #1680

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Enable integration tests #1680

wants to merge 6 commits into from

Conversation

aaschlote
Copy link
Contributor

@aaschlote aaschlote commented Jan 31, 2025

Background

We have an integration test to verify whether the pages and contexts in the on-flow configuration are available in Strapi. To obtain the latest Strapi content data, we retrieve the most recent content.json from production.

Problem

When new fields are added to the context of existing pages, the integration test fails because these fields are not present in the latest content.json from production. Additionally, we cannot deploy the updated content because the system crashes if a field is not yet defined in the on-flow configuration context.

Solution

Before running the integration tests, we first load the latest content data from Strapi and then execute the tests. This ensures that the tests run against the most up-to-date Strapi content, preventing failures due to missing fields.

@aaschlote aaschlote marked this pull request as ready for review January 31, 2025 17:45
Comment on lines +3 to +6
npm run build:localContent
CMS="FILE"
# After get the latest content data from Strapi, run the tests
npx vitest run --project=integration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. I thought the idea is to run the test directly against strapi? why would we download content and force an offline test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was also my understanding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, but I would need to make a big refactor in the tests and how Strapi gets slow after the update to the version 5 the tests might fail due the timeout (vitest problems).

So getting the all current Strapi content and tests offline it'll be the same thing as testing directly against Strapi. And it runs fast as well, because I don't need to retrieve every single flow or content from strapi to test it.

@@ -33,7 +33,7 @@
"test:e2e": "npx playwright test",
"test": "vitest run --project=!integration",
"test:watch": "vitest --project=!integration",
"test:integration": "vitest run --project integration",
"test:integration": "./tests/integration/runTests.sh",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer a solution without shell script, like npm run build:localContent && CMS="FILE" vitest run --project integration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you strongly prefer a solution without shell script? I did a shell script to avoid a long command line. And in case we need to add more options in the command line, adding in the shell script is easier than adding here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me: Much easier to understand whats going on + less files in the repo (especially hard-to-debug executables like shell scripts)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it's much easier to read multiple lines in a shell script than to read a long single-line command. 😅

Copy link

sonarqubecloud bot commented Feb 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants