<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=278116885016877&amp;ev=PageView&amp;noscript=1">

,

Mar 25, 2020 | 3 Minute Read

Testing Revisions in Drupal

Table of Contents

Introduction

Revisions in Drupal allows a user to create different versions (revisions) of the same node every time it is saved (whether it’s in Draft, In Review or Published state). Revisions helps a user track the changes made to the node over time. 

This feature is available in Drupal 8 core by default and can be configured for user roles through Permissions. 

Users with selected Revisions permissions can View, Revert and Delete the revisions. Users can also compare the changes between two revisions, provided the Diff module is installed.

Node Revisions in Drupal

Each revision tracks the changes made to a node every time it is saved.

This feature is enabled by default for content types in Drupal 8. However, there are ways in which Revisions could be made available for a particular content type and not for others. Similarly, Revisions could be made available per the required User Role as well.

Disabling Revisions

To disable Revisions for a content type:

  1. Navigate to Admin > Structure > Content Type > Manage. Click on the Edit tab and then navigate to Publishing Options. Uncheck the Create new revision checkbox (as shown in the image).
     
    Testing Revisions in Drupal - 1
  1. For the above content type, the Revisions tab will not be visible (as shown below).
     
    Testing Revisions in Drupal - 2

Working with Revision of Content as a QA

The Revisions tab is available as soon as a node is created, whether it’s published or unpublished. The tab is visible once the user clicks on the Edit button of a selected content type for which revisions are enabled.

  1. Switching to an older version of the content type node: To perform this action, the user should click on the Revisions tab in the Edit node page (as shown in the image below). Clicking on this redirects to the Revisions page (as shown in the next image).
     
    Testing Revisions in Drupal - 3
  2. On the Revisions page, a user with valid permissions should see the following:
     
    Testing Revisions in Drupal - 4
  1. Clicking on the date stamp should open the page. 
     
    Testing Revisions in Drupal - 5
  1. Selecting two revisions and clicking on the Compare selected revisions button should compare the differences between the two revisions. 
     
    Testing Revisions in Drupal - 6
  1. Clicking on Compare selected revisions should redirect to the view revisions page. The content shown in Red has been removed and the one in Green has been added. 
    Testing Revisions in Drupal - 7
  2. Reverting to an older version creates a new copy of the selected version and the old version is kept intact. To revert to an older version, follow these steps:
    1. Check the radio button of the version to create a revision from.
    2. Click the Revert button.
    3. Click on Revert in the confirmation message to revert. 
    4. The user gets redirected to the Revisions page and the reverted version is added as the Current revision. The old Revisions are kept intact. 
    5. Similarly, we can also Cancel the revert action by clicking on Cancel. 
       
      Testing Revisions in Drupal - 8
      Testing Revisions in Drupal - 9
    6. The status of the reverted node is kept the same. For example, in the image below the revision reverted from is In review and the status is the same in the reverted version. (The same will happen with a node in the Draft or Published state.)
       
      Testing Revisions in Drupal - 10
    7. In the example above, the status of the reverted node is In review. Verify that the changes in the reverted node are not visible to anonymous users until it is published.
    8. On clicking Edit, the tab has the data from the reverted node whose status is In review (as shown in the images below).
       
      Testing Revisions in Drupal - 11
      Testing Revisions in Drupal - 12
    9. When a revision is performed on a node which is in Published state, the same reverted node is visible to anonymous users too.
  1. Revisions work independently of translations. For example, there are two language pairs. If the user reverts the changes made to a node in one language, that should not revert the node for the other language. 
     
  2. An Admin can also control the creation of revisions from the Edit node, which by default is checked. 
    Testing Revisions in Drupal - 13
  3. A user should enter a Revision log message to verify how it appears on the Revisions page.  
    Testing Revisions in Drupal - 14

    The message appears on the Revisions page below the timestamp. 
    Testing Revisions in Drupal - 15
  4. The reverted node or any revision can also be deleted if required. This can be done by clicking on the Revert button’s dropdown and clicking on Delete. 

    Note: To be able to delete a node, the user should have the Delete Revisions permission.
    Testing Revisions in Drupal - 16

Pre-requisites

  1. Diff Module should be enabled to check the differences between two nodes.
    Testing Revisions in Drupal - 17
  2. Revision Permissions should be given to the required roles to check the revisions.
    Testing Revisions in Drupal - 18
     
    Testing Revisions in Drupal - 19
     
    Testing Revisions in Drupal - 20
  3. The user should not be able to uncheck Create new revisions for content types for which the Moderation workflow is enabled. 
    Testing Revisions in Drupal - 21
    Testing Revisions in Drupal - 22

Conclusion

The revisions functionality in Drupal prevents us from pushing the wrong information to the website. Any unwanted changes can always be reverted to the previous correct version at any time.

About the Author
Naveen Sirohi, QA Engineer - L2
About the Author

Naveen Sirohi, QA Engineer - L2

He loves eating, is a great listener, and can teach anyone how to drive a car. Off work, he’s usually binge-watching episodes of his favorite shows.


Leave us a comment

Back to Top