|
|
|
@ -3,6 +3,8 @@ use perseus::wait_for_checkpoint;
|
|
|
|
|
|
|
|
|
|
|
|
// This is is an E2E test with the following steps:
|
|
|
|
// This is is an E2E test with the following steps:
|
|
|
|
// - Go to the index page
|
|
|
|
// - Go to the index page
|
|
|
|
|
|
|
|
// - Try all page sizes and verify that they are respected
|
|
|
|
|
|
|
|
// - Try to go to page 2
|
|
|
|
// - Use the async select component to find any company
|
|
|
|
// - Use the async select component to find any company
|
|
|
|
// - Click on this company and verify that we arrived
|
|
|
|
// - Click on this company and verify that we arrived
|
|
|
|
// - Come back to the root using the top left link
|
|
|
|
// - Come back to the root using the top left link
|
|
|
|
@ -12,9 +14,7 @@ use perseus::wait_for_checkpoint;
|
|
|
|
// Run like this:
|
|
|
|
// Run like this:
|
|
|
|
// - Run any headless browser drive like geckodriver
|
|
|
|
// - Run any headless browser drive like geckodriver
|
|
|
|
// - Run perseus test
|
|
|
|
// - Run perseus test
|
|
|
|
// - The backend should be available with some data
|
|
|
|
// - The backend should be available with at least 11 saved transactions
|
|
|
|
// - run PERSEUS_RUN_WASM_TESTS=true cargo test -- --test-threads 1
|
|
|
|
|
|
|
|
// (or use make test-client-cargo)
|
|
|
|
|
|
|
|
#[perseus::test]
|
|
|
|
#[perseus::test]
|
|
|
|
async fn index(c: &mut Client) -> Result<(), fantoccini::error::CmdError> {
|
|
|
|
async fn index(c: &mut Client) -> Result<(), fantoccini::error::CmdError> {
|
|
|
|
c.goto("http://localhost:8080").await?;
|
|
|
|
c.goto("http://localhost:8080").await?;
|
|
|
|
@ -27,6 +27,56 @@ async fn index(c: &mut Client) -> Result<(), fantoccini::error::CmdError> {
|
|
|
|
let title = c.find(Locator::Css("title")).await?.html(false).await?;
|
|
|
|
let title = c.find(Locator::Css("title")).await?.html(false).await?;
|
|
|
|
assert!(title.contains("Fast Insiders"));
|
|
|
|
assert!(title.contains("Fast Insiders"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Verify that the default table size is 20
|
|
|
|
|
|
|
|
let page_size_select = c.find(Locator::Css("#size-select")).await?;
|
|
|
|
|
|
|
|
let default_page_size = page_size_select
|
|
|
|
|
|
|
|
.prop("value")
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.expect("The value prop must be set");
|
|
|
|
|
|
|
|
assert_eq!(default_page_size.parse::<i32>().unwrap(), 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test all page sizes
|
|
|
|
|
|
|
|
let page_sizes = [20, 30, 40, 50, 10].iter();
|
|
|
|
|
|
|
|
for page_size in page_sizes {
|
|
|
|
|
|
|
|
let page_size_select = c.find(Locator::Css("#size-select")).await?;
|
|
|
|
|
|
|
|
page_size_select
|
|
|
|
|
|
|
|
.select_by_value(&page_size.to_string())
|
|
|
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let table_rows = c.find_all(Locator::Css("table tr")).await?.iter().count();
|
|
|
|
|
|
|
|
let page_size_select = c.find(Locator::Css("#size-select")).await?;
|
|
|
|
|
|
|
|
let browser_page_size = page_size_select
|
|
|
|
|
|
|
|
.prop("value")
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.expect("The value prop must be set");
|
|
|
|
|
|
|
|
assert_eq!(browser_page_size.parse::<usize>().unwrap(), *page_size);
|
|
|
|
|
|
|
|
assert_eq!(table_rows, page_size + 1); // The header also counts as a table row
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Verify that we can change pages
|
|
|
|
|
|
|
|
let page_buttons = c.find_all(Locator::Css("#page_buttons button")).await?;
|
|
|
|
|
|
|
|
assert_eq!(page_buttons[0].text().await?, "<<");
|
|
|
|
|
|
|
|
assert_eq!(page_buttons[1].text().await?, ">>");
|
|
|
|
|
|
|
|
let page_numbers = c
|
|
|
|
|
|
|
|
.find(Locator::Css("#page_buttons div"))
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.text()
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.split("/")
|
|
|
|
|
|
|
|
.map(|x| x.parse().unwrap())
|
|
|
|
|
|
|
|
.collect::<Vec<usize>>();
|
|
|
|
|
|
|
|
assert_eq!(page_numbers[0], 1);
|
|
|
|
|
|
|
|
page_buttons[1].click().await?;
|
|
|
|
|
|
|
|
let new_page_numbers = c
|
|
|
|
|
|
|
|
.find(Locator::Css("#page_buttons div"))
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.text()
|
|
|
|
|
|
|
|
.await?
|
|
|
|
|
|
|
|
.split("/")
|
|
|
|
|
|
|
|
.map(|x| x.parse().unwrap())
|
|
|
|
|
|
|
|
.collect::<Vec<usize>>();
|
|
|
|
|
|
|
|
assert_eq!(new_page_numbers[0], page_numbers[0] + 1);
|
|
|
|
|
|
|
|
|
|
|
|
// let table = c.find(Locator::Css("table")).await?.html(true).await?;
|
|
|
|
// let table = c.find(Locator::Css("table")).await?.html(true).await?;
|
|
|
|
let filter_button = c.find(Locator::Css("#main button")).await?;
|
|
|
|
let filter_button = c.find(Locator::Css("#main button")).await?;
|
|
|
|
filter_button.click().await?;
|
|
|
|
filter_button.click().await?;
|
|
|
|
|