You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.1 KiB
80 lines
3.1 KiB
use fantoccini::{
|
|
actions::{InputSource, KeyAction, KeyActions},
|
|
error::CmdError,
|
|
Client, Locator,
|
|
};
|
|
use perseus::wait_for_checkpoint;
|
|
use std::time::Duration;
|
|
|
|
// This is is an E2E test with the following steps:
|
|
// - Go to the index page
|
|
// - Use the async select component to find any company
|
|
// - Click on this company and verify that we arrived
|
|
// - Come back to the root using the top left link
|
|
// - Find the first link in the table and click on it
|
|
// - Verify that all the company names in the table of the new page are the same as the link we
|
|
// clicked before
|
|
// Run like this:
|
|
// - Run any headless browser drive like geckodriver
|
|
// - Run perseus test
|
|
// - The backend should be available with some data
|
|
// - run PERSEUS_RUN_WASM_TESTS=true cargo test -- --test-threads 1
|
|
// (or use make test-client-cargo)
|
|
#[perseus::test]
|
|
async fn index(c: &mut Client) -> Result<(), fantoccini::error::CmdError> {
|
|
c.goto("http://localhost:8080").await?;
|
|
wait_for_checkpoint!("begin", 0, c);
|
|
let url = c.current_url().await?;
|
|
assert!(url.as_ref().starts_with("http://localhost:8080"));
|
|
|
|
wait_for_checkpoint!("page_visible", 0, c);
|
|
// Verify the page title
|
|
let title = c.find(Locator::Css("title")).await?.html(false).await?;
|
|
assert!(title.contains("Fast Insiders"));
|
|
|
|
wait_for_checkpoint!("page_interactive", 0, c);
|
|
// let table = c.find(Locator::Css("table")).await?.html(true).await?;
|
|
let filter_button = c.find(Locator::Css("#main button")).await?;
|
|
filter_button.click().await?;
|
|
|
|
let company_select = c.find(Locator::Css("#filters input")).await?;
|
|
company_select.send_keys("E").await?; // E is one of the most used letter.
|
|
|
|
wait_for_checkpoint!("async_select_item_change", 0, c);
|
|
|
|
let first_company = c.find(Locator::Css("div.relative li")).await?;
|
|
let clicked_company = first_company.text().await?;
|
|
first_company.click().await?;
|
|
|
|
let search_button = c.find(Locator::Css("#filters button")).await?;
|
|
search_button.click().await?;
|
|
let page = c.current_url().await?;
|
|
assert!(
|
|
page.as_ref().starts_with("http://localhost:8080/index/"),
|
|
"Unexpected target url reached: {}",
|
|
page
|
|
);
|
|
for a in c.find_all(Locator::Css("table a")).await? {
|
|
let a_text = a.text().await?;
|
|
assert_eq!(clicked_company, a_text, "The clicked company is different from the target page list of companies, respectively {} and {}", clicked_company, a_text);
|
|
}
|
|
|
|
let root_link = c.find(Locator::Css("a")).await?;
|
|
root_link.click().await?;
|
|
|
|
let first_company_in_table = c.find(Locator::Css("table a")).await?;
|
|
let company_name = first_company_in_table.text().await?;
|
|
first_company_in_table.click().await?;
|
|
for a in c.find_all(Locator::Css("table a")).await? {
|
|
let a_text = a.text().await?;
|
|
assert_eq!(company_name, a_text, "The clicked company is different from the target page list of companies, respectively {} and {}", company_name, a_text);
|
|
}
|
|
assert!(
|
|
page.as_ref().starts_with("http://localhost:8080/index/"),
|
|
"Unexpected target url reached: {}",
|
|
page
|
|
);
|
|
|
|
Ok(())
|
|
}
|