diff --git a/Cargo.lock b/Cargo.lock index fdf36837e..52689ea58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1268,6 +1268,7 @@ dependencies = [ "tracing", "tracing-subscriber", "uuid", + "web-sys", ] [[package]] diff --git a/libs/client-api-test-util/Cargo.toml b/libs/client-api-test-util/Cargo.toml index 9c8616e29..7e47e2001 100644 --- a/libs/client-api-test-util/Cargo.toml +++ b/libs/client-api-test-util/Cargo.toml @@ -29,4 +29,7 @@ uuid = "1.6.1" lazy_static = "1.4.0" dotenv = "0.15.0" reqwest = "0.11.23" -gotrue.workspace = true \ No newline at end of file +gotrue.workspace = true + +[target.'cfg(target_arch = "wasm32")'.dependencies] +web-sys = { version = "0.3", features = ["console"] } \ No newline at end of file diff --git a/libs/wasm-test/README.md b/libs/wasm-test/README.md new file mode 100644 index 000000000..830054f92 --- /dev/null +++ b/libs/wasm-test/README.md @@ -0,0 +1,25 @@ + +## Run test + +before running the test, it requires to install the [chrome driver](https://chromedriver.chromium.org/downloads). +for mac user, you can install it by brew. + +```shell +brew install chromedriver +``` + +then run the test + + +```shell +wasm-pack test --headless --chrome +``` + +## Testing in browser + +```shell +wasm-pack test --chrome +``` + +Ref: +[wasm-bindgen-test](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/browsers.html) \ No newline at end of file diff --git a/libs/wasm-test/tests/main.rs b/libs/wasm-test/tests/main.rs index 43b580d5e..404fc2df4 100644 --- a/libs/wasm-test/tests/main.rs +++ b/libs/wasm-test/tests/main.rs @@ -3,3 +3,6 @@ wasm_bindgen_test_configure!(run_in_browser); // #[cfg(target_arch = "wasm32")] // mod conn_test; + +#[cfg(target_arch = "wasm32")] +mod user_test; diff --git a/libs/wasm-test/tests/user_test.rs b/libs/wasm-test/tests/user_test.rs new file mode 100644 index 000000000..b0c1c05a3 --- /dev/null +++ b/libs/wasm-test/tests/user_test.rs @@ -0,0 +1,10 @@ +use client_api_test_util::{admin_user_client, generate_unique_email, localhost_client}; +use wasm_bindgen_test::wasm_bindgen_test; + +#[wasm_bindgen_test] +async fn sign_up_success() { + let email = generate_unique_email(); + let password = "Hello!123#"; + let c = localhost_client(); + c.sign_up(&email, password).await.unwrap(); +} diff --git a/src/middleware/cors_mw.rs b/src/middleware/cors_mw.rs index 00f7654b8..43659d54e 100644 --- a/src/middleware/cors_mw.rs +++ b/src/middleware/cors_mw.rs @@ -10,7 +10,10 @@ pub fn default_cors() -> Cors { .allow_any_origin() .send_wildcard() .allowed_methods(vec!["GET", "POST", "PUT", "DELETE"]) - .allowed_headers(vec![http::header::ACCEPT]) + .allowed_headers(vec![ + actix_web::http::header::AUTHORIZATION, + actix_web::http::header::ACCEPT, + ]) .allowed_header(http::header::CONTENT_TYPE) .max_age(3600) }