Skip to content

Add a tool for checking for unused selectors

Will Meek requested to merge unused_selector_tool into master

What does this MR do and why?

Add a tool for checking for unused selectors

This tool interrogates vue and haml files for data-testid, and then checks if they exist in QA or spec directories

As per gitlab-org/quality/quality-engineering/team-tasks#482

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

To test a selector which is not in the todo:

  • Update qa/tools/unused_selector_todo.txt
  • Remove a line
  • cd qa
  • bundle exec rake find_unused_selectors

reports the selector eg.

        ----------------------------------------------------------------
        Found unused selector - selector1
        found in file(s) - /path/tofile1.vue
        ----------------------------------------------------------------
        Found unused selector - selector2
        found in file(s) - /path/tofile2.haml

then test that adding it to the todo does not show up:

  • bundle exec rake "find_unused_selectors[write_file: true]"
  • bundle exec rake find_unused_selectors

To test a selector which is not used in QA or specs:

  • Update a file in /app or /ee/app with a data-testid=
  • cd qa
  • bundle exec rake find_unused_selectors
  • Added selector is reported

There are a couple of follow up tasks:

Edited by Will Meek

Merge request reports