XbConfigEntityHttpApiTest::testJavaScriptComponent doesn't change the component on the first PATCH request

Created on 7 February 2025, 2 months ago

Overview

Working on ✨ Auto-save code components Active which is going to update XbConfigEntityHttpApiTest::testJavaScriptComponent I noticed when it does it's first successful PATCH request it actually sends exact same component, as $code_component_to_send, that it sent in the POST request to create the component.

So on 543

$request_options[RequestOptions::BODY] = self::encodeXBData($code_component_to_send);
    $body = $this->assertExpectedResponse('POST', $list_url, $request_options, 201, NULL, NULL, NULL, NULL, [
      'Location' => [
        "$base/xb/api/config/js_component/test",
      ],
    ]);
    $expected_component = [....
    $this->assertSame($expected_component, $body); 

then on 645

// Modify a Code Component correctly: 200.
    $request_options[RequestOptions::BODY] = self::encodeXBData($code_component_to_send);
    $body = $this->assertExpectedResponse('PATCH', Url::fromUri('base:/xb/api/config/js_component/test'), $request_options, 200, NULL, NULL, NULL, NULL);
    $this->assertSame($expected_component, $body);

As far as I can tell neither $code_component_to_send or $expected_component is changed between successful the POST and PATCH requests

So while it proves we get a 200 it is not a great way to prove we actually changed the code component in the PATCH,

Especially since right after the PATCH we check that the list again

$body = $this->assertExpectedResponse('GET', $list_url, [], 200, ['languages:language_interface', 'user.permissions', 'theme'], ['config:js_component_list', 'http_response'], 'UNCACHEABLE (request policy)', 'MISS');
    $this->assertSame([
      'test' => $expected_component,
    ], $body);

So while this assert does confirm that the GET list request gets the correct cache, it doesn't really prove the list has the changes made to entity in the PATCH, since there weren't any.

Proposed resolution

Send actual updates in the first successful PATCH request

πŸ› Bug report
Status

Active

Version

0.0

Component

Page builder

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

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