Add basic test coverage for `wse_config` with simple config

Created on 11 February 2025, 27 days ago

This is to add some basic test coverage of Workspaces Config (wse_config) with simple configuration data, e.g., site name.

My thinking is something like this:

Four users:

  • Anonymous session - obvious
  • Non-workspaces user - authenticated user without Workspaces permissions
  • Workspaces user #1 - has all Workspaces/Workspaces Config permissions
  • Workspaces user #2 - has all Workspaces/Workspaces Config permissions

Tests:

  1. They all see the same site name in the live workspace at the start.
  2. The Workspaces users each create and activate a workspace.
  3. Workspaces user #1 modifies the site name in their workspace.
  4. Workspaces user #1 sees the new site name in their workspace.
  5. Workspaces user #2 still sees the initial site name in their workspace.
  6. Workspaces user #2 can no longer modify the site name.
  7. They all still see the same initial site name in the live workspace.
  8. Workspaces user #1 publishes their workspace.
  9. They all see the new site name in the live workspace.

Does that seem about right to start with? Anything obviously missing or extraneous?

πŸ“Œ Task
Status

Active

Version

2.0

Component

Workspace Config

Created by

πŸ‡ΊπŸ‡ΈUnited States traviscarden

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

Merge Requests

Comments & Activities

  • Issue created by @traviscarden
  • πŸ‡ΊπŸ‡ΈUnited States traviscarden

    I've added a WIP branch to show the current state of my work while I attend to another priority. I've got a basic framework (that can probably be extracted for more generalized use later). It's going well, but wse seems to break Core's workspace test utilities, since they work until I enable it:

    TypeError : Drupal\Tests\wse_config\Functional\WseSimpleConfigTest::createAndActivateWorkspaceThroughUi(): Return value must be of type Drupal\workspaces\WorkspaceInterface, null returned
     /var/www/html/web/core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php:73
     /var/www/html/web/modules/contrib/wse/modules/wse_config/tests/src/Functional/WseSimpleConfigTest.php:99
    

    That's where I'll pick up when I get back.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    That test looks like a nice start! πŸ‘ πŸ˜„

    #2: seems like the expected Workspace config entity does not exist yet, since that NULL can only come from

    Workspace::load($id)
    
  • πŸ‡·πŸ‡΄Romania amateescu

    I think the test case laid out in the IS is an excellent starting point, thanks for working on this!

    The error from #2 is caused by wse_workspace_presave(), which overrides the workspace ID with its UUID before saving. This is needed because core's assumption that workspace IDs should be reused after publishing doesn't match the expected content editor experience on most sites.

    Until this is fixed in core, you should use \Drupal\Tests\wse\Functional\WseTestUtilities::wseCreateAndActivateWorkspaceThroughUi() instead of the core trait.

  • Pipeline finished with Failed
    17 days ago
    Total: 250s
    #431096
  • πŸ‡ΊπŸ‡ΈUnited States traviscarden

    Thank you, @amateescu; that was an important piece of knowledge.

    When I created this issue, I thought simple config staging was supposed to already be supported, so I'm changing this to a feature request, and I'm presuming to mark it "Major" since it's in the critical path for Experience Builder.

    The draft MR I created above adds failing tests that are basically complete for the happy path. They should be enough to prove that the basic functionality works. Then we can proceed to add tests for secondary functionality, edge cases, and error-handling, etc.

    I'm going to move on to writing tests for other functionality in the meantime.

  • Pipeline finished with Failed
    14 days ago
    Total: 238s
    #432656
  • Pipeline finished with Failed
    14 days ago
    Total: 230s
    #432680
  • Pipeline finished with Failed
    14 days ago
    Total: 230s
    #432693
  • Pipeline finished with Failed
    14 days ago
    Total: 234s
    #432997
  • Pipeline finished with Success
    14 days ago
    Total: 385s
    #433024
  • Pipeline finished with Failed
    13 days ago
    Total: 306s
    #433376
Production build 0.71.5 2024