Improve Dynamic Page Cache header assertions in JSON:API tests

Created on 10 September 2024, 3 months ago

Problem/Motivation

JSON:API has extensive test coverage, but when a test fails, debugging and identifying the root cause can be extremely complicated and time-consuming. One of the challenges arises when the Dynamic Page Cache headers do not match the expected values. Currently, the JSON:API test suite contains numerous hardcoded header values (likely intended as an extra safety measure). However, many parts of the tests rely on other expectations, such as the expected response, cache tags, contexts, and max ages.

I propose leveraging the expected cache contexts to auto-generate the expected Dynamic Page Cache header values. This approach would help prevent unexpected test failures that occur when refactoring or modifying the codebase, thereby improving test reliability and maintainability.

The MR in this issue was forked out and contains the work I did in 🐛 Access cacheability is not correct when "view own unpublished content" is in use Needs work , where I personally encountered the difficulties caused by the current system. Additionally, I realized today that the tests in 🐛 MediaAccessControlHandler update/delete access caching is not correct Needs work are most likely failing for similar reasons to those I faced in my previous issue.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component
JSON API 

Last updated about 6 hours ago

Created by

🇭🇺Hungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024