Testing SQL Query Filtering in a Data Labelling Application
I'll help you create a Cucumber feature file to test the SQL query filtering functionality in your data labelling application. Here's how you can structure your test:
Feature: SQL Query Filtering for Transaction Labelling
As a data labeller
I want to filter transaction descriptors using SQL queries
So that I can efficiently label specific sets of transactions
Background:
Given I am logged into the data labelling application
And I navigate to the query filtering section
Scenario: Filter transactions using a raw SQL query
When I enter the following SQL query in the raw query input field:
"""
select "descriptor",descriptor_to_sanitize_cleaned, channel, card_acceptor_id,amount,taxonomy_root,city,state_location, mcc,count(*) as trans_count
from pipeline_output.cc_pipeline_results_2024_h1_0721 cpr
where process = 'Sanitization'
group by "descriptor",descriptor_to_sanitize_cleaned, channel, card_acceptor_id,amount,taxonomy_root,city,state_location,mcc
order by trans_count desc
limit 50
"""
And I submit the query
Then a new table should be created with filtered results
And the table should contain 50 rows or fewer
And the table should include columns:
| descriptor |
| descriptor_to_sanitize_cleaned |
| channel |
| card_acceptor_id |
| amount |
| taxonomy_root |
| city |
| state_location |
| mcc |
| trans_count |
And the results should be ordered by "trans_count" in descending order
And all records should have "process" value of "Sanitization"
Scenario: Verify labelling functionality on filtered results
When I enter the SQL query for Sanitization process transactions
And I submit the query
Then I should be able to select a transaction from the results
And I should be able to suggest a transaction resolution for the selected merchant
And the suggested resolution should be saved successfully
Scenario: Verify query validation
When I enter an invalid SQL query
And I submit the query
Then I should see an error message indicating the query is invalid
And no results table should be created
Implementation Notes for Your Step Definitions:
-
For the SQL query step, you might want to use a docstring (the triple quotes) to maintain formatting and readability.
-
You'll need to implement step definitions that:
- Navigate to the appropriate section of the application
- Enter the SQL query in the correct input field
- Submit the query
- Verify the results table is created with the expected columns
- Check the ordering and filtering is applied correctly
- Test the labelling functionality on the filtered results
-
For the validation scenario, you'll need to create a deliberately invalid query and verify the application handles it gracefully.
-
Consider adding additional scenarios for:
- Testing the simplified query interface if available
- Saving and reusing queries
- Exporting filtered results
- Performance testing with large result sets
This feature file provides a good starting point for testing your SQL filtering functionality in the data labelling application.