Created on 27 February 2023, almost 2 years ago
Updated 17 March 2023, almost 2 years ago

Problem/Motivation

If we're serious about getting this feature into core, we'll need tests. Let's plan and implement our test coverage. This can be used as an organizing issue.

Proposed resolution

Off the top of my head we need tests to cover:

  • Having a preview element on the page.
  • The preview renders with the active (non-admin) theme.
  • Clicking the preview button refreshes the preview and doesn't navigate the user away from the edit page.

Remaining tasks

Running the tests as Functional tests eventually produced this pages:

The node/add/page

The preview pane

@brianperry @laurii :
I was hoping to generate a page that has the preview pane feature working. Is that possible as a FunctionalTest? Should I use FunctionalJavascript / Nightwatch?

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @cosmicdreams
  • Assigned to cosmicdreams
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    In the comments here we can have a discussion of WHAT needs to be tested.

  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    I have made process in writing tests, I had a heck of time getting my test runner working with my debugger. After that was done I wrote this:

    /**
       * Test node edit form with new same_page_preview.
       */
      public function testNodePreviewButtons() {
        // Prerequisites.
        $assert_session = $this->assertSession();
        $page = $this->getSession()->getPage();
    
        // Does standard preview button?
        try {
          $assert_session->assert($page->hasButton('Preview'), "Has Preview button.");
        }
        catch (ExpectationException $e) {
          $this->fail('Original Preview button not found.');
        }
    
        // Does the page have our new preview buttons?
        try {
          $assert_session->assert($page->hasLink('edit-toggle-preview'), "Has Toggle Preview button.");
          $assert_session->assert($page->hasButton('edit-preview--2'), "Has Refresh Preview button.");
          $page->clickLink('edit-toggle-preview');
        }
        catch (ExpectationException | ElementNotFoundException $e ) {
          $this->fail('New Preview buttons not found.');
        }
      }
    
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    It produced these pages:

    Node Add Page

    Preview Pane

    @brianperry @laurii
    I was expected the Node Add Page to show the toggle working. Are javascript driven behaviors possible to test with FunctionalTest? Should I use FunctionalJavascript or Nightwatch instead? Is there something else you'd recommend?

  • Status changed to RTBC almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    I have test that work now.

  • @cosmicdreams opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    Ultimately I couldn't get a Nightwatch test that installs a module to work (either the core provided test or one I created myself). I found a way to test everything with a FunctionalJavascript tests so I'll put a pin in this until I know more.

  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul
  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul
  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul
Production build 0.71.5 2024