This repository was archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Selenium test for WebUI #398
Open
gz
wants to merge
4
commits into
main
Choose a base branch
from
selenium-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ lcov.info | |
|
||
.idea | ||
*.iml | ||
.DS_Store | ||
|
||
benches/galen_data/ | ||
benches/gdelt-data/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "webui-tester" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dev-dependencies] | ||
thirtyfour = "0.32.0-rc.7" | ||
tokio = "1.28" | ||
anyhow = "1.0" | ||
futures = "0.3.28" | ||
log = "0.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[cfg(test)] | ||
mod smoke; | ||
#[cfg(test)] | ||
mod ui; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// A basic UI workflow test. | ||
// | ||
// This test will: | ||
// 1. Create a program. | ||
// 2. Create a connector. | ||
// 3. Create a pipeline. | ||
// 4. Start the pipeline. | ||
|
||
use anyhow::Result; | ||
use thirtyfour::prelude::*; | ||
use thirtyfour::TimeoutConfiguration; | ||
use tokio::time::Duration; | ||
|
||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
|
||
use crate::ui::*; | ||
|
||
/// This is the SQL code that will be saved. | ||
/// | ||
/// I noticed that if you put newlines immediately after the braces, the code | ||
/// editor might add another brace to complete it, and then the code won't be | ||
/// correct anymore. | ||
const SQL_CODE: &str = " | ||
CREATE TABLE USERS ( name varchar ); | ||
CREATE VIEW OUTPUT_USERS as SELECT * from USERS; | ||
"; | ||
|
||
/// A config for a HTTP endpoint. | ||
/// | ||
/// The \x08 is a backspace character, which is needed to remove the space that | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sick |
||
/// is inserted by the editor. | ||
const HTTP_ENDPOINT_CONFIG: &str = " | ||
transport: | ||
name: http | ||
\x08format: | ||
name: csv | ||
"; | ||
|
||
#[tokio::test] | ||
async fn smoke_workflow() -> Result<()> { | ||
//let caps = DesiredCapabilities::firefox(); | ||
//let mut driver = WebDriver::new("http://localhost:4444", caps).await?; | ||
let nanos = SystemTime::now() | ||
.duration_since(UNIX_EPOCH) | ||
.expect("Can't get time") | ||
.subsec_nanos(); | ||
|
||
let caps = DesiredCapabilities::chrome(); | ||
let driver = WebDriver::new("http://localhost:9515", caps).await?; | ||
|
||
let timeouts = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. describe the three fields? |
||
TimeoutConfiguration::new(None, None, Some(std::time::Duration::from_millis(2000))); | ||
driver.update_timeouts(timeouts).await?; | ||
|
||
driver.goto("http://localhost:3000").await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where do all these ports come from? |
||
let elem = driver.find(By::Id("navigation")).await?; | ||
let menu = VerticalMenu::from(elem); | ||
|
||
// First we make a program, then we compile it. | ||
menu.navigate_to("SQL Editor").await?; | ||
let code_page = SqlEditor::from(driver.find(By::Id("editor-content")).await?); | ||
let program_name = format!("My Program {}", nanos); | ||
code_page.set_code(SQL_CODE, &driver).await?; | ||
code_page.set_name(&program_name).await?; | ||
code_page.set_description("This is a program").await?; | ||
code_page.wait_until_saved(Duration::from_secs(20)).await?; | ||
code_page | ||
.wait_until_compiled(Duration::from_secs(20)) | ||
.await?; | ||
|
||
// Next we make a connector. | ||
menu.navigate_to("Connector Creator").await?; | ||
let connector_creator = | ||
ConnectorCreator::from(driver.find(By::Id("connector-creator-content")).await?); | ||
connector_creator | ||
.add_generic_connector( | ||
&driver, | ||
"My HTTP Connector", | ||
"This is a HTTP connector", | ||
HTTP_ENDPOINT_CONFIG, | ||
) | ||
.await?; | ||
|
||
// Finally we make a pipeline. | ||
menu.navigate_to("Pipeline Builder").await?; | ||
let pipeline_builder = | ||
PipelineBuilder::from(driver.find(By::Id("pipeline-builder-content")).await?); | ||
let pipeline_name = format!("My Pipeline {}", nanos); | ||
pipeline_builder.set_name(&pipeline_name).await?; | ||
pipeline_builder | ||
.set_description("This is a pipeline") | ||
.await?; | ||
pipeline_builder.set_program(&program_name).await?; | ||
pipeline_builder | ||
.add_input(&driver, "My HTTP Connector") | ||
.await?; | ||
pipeline_builder | ||
.add_output(&driver, "My HTTP Connector") | ||
.await?; | ||
pipeline_builder | ||
.connect_input(&driver, "My HTTP Connector", "USERS") | ||
.await?; | ||
pipeline_builder | ||
.connect_output(&driver, "OUTPUT_USERS", "My HTTP Connector") | ||
.await?; | ||
pipeline_builder | ||
.wait_until_saved(Duration::from_secs(3)) | ||
.await?; | ||
|
||
// Start the pipeline. | ||
menu.navigate_to("Pipeline Management").await?; | ||
let pipeline_management = | ||
PipelineManagementTable::from(driver.find(By::Id("pipeline-management-content")).await?); | ||
pipeline_management.start(&pipeline_name).await?; | ||
pipeline_management | ||
.wait_until_running(&pipeline_name, Duration::from_secs(10)) | ||
.await?; | ||
|
||
let details = pipeline_management | ||
.open_details(&driver, &pipeline_name) | ||
.await?; | ||
assert_eq!(details.get_records_for_table("USERS").await?, 0); | ||
assert_eq!(details.get_records_for_view("OUTPUT_USERS").await?, 0); | ||
// TODO: send some stuff | ||
|
||
pipeline_management.pause(&pipeline_name).await?; | ||
|
||
driver.quit().await?; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a stupid editor. should have an option not to do that.