forge
Explore
Log in

Don't you dare go Hollow

Forge-web integration tests build as one binary

Browse files at this commit

177e570658922eb4693315518b7d9c4336aa8f33Ahmet Kaan GümüşParent: c8bdbe0
  • refactor
    • forge-web integration tests build as one binary
Show full message
♻️ refactor: forge-web integration tests build as one binary

The 30 test files in crates/forge-web/tests now compile into one test
binary, `e2e`, instead of one binary per file. Linking dominated build
time, so the crate links one test executable.

- Files moved to tests/e2e/, declared as modules from e2e/main.rs
- Shared support moved to tests/e2e/common, declared once
- input_value (identical in 25 files) moved into common
- Test count unchanged at 104 (102 run, 2 ignored), all passing
- Binaries before 30, after 1
- login and cookie_named differ per file (each file has its own
  Http and Resp harness), so they stay local for now
crates/forge-web/tests/account_mail_e2e.rs → crates/forge-web/tests/e2e/account_mail_e2e.rsrenamed+1 -2
@@ -2,8 +2,7 @@
2 //! tests, this starts the real `forge` binary. The log transport writes each mail to2 //! tests, this starts the real `forge` binary. The log transport writes each mail to
3 //! `<data_dir>/mail-log/`, which is where the tests read the reset link from.3 //! `<data_dir>/mail-log/`, which is where the tests read the reset link from.
4 4
5-mod common;5+use crate::common::{launch_with, pick_ports};
6-use common::{launch_with, pick_ports};
7 use std::fs;6 use std::fs;
8 use std::path::{Path, PathBuf};7 use std::path::{Path, PathBuf};
9 use std::time::Duration;8 use std::time::Duration;
crates/forge-web/tests/advisories_e2e.rs → crates/forge-web/tests/e2e/advisories_e2e.rsrenamed+3 -12
@@ -8,8 +8,9 @@
8 //! - an owner dismisses it, reopens it, and a fixing push moves it to `fixed`;8 //! - an owner dismisses it, reopens it, and a fixing push moves it to `fixed`;
9 //! - a reader without Write gets a 404 on the page.9 //! - a reader without Write gets a 404 on the page.
10 10
11-mod common;11+use crate::common::{
12-use common::{BIN, Server, launch_with, pick_ports, tool_on_path, write_config_with};12+ BIN, Server, input_value, launch_with, pick_ports, tool_on_path, write_config_with,
13+};
13 use std::fs;14 use std::fs;
14 use std::io::{Cursor, Write};15 use std::io::{Cursor, Write};
15 use std::path::{Path, PathBuf};16 use std::path::{Path, PathBuf};
@@ -104,16 +105,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
104 }105 }
105 106
106 /// The value of the first `<input name="...">` on a page.107 /// The value of the first `<input name="...">` on a page.
107-fn input_value(body: &str, name: &str) -> String {
108- let doc = scraper::Html::parse_document(body);
109- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
110- doc.select(&selector)
111- .next()
112- .and_then(|el| el.value().attr("value"))
113- .unwrap_or_else(|| panic!("no input named {name} on page"))
114- .to_owned()
115-}
116-
117 /// Runs git with credential helpers disabled. Panics on failure and returns trimmed stdout.108 /// Runs git with credential helpers disabled. Panics on failure and returns trimmed stdout.
118 fn git(cwd: &Path, args: &[&str]) -> String {109 fn git(cwd: &Path, args: &[&str]) -> String {
119 let out: Output = Command::new("git")110 let out: Output = Command::new("git")
crates/forge-web/tests/branch_protection_e2e.rs → crates/forge-web/tests/e2e/branch_protection_e2e.rsrenamed+3 -13
@@ -2,9 +2,9 @@
2 //! binary, pushes with the real `git` client over HTTPS, and writes rules through `forge-core`2 //! binary, pushes with the real `git` client over HTTPS, and writes rules through `forge-core`
3 //! while the server runs. Helpers mirror `git_e2e.rs`.3 //! while the server runs. Helpers mirror `git_e2e.rs`.
4 4
5-mod common;5+use crate::common::{
6-use common::{6+ BIN, Ports, Server, describe, input_value, launch, pick_ports, relaunch, tool_on_path,
7- BIN, Ports, Server, describe, launch, pick_ports, relaunch, tool_on_path, write_config,7+ write_config,
8 };8 };
9 use std::fs;9 use std::fs;
10 use std::path::{Path, PathBuf};10 use std::path::{Path, PathBuf};
@@ -100,16 +100,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
100 }100 }
101 101
102 /// The value of the first `<input name="...">` on a page.102 /// The value of the first `<input name="...">` on a page.
103-fn input_value(body: &str, name: &str) -> String {
104- let doc = scraper::Html::parse_document(body);
105- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
106- doc.select(&selector)
107- .next()
108- .and_then(|el| el.value().attr("value"))
109- .unwrap_or_else(|| panic!("no input named {name} on page"))
110- .to_owned()
111-}
112-
113 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {103 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {
114 let out = Command::new(BIN)104 let out = Command::new(BIN)
115 .arg("--config")105 .arg("--config")
crates/forge-web/tests/browse_e2e.rs → crates/forge-web/tests/e2e/browse_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! Cookies are handled by hand, as in `git_e2e.rs`: the session cookie is `__Host-forge_session`5 //! Cookies are handled by hand, as in `git_e2e.rs`: the session cookie is `__Host-forge_session`
6 //! with `Secure`, so a cookie jar would not send it over plain http.6 //! with `Secure`, so a cookie jar would not send it over plain http.
7 7
8-mod common;8+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
10 use std::fs;9 use std::fs;
11 use std::path::Path;10 use std::path::Path;
12 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -108,16 +107,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
108 }107 }
109 108
110 /// The value of the first `<input name="...">` on a page.109 /// The value of the first `<input name="...">` on a page.
111-fn input_value(body: &str, name: &str) -> String {
112- let doc = scraper::Html::parse_document(body);
113- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
114- doc.select(&selector)
115- .next()
116- .and_then(|el| el.value().attr("value"))
117- .unwrap_or_else(|| panic!("no input named {name} on page"))
118- .to_owned()
119-}
120-
121 /// The values of `attr` on every element matching `selector`, in document order.110 /// The values of `attr` on every element matching `selector`, in document order.
122 fn attr_values(body: &str, selector: &str, attr: &str) -> Vec<String> {111 fn attr_values(body: &str, selector: &str, attr: &str) -> Vec<String> {
123 let doc = scraper::Html::parse_document(body);112 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/ci_e2e.rs → crates/forge-web/tests/e2e/ci_e2e.rsrenamed+1 -12
@@ -10,8 +10,7 @@
10 //! - a fork pull request: it waits for approval, then runs without secrets;10 //! - a fork pull request: it waits for approval, then runs without secrets;
11 //! - a live log: `log.txt` streams while a job runs and ends when the job finishes.11 //! - a live log: `log.txt` streams while a job runs and ends when the job finishes.
12 12
13-mod common;13+use crate::common::{BIN, FAST_CLAIMS, Server, input_value, launch_with, pick_ports, write_config};
14-use common::{BIN, FAST_CLAIMS, Server, launch_with, pick_ports, write_config};
15 use forge_ci::proto::{JobAssignment, Outcome, RegisterRequest};14 use forge_ci::proto::{JobAssignment, Outcome, RegisterRequest};
16 use forge_runner::client::ForgeClient;15 use forge_runner::client::ForgeClient;
17 use forge_runner::config::{Limits, RunnerConfig};16 use forge_runner::config::{Limits, RunnerConfig};
@@ -176,16 +175,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
176 }175 }
177 176
178 /// The value of the first `<input name="...">` on a page.177 /// The value of the first `<input name="...">` on a page.
179-fn input_value(body: &str, name: &str) -> String {
180- let doc = scraper::Html::parse_document(body);
181- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
182- doc.select(&selector)
183- .next()
184- .and_then(|el| el.value().attr("value"))
185- .unwrap_or_else(|| panic!("no input named {name} on page"))
186- .to_owned()
187-}
188-
189 /// The text of the first element matching `selector`.178 /// The text of the first element matching `selector`.
190 fn first_text(body: &str, selector: &str) -> String {179 fn first_text(body: &str, selector: &str) -> String {
191 let doc = scraper::Html::parse_document(body);180 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/common/mod.rs → crates/forge-web/tests/e2e/common/mod.rsrenamed+14 -2
@@ -1,5 +1,6 @@
1-//! Helpers shared by the forge-web e2e tests. Every test file pulls this in with `mod common;`, so1+//! Helpers shared by the forge-web e2e tests. `main.rs` declares this module once, and each test
2-//! items a given test binary does not use are allowed to be dead code.2+//! module imports what it needs from `crate::common`. Items a given test does not use are allowed
3+//! to be dead code.
3 //!4 //!
4 //! The server is started with `launch`, which waits for the three listeners (HTTP, user content5 //! The server is started with `launch`, which waits for the three listeners (HTTP, user content
5 //! and SSH) with backoff. A connection that is refused just means "not yet". If the child exits6 //! and SSH) with backoff. A connection that is refused just means "not yet". If the child exits
@@ -39,6 +40,17 @@ pub struct Ports {
39 pub content: u16,40 pub content: u16,
40 }41 }
41 42
43+/// The value of the named `<input>` on a page, read with an HTML parser.
44+pub fn input_value(body: &str, name: &str) -> String {
45+ let doc = scraper::Html::parse_document(body);
46+ let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
47+ doc.select(&selector)
48+ .next()
49+ .and_then(|el| el.value().attr("value"))
50+ .unwrap_or_else(|| panic!("no input named {name} on page"))
51+ .to_owned()
52+}
53+
42 /// A port the kernel handed out for a moment. It is free only until something binds it.54 /// A port the kernel handed out for a moment. It is free only until something binds it.
43 pub fn free_port() -> u16 {55 pub fn free_port() -> u16 {
44 std::net::TcpListener::bind("127.0.0.1:0")56 std::net::TcpListener::bind("127.0.0.1:0")
crates/forge-web/tests/community_i18n_e2e.rs → crates/forge-web/tests/e2e/community_i18n_e2e.rsrenamed+1 -3
@@ -1,12 +1,10 @@
1 //! End-to-end check that a community page (snippets) follows the viewer's browser language:1 //! End-to-end check that a community page (snippets) follows the viewer's browser language:
2 //! Turkish when `Accept-Language` asks for it, English otherwise.2 //! Turkish when `Accept-Language` asks for it, English otherwise.
3 3
4-mod common;
5-
6 use std::process::Command;4 use std::process::Command;
7 use std::time::Duration;5 use std::time::Duration;
8 6
9-use common::{BIN, describe, launch, pick_ports, write_config};7+use crate::common::{BIN, describe, launch, pick_ports, write_config};
10 use reqwest::header::ACCEPT_LANGUAGE;8 use reqwest::header::ACCEPT_LANGUAGE;
11 9
12 const PW: &str = "tahinli-password-123";10 const PW: &str = "tahinli-password-123";
crates/forge-web/tests/discussions_e2e.rs → crates/forge-web/tests/e2e/discussions_e2e.rsrenamed+1 -12
@@ -3,8 +3,7 @@
3 //! an answer in Q&A, and the lock: once locked, a plain viewer's comment is refused while the3 //! an answer in Q&A, and the lock: once locked, a plain viewer's comment is refused while the
4 //! owner can still write.4 //! owner can still write.
5 5
6-mod common;6+use crate::common::{BIN, input_value, launch, pick_ports, tool_on_path, write_config};
7-use common::{BIN, launch, pick_ports, tool_on_path, write_config};
8 use std::path::Path;7 use std::path::Path;
9 use std::process::Command;8 use std::process::Command;
10 use std::time::Duration;9 use std::time::Duration;
@@ -89,16 +88,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
89 }88 }
90 89
91 /// The value of the first `<input name="...">` on a page.90 /// The value of the first `<input name="...">` on a page.
92-fn input_value(body: &str, name: &str) -> String {
93- let doc = scraper::Html::parse_document(body);
94- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
95- doc.select(&selector)
96- .next()
97- .and_then(|el| el.value().attr("value"))
98- .unwrap_or_else(|| panic!("no input named {name} on page"))
99- .to_owned()
100-}
101-
102 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {91 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {
103 let out = Command::new(BIN)92 let out = Command::new(BIN)
104 .arg("--config")93 .arg("--config")
crates/forge-web/tests/git_e2e.rs → crates/forge-web/tests/e2e/git_e2e.rsrenamed+1 -12
@@ -4,8 +4,7 @@
4 //! Cookies are handled by hand: the session cookie is `__Host-forge_session` with `Secure`, so a4 //! Cookies are handled by hand: the session cookie is `__Host-forge_session` with `Secure`, so a
5 //! cookie jar would not send it over plain http. The test parses `Set-Cookie` and sends `Cookie`.5 //! cookie jar would not send it over plain http. The test parses `Set-Cookie` and sends `Cookie`.
6 6
7-mod common;7+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
8-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
9 use std::fs;8 use std::fs;
10 use std::path::{Path, PathBuf};9 use std::path::{Path, PathBuf};
11 use std::process::{Command, Output};10 use std::process::{Command, Output};
@@ -127,16 +126,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
127 }126 }
128 127
129 /// The value of the first `<input name="...">` on a page.128 /// The value of the first `<input name="...">` on a page.
130-fn input_value(body: &str, name: &str) -> String {
131- let doc = scraper::Html::parse_document(body);
132- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
133- doc.select(&selector)
134- .next()
135- .and_then(|el| el.value().attr("value"))
136- .unwrap_or_else(|| panic!("no input named {name} on page"))
137- .to_owned()
138-}
139-
140 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {129 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {
141 let out = Command::new(BIN)130 let out = Command::new(BIN)
142 .arg("--config")131 .arg("--config")
crates/forge-web/tests/i18n_e2e.rs → crates/forge-web/tests/e2e/i18n_e2e.rsrenamed+1 -13
@@ -1,13 +1,11 @@
1 //! End-to-end checks for the interface language. Anonymous pages follow `Accept-Language`; a1 //! End-to-end checks for the interface language. Anonymous pages follow `Accept-Language`; a
2 //! signed-in user's stored language beats the browser; `<html lang>` matches the language used.2 //! signed-in user's stored language beats the browser; `<html lang>` matches the language used.
3 3
4-mod common;
5-
6 use std::path::{Path, PathBuf};4 use std::path::{Path, PathBuf};
7 use std::process::Command;5 use std::process::Command;
8 use std::time::Duration;6 use std::time::Duration;
9 7
10-use common::{BIN, Server, describe, launch, pick_ports, write_config};8+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
11 use forge_core::Store;9 use forge_core::Store;
12 use reqwest::header::{ACCEPT_LANGUAGE, COOKIE, HeaderMap, SET_COOKIE};10 use reqwest::header::{ACCEPT_LANGUAGE, COOKIE, HeaderMap, SET_COOKIE};
13 11
@@ -90,16 +88,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
90 }88 }
91 89
92 /// The value of the first `<input name="...">` on a page.90 /// The value of the first `<input name="...">` on a page.
93-fn input_value(body: &str, name: &str) -> String {
94- let doc = scraper::Html::parse_document(body);
95- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
96- doc.select(&selector)
97- .next()
98- .and_then(|el| el.value().attr("value"))
99- .unwrap_or_else(|| panic!("no input named {name} on page"))
100- .to_owned()
101-}
102-
103 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.91 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
104 fn admin(config: &Path, args: &[&str]) {92 fn admin(config: &Path, args: &[&str]) {
105 let out = Command::new(BIN)93 let out = Command::new(BIN)
crates/forge-web/tests/issue_close_e2e.rs → crates/forge-web/tests/e2e/issue_close_e2e.rsrenamed+1 -12
@@ -3,8 +3,7 @@
3 //! The server runs as a subprocess. Issues are created through the store on the same database3 //! The server runs as a subprocess. Issues are created through the store on the same database
4 //! file, and every push is a real `git push` through the git HTTP endpoints.4 //! file, and every push is a real `git push` through the git HTTP endpoints.
5 5
6-mod common;6+use crate::common::{BIN, input_value, launch, pick_ports, relaunch, tool_on_path, write_config};
7-use common::{BIN, launch, pick_ports, relaunch, tool_on_path, write_config};
8 use std::fs;7 use std::fs;
9 use std::future::Future;8 use std::future::Future;
10 use std::path::Path;9 use std::path::Path;
@@ -96,16 +95,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
96 }95 }
97 96
98 /// The value of the first `<input name="...">` on a page.97 /// The value of the first `<input name="...">` on a page.
99-fn input_value(body: &str, name: &str) -> String {
100- let doc = scraper::Html::parse_document(body);
101- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
102- doc.select(&selector)
103- .next()
104- .and_then(|el| el.value().attr("value"))
105- .unwrap_or_else(|| panic!("no input named {name} on page"))
106- .to_owned()
107-}
108-
109 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {98 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {
110 let out = Command::new(BIN)99 let out = Command::new(BIN)
111 .arg("--config")100 .arg("--config")
crates/forge-web/tests/lfs_e2e.rs → crates/forge-web/tests/e2e/lfs_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! Git config is isolated from the developer's machine: `HOME` and `GIT_CONFIG_GLOBAL` point into5 //! Git config is isolated from the developer's machine: `HOME` and `GIT_CONFIG_GLOBAL` point into
6 //! the test's temp dir.6 //! the test's temp dir.
7 7
8-mod common;8+use crate::common::{BIN, describe, input_value, launch, pick_ports, write_config};
9-use common::{BIN, describe, launch, pick_ports, write_config};
10 use std::fs;9 use std::fs;
11 use std::path::Path;10 use std::path::Path;
12 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -94,16 +93,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
94 }93 }
95 94
96 /// The value of the first `<input name="...">` on a page.95 /// The value of the first `<input name="...">` on a page.
97-fn input_value(body: &str, name: &str) -> String {
98- let doc = scraper::Html::parse_document(body);
99- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
100- doc.select(&selector)
101- .next()
102- .and_then(|el| el.value().attr("value"))
103- .unwrap_or_else(|| panic!("no input named {name} on page"))
104- .to_owned()
105-}
106-
107 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {96 fn run_admin(config: &Path, username: &str, extra: &[&str], password: &str) {
108 let out = Command::new(BIN)97 let out = Command::new(BIN)
109 .arg("--config")98 .arg("--config")
crates/forge-web/tests/e2e/main.rsadded+36 -0
@@ -0,0 +1,36 @@
1+//! One integration test binary for forge-web. Every file in this directory is a module of this
2+//! crate, so the package links one test executable instead of one per file. The shared support
3+//! lives in `common`.
4+
5+mod common;
6+
7+mod account_mail_e2e;
8+mod advisories_e2e;
9+mod branch_protection_e2e;
10+mod browse_e2e;
11+mod ci_e2e;
12+mod community_i18n_e2e;
13+mod discussions_e2e;
14+mod git_e2e;
15+mod i18n_e2e;
16+mod issue_close_e2e;
17+mod lfs_e2e;
18+mod merge_queue_e2e;
19+mod mirrors_e2e;
20+mod oci_e2e;
21+mod orgs_core_e2e;
22+mod orgs_live_e2e;
23+mod orgs_ui_e2e;
24+mod packages_e2e;
25+mod pulls_e2e;
26+mod repo_collaborators_e2e;
27+mod repo_rename_e2e;
28+mod repo_settings_e2e;
29+mod repo_transfer_e2e;
30+mod runner_subcommand;
31+mod section_nav_e2e;
32+mod snippets_e2e;
33+mod stars_e2e;
34+mod ui_prefs_e2e;
35+mod user_delete_e2e;
36+mod wiki_e2e;
crates/forge-web/tests/merge_queue_e2e.rs → crates/forge-web/tests/e2e/merge_queue_e2e.rsrenamed+3 -12
@@ -9,8 +9,9 @@
9 // The harness helpers are the same ones `ci_e2e.rs` uses. This file uses a subset of them.9 // The harness helpers are the same ones `ci_e2e.rs` uses. This file uses a subset of them.
10 #![allow(dead_code)]10 #![allow(dead_code)]
11 11
12-mod common;12+use crate::common::{
13-use common::{BIN, FAST_CLAIMS, Server, launch_with, pick_ports, tool_on_path, write_config};13+ BIN, FAST_CLAIMS, Server, input_value, launch_with, pick_ports, tool_on_path, write_config,
14+};
14 use forge_ci::proto::{JobAssignment, RegisterRequest};15 use forge_ci::proto::{JobAssignment, RegisterRequest};
15 use forge_runner::client::ForgeClient;16 use forge_runner::client::ForgeClient;
16 use forge_runner::config::{Limits, RunnerConfig};17 use forge_runner::config::{Limits, RunnerConfig};
@@ -117,16 +118,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
117 }118 }
118 119
119 /// The value of the first `<input name="...">` on a page.120 /// The value of the first `<input name="...">` on a page.
120-fn input_value(body: &str, name: &str) -> String {
121- let doc = scraper::Html::parse_document(body);
122- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
123- doc.select(&selector)
124- .next()
125- .and_then(|el| el.value().attr("value"))
126- .unwrap_or_else(|| panic!("no input named {name} on page"))
127- .to_owned()
128-}
129-
130 /// The text of the first element matching `selector`.121 /// The text of the first element matching `selector`.
131 fn first_text(body: &str, selector: &str) -> String {122 fn first_text(body: &str, selector: &str) -> String {
132 let doc = scraper::Html::parse_document(body);123 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/mirrors_e2e.rs → crates/forge-web/tests/e2e/mirrors_e2e.rsrenamed+3 -12
@@ -9,8 +9,9 @@
9 //! - push mirror `pm` to `tahinli/target` (created empty) after a push to `pm`;9 //! - push mirror `pm` to `tahinli/target` (created empty) after a push to `pm`;
10 //! - the mirror pages and the server log never contain the access token.10 //! - the mirror pages and the server log never contain the access token.
11 11
12-mod common;12+use crate::common::{
13-use common::{BIN, Server, launch_with, pick_ports, tool_on_path, write_config_with};13+ BIN, Server, input_value, launch_with, pick_ports, tool_on_path, write_config_with,
14+};
14 use std::collections::BTreeSet;15 use std::collections::BTreeSet;
15 use std::fs;16 use std::fs;
16 use std::path::{Path, PathBuf};17 use std::path::{Path, PathBuf};
@@ -101,16 +102,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
101 }102 }
102 103
103 /// The value of the first `<input name="...">` on a page.104 /// The value of the first `<input name="...">` on a page.
104-fn input_value(body: &str, name: &str) -> String {
105- let doc = scraper::Html::parse_document(body);
106- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
107- doc.select(&selector)
108- .next()
109- .and_then(|el| el.value().attr("value"))
110- .unwrap_or_else(|| panic!("no input named {name} on page"))
111- .to_owned()
112-}
113-
114 /// The `action` of every form whose action ends with `suffix`, in page order.105 /// The `action` of every form whose action ends with `suffix`, in page order.
115 fn form_actions(body: &str, suffix: &str) -> Vec<String> {106 fn form_actions(body: &str, suffix: &str) -> Vec<String> {
116 let doc = scraper::Html::parse_document(body);107 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/oci_e2e.rs → crates/forge-web/tests/e2e/oci_e2e.rsrenamed+1 -2
@@ -5,8 +5,7 @@
5 //! up through the store before the server starts, since the web has no way to make one private.5 //! up through the store before the server starts, since the web has no way to make one private.
6 //! The last test drives podman when it is installed; it is ignored by default.6 //! The last test drives podman when it is installed; it is ignored by default.
7 7
8-mod common;8+use crate::common::{BIN, Server, describe, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, Server, describe, launch, pick_ports, tool_on_path, write_config};
10 use std::path::Path;9 use std::path::Path;
11 use std::process::Command;10 use std::process::Command;
12 use std::time::Duration;11 use std::time::Duration;
crates/forge-web/tests/orgs_core_e2e.rs → crates/forge-web/tests/e2e/orgs_core_e2e.rsrenamed+1 -12
@@ -3,8 +3,7 @@
3 //! this starts the real `forge` binary and drives it over HTTP. The org rows and their credentials3 //! this starts the real `forge` binary and drives it over HTTP. The org rows and their credentials
4 //! are written straight into the database before the server starts.4 //! are written straight into the database before the server starts.
5 5
6-mod common;6+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
7-use common::{BIN, Server, describe, launch, pick_ports, write_config};
8 use std::future::Future;7 use std::future::Future;
9 use std::path::{Path, PathBuf};8 use std::path::{Path, PathBuf};
10 use std::process::Command;9 use std::process::Command;
@@ -98,16 +97,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
98 }97 }
99 98
100 /// The value of the first `<input name="...">` on a page.99 /// The value of the first `<input name="...">` on a page.
101-fn input_value(body: &str, name: &str) -> String {
102- let doc = scraper::Html::parse_document(body);
103- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
104- doc.select(&selector)
105- .next()
106- .and_then(|el| el.value().attr("value"))
107- .unwrap_or_else(|| panic!("no input named {name} on page"))
108- .to_owned()
109-}
110-
111 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.100 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
112 fn admin(config: &Path, args: &[&str]) {101 fn admin(config: &Path, args: &[&str]) {
113 let out = Command::new(BIN)102 let out = Command::new(BIN)
crates/forge-web/tests/orgs_live_e2e.rs → crates/forge-web/tests/e2e/orgs_live_e2e.rsrenamed+1 -12
@@ -2,8 +2,7 @@
2 //! with a seeded org (owner tahinli, member bob, a team), and the test drives the writes over HTTP2 //! with a seeded org (owner tahinli, member bob, a team), and the test drives the writes over HTTP
3 //! and reads each stream. It also checks that each stream refuses the viewers its page refuses.3 //! and reads each stream. It also checks that each stream refuses the viewers its page refuses.
4 4
5-mod common;5+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
6-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
7 use std::path::Path;6 use std::path::Path;
8 use std::process::{Command, Output};7 use std::process::{Command, Output};
9 use std::time::Duration;8 use std::time::Duration;
@@ -118,16 +117,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
118 }117 }
119 118
120 /// The value of the first `<input name="...">` on a page.119 /// The value of the first `<input name="...">` on a page.
121-fn input_value(body: &str, name: &str) -> String {
122- let doc = scraper::Html::parse_document(body);
123- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
124- doc.select(&selector)
125- .next()
126- .and_then(|el| el.value().attr("value"))
127- .unwrap_or_else(|| panic!("no input named {name} on page"))
128- .to_owned()
129-}
130-
131 /// The `data-live` value of the first element that names a stream, if any.120 /// The `data-live` value of the first element that names a stream, if any.
132 fn live_url(body: &str) -> Option<String> {121 fn live_url(body: &str) -> Option<String> {
133 let doc = scraper::Html::parse_document(body);122 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/orgs_ui_e2e.rs → crates/forge-web/tests/e2e/orgs_ui_e2e.rsrenamed+3 -12
@@ -3,8 +3,9 @@
3 //! through the store before the server starts, and then drive the pages over HTTP. Cookies are3 //! through the store before the server starts, and then drive the pages over HTTP. Cookies are
4 //! handled by hand, as in `repo_collaborators_e2e.rs`.4 //! handled by hand, as in `repo_collaborators_e2e.rs`.
5 5
6-mod common;6+use crate::common::{
7-use common::{BIN, describe, launch, launch_with, pick_ports, tool_on_path, write_config};7+ BIN, describe, input_value, launch, launch_with, pick_ports, tool_on_path, write_config,
8+};
8 use std::fs;9 use std::fs;
9 use std::path::Path;10 use std::path::Path;
10 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -101,16 +102,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
101 }102 }
102 103
103 /// The value of the first `<input name="...">` on a page.104 /// The value of the first `<input name="...">` on a page.
104-fn input_value(body: &str, name: &str) -> String {
105- let doc = scraper::Html::parse_document(body);
106- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
107- doc.select(&selector)
108- .next()
109- .and_then(|el| el.value().attr("value"))
110- .unwrap_or_else(|| panic!("no input named {name} on page"))
111- .to_owned()
112-}
113-
114 /// The value of the selected option of the `<select name="...">` on a page.105 /// The value of the selected option of the `<select name="...">` on a page.
115 fn selected_value(body: &str, name: &str) -> Option<String> {106 fn selected_value(body: &str, name: &str) -> Option<String> {
116 let doc = scraper::Html::parse_document(body);107 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/packages_e2e.rs → crates/forge-web/tests/e2e/packages_e2e.rsrenamed+1 -2
@@ -4,8 +4,7 @@
4 //! private package are seeded through the store before the server starts, since the web API has4 //! private package are seeded through the store before the server starts, since the web API has
5 //! no way to make a package private.5 //! no way to make a package private.
6 6
7-mod common;7+use crate::common::{BIN, Server, describe, launch, pick_ports, write_config};
8-use common::{BIN, Server, describe, launch, pick_ports, write_config};
9 use std::io::Write;8 use std::io::Write;
10 use std::path::Path;9 use std::path::Path;
11 use std::process::Command;10 use std::process::Command;
crates/forge-web/tests/pulls_e2e.rs → crates/forge-web/tests/e2e/pulls_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! scenarios cover a same-repo merge that closes an issue, a push that updates an open pull,5 //! scenarios cover a same-repo merge that closes an issue, a push that updates an open pull,
6 //! a fork pull merged by squash, and a conflict that blocks the merge.6 //! a fork pull merged by squash, and a conflict that blocks the merge.
7 7
8-mod common;8+use crate::common::{BIN, Server, input_value, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, Server, launch, pick_ports, tool_on_path, write_config};
10 use std::fs;9 use std::fs;
11 use std::path::{Path, PathBuf};10 use std::path::{Path, PathBuf};
12 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -98,16 +97,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
98 }97 }
99 98
100 /// The value of the first `<input name="...">` on a page.99 /// The value of the first `<input name="...">` on a page.
101-fn input_value(body: &str, name: &str) -> String {
102- let doc = scraper::Html::parse_document(body);
103- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
104- doc.select(&selector)
105- .next()
106- .and_then(|el| el.value().attr("value"))
107- .unwrap_or_else(|| panic!("no input named {name} on page"))
108- .to_owned()
109-}
110-
111 /// Text of the first state badge on a page, e.g. `Open`, `Closed` or `Merged`.100 /// Text of the first state badge on a page, e.g. `Open`, `Closed` or `Merged`.
112 fn state_badge(body: &str) -> String {101 fn state_badge(body: &str) -> String {
113 let doc = scraper::Html::parse_document(body);102 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/repo_collaborators_e2e.rs → crates/forge-web/tests/e2e/repo_collaborators_e2e.rsrenamed+1 -12
@@ -2,8 +2,7 @@
2 //! seed users and repos through the store before the server starts, and then drive the page and2 //! seed users and repos through the store before the server starts, and then drive the page and
3 //! its POST forms over HTTP. Cookies are handled by hand (see `repo_settings_e2e.rs`).3 //! its POST forms over HTTP. Cookies are handled by hand (see `repo_settings_e2e.rs`).
4 4
5-mod common;5+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
6-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
7 use std::fs;6 use std::fs;
8 use std::path::Path;7 use std::path::Path;
9 use std::process::{Command, Output};8 use std::process::{Command, Output};
@@ -95,16 +94,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
95 }94 }
96 95
97 /// The value of the first `<input name="...">` on a page.96 /// The value of the first `<input name="...">` on a page.
98-fn input_value(body: &str, name: &str) -> String {
99- let doc = scraper::Html::parse_document(body);
100- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
101- doc.select(&selector)
102- .next()
103- .and_then(|el| el.value().attr("value"))
104- .unwrap_or_else(|| panic!("no input named {name} on page"))
105- .to_owned()
106-}
107-
108 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.97 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
109 fn admin(config: &Path, args: &[&str]) -> Output {98 fn admin(config: &Path, args: &[&str]) -> Output {
110 let out = Command::new(BIN)99 let out = Command::new(BIN)
crates/forge-web/tests/repo_rename_e2e.rs → crates/forge-web/tests/e2e/repo_rename_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,
6 //! which a cookie jar would not send over plain http.6 //! which a cookie jar would not send over plain http.
7 7
8-mod common;8+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
10 use std::fs;9 use std::fs;
11 use std::path::Path;10 use std::path::Path;
12 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -98,16 +97,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
98 }97 }
99 98
100 /// The value of the first `<input name="...">` on a page.99 /// The value of the first `<input name="...">` on a page.
101-fn input_value(body: &str, name: &str) -> String {
102- let doc = scraper::Html::parse_document(body);
103- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
104- doc.select(&selector)
105- .next()
106- .and_then(|el| el.value().attr("value"))
107- .unwrap_or_else(|| panic!("no input named {name} on page"))
108- .to_owned()
109-}
110-
111 /// The `action` of the first form on a page whose action ends with `suffix`.100 /// The `action` of the first form on a page whose action ends with `suffix`.
112 fn form_action(body: &str, suffix: &str) -> String {101 fn form_action(body: &str, suffix: &str) -> String {
113 let doc = scraper::Html::parse_document(body);102 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/repo_settings_e2e.rs → crates/forge-web/tests/e2e/repo_settings_e2e.rsrenamed+1 -12
@@ -4,8 +4,7 @@
4 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,4 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,
5 //! which a cookie jar would not send over plain http.5 //! which a cookie jar would not send over plain http.
6 6
7-mod common;7+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
8-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
9 use std::fs;8 use std::fs;
10 use std::path::{Path, PathBuf};9 use std::path::{Path, PathBuf};
11 use std::process::{Command, Output};10 use std::process::{Command, Output};
@@ -97,16 +96,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
97 }96 }
98 97
99 /// The value of the first `<input name="...">` on a page.98 /// The value of the first `<input name="...">` on a page.
100-fn input_value(body: &str, name: &str) -> String {
101- let doc = scraper::Html::parse_document(body);
102- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
103- doc.select(&selector)
104- .next()
105- .and_then(|el| el.value().attr("value"))
106- .unwrap_or_else(|| panic!("no input named {name} on page"))
107- .to_owned()
108-}
109-
110 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.99 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
111 fn admin(config: &Path, args: &[&str]) -> Output {100 fn admin(config: &Path, args: &[&str]) -> Output {
112 let out = Command::new(BIN)101 let out = Command::new(BIN)
crates/forge-web/tests/repo_transfer_e2e.rs → crates/forge-web/tests/e2e/repo_transfer_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,
6 //! which a cookie jar would not send over plain http.6 //! which a cookie jar would not send over plain http.
7 7
8-mod common;8+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
10 use std::fs;9 use std::fs;
11 use std::process::Command;10 use std::process::Command;
12 use std::time::Duration;11 use std::time::Duration;
@@ -98,16 +97,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
98 }97 }
99 98
100 /// The value of the first `<input name="...">` on a page.99 /// The value of the first `<input name="...">` on a page.
101-fn input_value(body: &str, name: &str) -> String {
102- let doc = scraper::Html::parse_document(body);
103- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
104- doc.select(&selector)
105- .next()
106- .and_then(|el| el.value().attr("value"))
107- .unwrap_or_else(|| panic!("no input named {name} on page"))
108- .to_owned()
109-}
110-
111 /// The `action` of the first form on a page whose action ends with `suffix`. Panics when none.100 /// The `action` of the first form on a page whose action ends with `suffix`. Panics when none.
112 fn form_action(body: &str, suffix: &str) -> String {101 fn form_action(body: &str, suffix: &str) -> String {
113 let doc = scraper::Html::parse_document(body);102 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/runner_subcommand.rs → crates/forge-web/tests/e2e/runner_subcommand.rsrenamed+0 -0
crates/forge-web/tests/section_nav_e2e.rs → crates/forge-web/tests/e2e/section_nav_e2e.rsrenamed+1 -12
@@ -4,8 +4,7 @@
4 4
5 #![allow(dead_code)]5 #![allow(dead_code)]
6 6
7-mod common;7+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
8-use common::{BIN, Server, describe, launch, pick_ports, write_config};
9 use std::path::Path;8 use std::path::Path;
10 use std::process::Command;9 use std::process::Command;
11 use std::time::Duration;10 use std::time::Duration;
@@ -95,16 +94,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
95 }94 }
96 95
97 /// The value of the first `<input name="...">` on a page.96 /// The value of the first `<input name="...">` on a page.
98-fn input_value(body: &str, name: &str) -> String {
99- let doc = scraper::Html::parse_document(body);
100- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
101- doc.select(&selector)
102- .next()
103- .and_then(|el| el.value().attr("value"))
104- .unwrap_or_else(|| panic!("no input named {name} on page"))
105- .to_owned()
106-}
107-
108 /// The `data-theme` attribute of `<html>`, if the page sets one.97 /// The `data-theme` attribute of `<html>`, if the page sets one.
109 fn html_theme(body: &str) -> Option<String> {98 fn html_theme(body: &str) -> Option<String> {
110 let doc = scraper::Html::parse_document(body);99 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/snippets_e2e.rs → crates/forge-web/tests/e2e/snippets_e2e.rsrenamed+1 -12
@@ -2,8 +2,7 @@
2 //! drives it over HTTP. Cookies are set by hand because the session cookie is `__Host-` and2 //! drives it over HTTP. Cookies are set by hand because the session cookie is `__Host-` and
3 //! `Secure`. Files are fetched from the user-content listener, as a browser would.3 //! `Secure`. Files are fetched from the user-content listener, as a browser would.
4 4
5-mod common;5+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
6-use common::{BIN, Server, describe, launch, pick_ports, write_config};
7 use std::path::{Path, PathBuf};6 use std::path::{Path, PathBuf};
8 use std::process::Command;7 use std::process::Command;
9 use std::time::Duration;8 use std::time::Duration;
@@ -90,16 +89,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
90 }89 }
91 90
92 /// The value of the first `<input name="...">` on a page.91 /// The value of the first `<input name="...">` on a page.
93-fn input_value(body: &str, name: &str) -> String {
94- let doc = scraper::Html::parse_document(body);
95- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
96- doc.select(&selector)
97- .next()
98- .and_then(|el| el.value().attr("value"))
99- .unwrap_or_else(|| panic!("no input named {name} on page"))
100- .to_owned()
101-}
102-
103 /// The path and query of an absolute URL, so it can be requested through a base-bound client.92 /// The path and query of an absolute URL, so it can be requested through a base-bound client.
104 fn path_of(url: &str) -> String {93 fn path_of(url: &str) -> String {
105 let rest = url.split_once("//").map_or(url, |(_, r)| r);94 let rest = url.split_once("//").map_or(url, |(_, r)| r);
crates/forge-web/tests/stars_e2e.rs → crates/forge-web/tests/e2e/stars_e2e.rsrenamed+3 -12
@@ -2,8 +2,9 @@
2 //! banner. Like the other e2e tests, this starts the real `forge` binary and drives it over2 //! banner. Like the other e2e tests, this starts the real `forge` binary and drives it over
3 //! HTTP. Cookies are set by hand because the session cookie is `__Host-` and `Secure`.3 //! HTTP. Cookies are set by hand because the session cookie is `__Host-` and `Secure`.
4 4
5-mod common;5+use crate::common::{
6-use common::{BIN, Server, describe, launch, pick_ports, tool_on_path, write_config};6+ BIN, Server, describe, input_value, launch, pick_ports, tool_on_path, write_config,
7+};
7 use std::fs;8 use std::fs;
8 use std::path::{Path, PathBuf};9 use std::path::{Path, PathBuf};
9 use std::process::{Command, Stdio};10 use std::process::{Command, Stdio};
@@ -95,16 +96,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
95 }96 }
96 97
97 /// The value of the first `<input name="...">` on a page.98 /// The value of the first `<input name="...">` on a page.
98-fn input_value(body: &str, name: &str) -> String {
99- let doc = scraper::Html::parse_document(body);
100- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
101- doc.select(&selector)
102- .next()
103- .and_then(|el| el.value().attr("value"))
104- .unwrap_or_else(|| panic!("no input named {name} on page"))
105- .to_owned()
106-}
107-
108 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.99 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
109 fn admin(config: &Path, args: &[&str]) {100 fn admin(config: &Path, args: &[&str]) {
110 let out = Command::new(BIN)101 let out = Command::new(BIN)
crates/forge-web/tests/ui_prefs_e2e.rs → crates/forge-web/tests/e2e/ui_prefs_e2e.rsrenamed+1 -12
@@ -3,8 +3,7 @@
3 //! tests, this starts the real `forge` binary and drives it over HTTP. Cookies are set by hand3 //! tests, this starts the real `forge` binary and drives it over HTTP. Cookies are set by hand
4 //! because the session cookie is `__Host-` and `Secure`.4 //! because the session cookie is `__Host-` and `Secure`.
5 5
6-mod common;6+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
7-use common::{BIN, Server, describe, launch, pick_ports, write_config};
8 use std::path::Path;7 use std::path::Path;
9 use std::process::Command;8 use std::process::Command;
10 use std::time::Duration;9 use std::time::Duration;
@@ -94,16 +93,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
94 }93 }
95 94
96 /// The value of the first `<input name="...">` on a page.95 /// The value of the first `<input name="...">` on a page.
97-fn input_value(body: &str, name: &str) -> String {
98- let doc = scraper::Html::parse_document(body);
99- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
100- doc.select(&selector)
101- .next()
102- .and_then(|el| el.value().attr("value"))
103- .unwrap_or_else(|| panic!("no input named {name} on page"))
104- .to_owned()
105-}
106-
107 /// The `data-theme` attribute of `<html>`, if the page sets one.96 /// The `data-theme` attribute of `<html>`, if the page sets one.
108 fn html_theme(body: &str) -> Option<String> {97 fn html_theme(body: &str) -> Option<String> {
109 let doc = scraper::Html::parse_document(body);98 let doc = scraper::Html::parse_document(body);
crates/forge-web/tests/user_delete_e2e.rs → crates/forge-web/tests/e2e/user_delete_e2e.rsrenamed+1 -12
@@ -3,8 +3,7 @@
3 //! the real `forge` binary and drives it over HTTP. Cookies are set by hand because the3 //! the real `forge` binary and drives it over HTTP. Cookies are set by hand because the
4 //! session cookie is `__Host-` and `Secure`.4 //! session cookie is `__Host-` and `Secure`.
5 5
6-mod common;6+use crate::common::{BIN, Server, describe, input_value, launch, pick_ports, write_config};
7-use common::{BIN, Server, describe, launch, pick_ports, write_config};
8 use std::fs;7 use std::fs;
9 use std::future::Future;8 use std::future::Future;
10 use std::path::{Path, PathBuf};9 use std::path::{Path, PathBuf};
@@ -101,16 +100,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
101 }100 }
102 101
103 /// The value of the first `<input name="...">` on a page.102 /// The value of the first `<input name="...">` on a page.
104-fn input_value(body: &str, name: &str) -> String {
105- let doc = scraper::Html::parse_document(body);
106- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
107- doc.select(&selector)
108- .next()
109- .and_then(|el| el.value().attr("value"))
110- .unwrap_or_else(|| panic!("no input named {name} on page"))
111- .to_owned()
112-}
113-
114 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.103 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
115 fn admin(config: &Path, args: &[&str]) {104 fn admin(config: &Path, args: &[&str]) {
116 let out = Command::new(BIN)105 let out = Command::new(BIN)
crates/forge-web/tests/wiki_e2e.rs → crates/forge-web/tests/e2e/wiki_e2e.rsrenamed+1 -12
@@ -5,8 +5,7 @@
5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,5 //! Cookies are handled by hand because the session cookie is `__Host-forge_session` with `Secure`,
6 //! which a cookie jar would not send over plain http.6 //! which a cookie jar would not send over plain http.
7 7
8-mod common;8+use crate::common::{BIN, describe, input_value, launch, pick_ports, tool_on_path, write_config};
9-use common::{BIN, describe, launch, pick_ports, tool_on_path, write_config};
10 use std::fs;9 use std::fs;
11 use std::path::Path;10 use std::path::Path;
12 use std::process::{Command, Output};11 use std::process::{Command, Output};
@@ -98,16 +97,6 @@ fn cookie_named(resp: &Resp, suffix: &str) -> Option<String> {
98 }97 }
99 98
100 /// The value of the first `<input name="...">` on a page.99 /// The value of the first `<input name="...">` on a page.
101-fn input_value(body: &str, name: &str) -> String {
102- let doc = scraper::Html::parse_document(body);
103- let selector = scraper::Selector::parse(&format!("input[name=\"{name}\"]")).expect("selector");
104- doc.select(&selector)
105- .next()
106- .and_then(|el| el.value().attr("value"))
107- .unwrap_or_else(|| panic!("no input named {name} on page"))
108- .to_owned()
109-}
110-
111 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.100 /// Runs an admin subcommand with the password in FORGE_PASSWORD and asserts it succeeded.
112 fn admin(config: &Path, args: &[&str]) {101 fn admin(config: &Path, args: &[&str]) {
113 let out = Command::new(BIN)102 let out = Command::new(BIN)
docs/architecture.mdmodified+1 -1
@@ -479,7 +479,7 @@ Don't:
479 - Repo create with the ID-based path. Visibility, collaborators, archive flag.479 - Repo create with the ID-based path. Visibility, collaborators, archive flag.
480 - Smart HTTP (`info/refs`, upload-pack, receive-pack, gzip, streaming) and SSH (exec allow-list, `GIT_PROTOCOL`, piping, exit status).480 - Smart HTTP (`info/refs`, upload-pack, receive-pack, gzip, streaming) and SSH (exec allow-list, `GIT_PROTOCOL`, piping, exit status).
481 - Pre-receive policy (archived, default-branch delete and force-push, bad ref names) and post-receive `push_events`. Minimal UI: setup, login, dashboard, new repo, repo page, settings, admin users, `/healthz`.481 - Pre-receive policy (archived, default-branch delete and force-push, bad ref names) and post-receive `push_events`. Minimal UI: setup, login, dashboard, new repo, repo page, settings, admin users, `/healthz`.
482-- Tests: unit tests in core and git; end-to-end `git_e2e.rs` over HTTPS and SSH, with negative cases (bad token, cross-user private 404, forced default-branch push rejected, unknown SSH command rejected, traversal rejected, POST without CSRF rejected).482+- Tests: unit tests in core and git; end-to-end `tests/e2e/git_e2e.rs` over HTTPS and SSH, with negative cases (bad token, cross-user private 404, forced default-branch push rejected, unknown SSH command rejected, traversal rejected, POST without CSRF rejected).
483 483
484 ### Repo browsing and raw files484 ### Repo browsing and raw files
485 485