Skip to content

Commit

Permalink
Actually make it work properly
Browse files Browse the repository at this point in the history
- Instead of using examples, just feed it the table because examples
  will rerun the whole scenario from scratch, which isn't what we are
  trying to test here.
- Provide a basic example with item listing to show how this will work.
  • Loading branch information
metatoaster committed Oct 12, 2024
1 parent bc73aa0 commit 87c8b65
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ Feature: Check Instrumented
Given I select the mode Instrumented
When I select the component Counters
When I click on Reset Counters
Then I see under Counters the <heading> count is <n>

Examples:
| heading | n |
Then I see the Counters under the Suspend Calls
| item_listing | 0 |
| item_overview | 0 |
| item_inspect | 0 |
Then I see the Counters under the Server Calls
| list_items | 0 |
| get_item | 0 |
| inspect_item_root | 0 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@check_instrument_item_listing
Feature: Check Instrumented Item Listing

Background:

Given I see the app

@check_instrumented-initial
Scenario Outline: Should see counters updated
Given I select the mode Instrumented
When I select the component Counters
When I click on Reset Counters
When I select the component Item Listing
When I select the component Counters
Then I see the Counters under the Suspend Calls
| item_listing | 1 |
| item_overview | 0 |
| item_inspect | 0 |
Then I see the Counters under the Server Calls
| list_items | 1 |
| get_item | 0 |
| inspect_item_root | 0 |
| inspect_item_field | 0 |
16 changes: 11 additions & 5 deletions examples/suspense_tests/e2e/tests/fixtures/world/check_steps.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::fixtures::{check, world::AppWorld};
use anyhow::{Ok, Result};
use cucumber::then;
use cucumber::{then, gherkin::Step};

#[then(regex = r"^I see the page title is (.*)$")]
async fn i_see_the_page_title_is(
Expand Down Expand Up @@ -80,14 +80,20 @@ async fn i_see_the_second_count_is(
Ok(())
}

#[then(expr = "I see under Counters the {word} count is {int}")]
#[then(regex = "^I see the Counters under the (Suspend|Server) Calls$")]
async fn i_see_the_counter_for_listing_is(
world: &mut AppWorld,
which: String,
expected: u32,
step: &Step,
_heading: String,
) -> Result<()> {
let client = &world.client;
check::instrumented_count_is(client, &which, expected).await?;
if let Some(table) = step.table.as_ref() {
for row in table.rows.iter() {
let selector = &row[0];
let expected = row[1].parse::<u32>().unwrap();
check::instrumented_count_is(client, selector, expected).await?;
}
}

Ok(())
}

0 comments on commit 87c8b65

Please sign in to comment.