Skip to content

Commit

Permalink
test: fixtures for testing aria-current (#3202)
Browse files Browse the repository at this point in the history
  • Loading branch information
metatoaster authored Nov 16, 2024
1 parent 15fc7dd commit aa6cd08
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/suspense_tests/e2e/features/check_aria_current.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@check_aria_current
Feature: Check aria-current being applied to make links bolded

Background:

Given I see the app

Scenario: Should see the base case working
Then I see the link Out-of-Order being bolded
Then I see the following links being bolded
| Out-of-Order |
| Nested |
9 changes: 9 additions & 0 deletions examples/suspense_tests/e2e/tests/fixtures/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ pub async fn instrumented_counts(

Ok(())
}

pub async fn link_text_is_aria_current(client: &Client, text: &str) -> Result<()> {
let link = find::link_with_text(client, text).await?;

link.attr("aria-current").await?
.expect(format!("aria-current missing for {text}").as_str());

Ok(())
}
9 changes: 9 additions & 0 deletions examples/suspense_tests/e2e/tests/fixtures/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@ async fn component_message(client: &Client, id: &str) -> Result<String> {

Ok(text)
}

pub async fn link_with_text(client: &Client, text: &str) -> Result<Element> {
let link = client
.wait()
.for_element(Locator::LinkText(text))
.await
.expect(format!("Link not found by `{}`", text).as_str());
Ok(link)
}
26 changes: 26 additions & 0 deletions examples/suspense_tests/e2e/tests/fixtures/world/check_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ async fn i_see_the_second_count_is(
Ok(())
}

#[then(regex = r"^I see the link (.*) being bolded$")]
async fn i_see_the_link_being_bolded(
world: &mut AppWorld,
text: String,
) -> Result<()> {
let client = &world.client;
check::link_text_is_aria_current(client, &text).await?;

Ok(())
}

#[then(expr = "I see the following links being bolded")]
async fn i_see_the_following_links_being_bolded(
world: &mut AppWorld,
step: &Step,
) -> Result<()> {
let client = &world.client;
if let Some(table) = step.table.as_ref() {
for row in table.rows.iter() {
check::link_text_is_aria_current(client, &row[0]).await?;
}
}

Ok(())
}

#[then(expr = "I see the following counters under section")]
#[then(expr = "the following counters under section")]
async fn i_see_the_following_counters_under_section(
Expand Down

0 comments on commit aa6cd08

Please sign in to comment.