Adapt E2E tests to work with auto-save

Created on 18 October 2024, 2 months ago

Overview

In πŸ“Œ Autosave PoC Active we added very basic auto-save functionality. This make it easier to not lose your work in this demo state

But to make that issue smaller we just set a flag to turn off auto-save in E2E test or they would break.

Details for how it works for adapting the test

  1. Auto-saves are save to tempstore with a ENTITY_TYPE:ENTITY_ID key. It doesn't vary per user
  2. Now if you reload the XB page then you will be where left off. I think this is what breaks E2E tests as they assume reloading won't do this
  3. There is no way delete the auto-save from the UI but you could delete the tempstore
  4. The "Experience Builder" link in the toolbar now links to the current node if has the demo field, all articles for now.

Proposed resolution

Some options to adapt the tests. I don't much experience with the E2E test so take this with a grain of salt

  1. Change \Drupal\Tests\experience_builder\TestSite\XBTestSetup::setup to just create 5 or 10 nodes instead of 1, how every would be needed for the most in any test. Changes calls cy.loadURLandWaitForXBLoaded(); to just send url/node/NEXT_NID to always get a new node
  2. Change \Drupal\Tests\experience_builder\TestSite\XBTestSetup::setup to set the default value of the field_xb_demo field instead of creating a node. Then make utility Cypress method to add an article in the UI everytime you need a new one.

User interface changes

None

πŸ“Œ Task
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

  • Issue created by @tedbow
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • First commit to issue fork.
  • Merge request !427#3481736 Enable autosave in E2E test set up β†’ (Merged) created by jessebaker
  • πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

    I talked with @jessebaker about this. I made a test module, xb_e2e_support, that allows the e2e to clear the auto-save for an entity by hitting route like xb-test/clear-auto-save/node/1

    I also removed the work around in XBTestSetup that disables auto-saving and instead enabled xb_e2e_support

    This will should break the e2e test until they use the new route to clear auto-save where needed.

    I am not sure how @jessebaker plans to update the tests but I think we need test coverage that proves

    1. When a user 1 is working at xb/node/1 and they reload the page the components they placed should remain
    2. When user 2 signs in to a different computer and goes to xb/node/1 they will see the components user 1 placed. I assume there is some way to simulate the "different computer" in e2e such clearing out all brower state.

    Right now there is no safeguards around locking XB when 1 user is currently working so use 2 should be continue working where user 1 left off

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

    Looks good to me. I wrote the back end changes and confirmed we no longer have any todo's to this issue. I also confirmed that experience_builder.disable_auto-save which was the key for the state flag we used to disable auto-save is no longer in the code base

    I am not that familiar with the e2e tests but I took a quick look and it seems to make sense that loadURLandWaitForXBLoaded has new option clearAutoSave = true so all the existing tests will act the same. autosave.cy.js is the only test that uses clearAutoSave: false. The new clearAutoSave() functions make server side call I would expect to the test module.

    Will need others to approve the /ui changes

  • πŸ‡¬πŸ‡§United Kingdom jessebaker
  • πŸ‡³πŸ‡±Netherlands balintbrews Amsterdam, NL
  • πŸ‡¬πŸ‡§United Kingdom jessebaker
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024