Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache: "npm"
cache-dependency-path: dashboard/package-lock.json
- name: Install dependencies
working-directory: dashboard
run: npm ci
Expand Down
94 changes: 61 additions & 33 deletions contract/contracts/hello-world/src/tests/autoshare_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,10 +1486,10 @@ fn test_create_fails_name_too_long() {
let creator = test_env.users.get(0).unwrap().clone();
let token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);

// Create a very long name (over 100 characters)
let long_name = String::from_str(&test_env.env, "a".repeat(101).as_str());

crate::test_utils::mint_tokens(&test_env.env, &token, &creator, 10000000);
client.create(&id, &long_name, &creator, &10u32, &token);
}
Expand All @@ -1504,7 +1504,7 @@ fn test_create_fails_invalid_usage_count_zero() {
let token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);
let name = String::from_str(&test_env.env, "Test Group");

crate::test_utils::mint_tokens(&test_env.env, &token, &creator, 10000000);
client.create(&id, &name, &creator, &0u32, &token);
}
Expand All @@ -1518,14 +1518,14 @@ fn test_create_fails_unsupported_token() {
let creator = test_env.users.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);
let name = String::from_str(&test_env.env, "Test Group");

// Create an unsupported token (not added to supported tokens)
let unsupported_token = test_utils::deploy_mock_token(
&test_env.env,
&String::from_str(&test_env.env, "Unsupported"),
&String::from_str(&test_env.env, "UNSUP")
let unsupported_token = crate::test_utils::deploy_mock_token(
&test_env.env,
&String::from_str(&test_env.env, "Unsupported"),
&String::from_str(&test_env.env, "UNSUP"),
);

crate::test_utils::mint_tokens(&test_env.env, &unsupported_token, &creator, 10000000);
client.create(&id, &name, &creator, &10u32, &unsupported_token);
}
Expand All @@ -1539,10 +1539,17 @@ fn test_topup_fails_invalid_usage_count_zero() {
let creator = test_env.users.get(0).unwrap().clone();
let token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);

let members = Vec::new(&test_env.env);
create_test_group(&test_env.env, &test_env.autoshare_contract, &creator, &members, 10, &token);

create_test_group(
&test_env.env,
&test_env.autoshare_contract,
&creator,
&members,
10,
&token,
);

client.topup_subscription(&id, &0u32, &token, &creator);
}

Expand All @@ -1555,17 +1562,24 @@ fn test_topup_fails_unsupported_token() {
let creator = test_env.users.get(0).unwrap().clone();
let supported_token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);

let members = Vec::new(&test_env.env);
create_test_group(&test_env.env, &test_env.autoshare_contract, &creator, &members, 10, &supported_token);

create_test_group(
&test_env.env,
&test_env.autoshare_contract,
&creator,
&members,
10,
&supported_token,
);

// Create an unsupported token
let unsupported_token = test_utils::deploy_mock_token(
&test_env.env,
&String::from_str(&test_env.env, "Unsupported"),
&String::from_str(&test_env.env, "UNSUP")
let unsupported_token = crate::test_utils::deploy_mock_token(
&test_env.env,
&String::from_str(&test_env.env, "Unsupported"),
&String::from_str(&test_env.env, "UNSUP"),
);

crate::test_utils::mint_tokens(&test_env.env, &unsupported_token, &creator, 10000000);
client.topup_subscription(&id, &10u32, &unsupported_token, &creator);
}
Expand All @@ -1579,13 +1593,20 @@ fn test_reduce_usage_fails_no_usages_remaining() {
let creator = test_env.users.get(0).unwrap().clone();
let token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);

let members = Vec::new(&test_env.env);
create_test_group(&test_env.env, &test_env.autoshare_contract, &creator, &members, 1, &token);

create_test_group(
&test_env.env,
&test_env.autoshare_contract,
&creator,
&members,
1,
&token,
);

// Reduce once (should work)
client.reduce_usage(&id);

// Reduce again (should panic)
client.reduce_usage(&id);
}
Expand All @@ -1600,7 +1621,7 @@ fn test_set_usage_fee_fails_zero() {

let admin = Address::generate(&env);
client.initialize_admin(&admin);

client.set_usage_fee(&0u32, &admin);
}

Expand All @@ -1614,7 +1635,7 @@ fn test_add_supported_token_fails_already_exists() {

let admin = Address::generate(&env);
client.initialize_admin(&admin);

let token_id = env.register(MockToken, ());
let token_client = MockTokenClient::new(&env, &token_id);
token_client.initialize(
Expand All @@ -1623,7 +1644,7 @@ fn test_add_supported_token_fails_already_exists() {
&String::from_str(&env, "Test Token"),
&String::from_str(&env, "TST"),
);

// Add once
client.add_supported_token(&token_id, &admin);
// Add again (should panic)
Expand All @@ -1640,7 +1661,7 @@ fn test_remove_supported_token_fails_not_found() {

let admin = Address::generate(&env);
client.initialize_admin(&admin);

let token_id = env.register(MockToken, ());
let token_client = MockTokenClient::new(&env, &token_id);
token_client.initialize(
Expand All @@ -1649,7 +1670,7 @@ fn test_remove_supported_token_fails_not_found() {
&String::from_str(&env, "Test Token"),
&String::from_str(&env, "TST"),
);

// Try to remove a token that was never added
client.remove_supported_token(&token_id, &admin);
}
Expand All @@ -1663,11 +1684,18 @@ fn test_update_members_fails_too_many() {
let creator = test_env.users.get(0).unwrap().clone();
let token = test_env.mock_tokens.get(0).unwrap().clone();
let id = BytesN::from_array(&test_env.env, &[1u8; 32]);

// Create group first
let initial_members = Vec::new(&test_env.env);
create_test_group(&test_env.env, &test_env.autoshare_contract, &creator, &initial_members, 10, &token);

create_test_group(
&test_env.env,
&test_env.autoshare_contract,
&creator,
&initial_members,
10,
&token,
);

// Create 51 members (MAX_MEMBERS is 50)
let mut too_many_members = Vec::new(&test_env.env);
for _ in 0..51 {
Expand All @@ -1676,7 +1704,7 @@ fn test_update_members_fails_too_many() {
percentage: 1, // This will sum to 51, but first check is TooManyMembers
});
}

client.update_members(&id, &creator, &too_many_members);
}

Expand Down
10 changes: 4 additions & 6 deletions dashboard/src/components/EventFiltersBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { memo } from 'react';
import { useEventStore } from '../store/eventStore';
import { useEventCount, useEventFilters, useFilterOptions } from '../hooks/useEventSelectors';
import { SearchAutocomplete } from './SearchAutocomplete';

export const EventFiltersBar = memo(function EventFiltersBar() {
const filters = useEventFilters();
Expand All @@ -14,12 +15,9 @@ export const EventFiltersBar = memo(function EventFiltersBar() {
<section className="event-filters" aria-label="Event filters">
<div className="event-filters__group">
<label htmlFor="event-search">Search</label>
<input
id="event-search"
type="search"
placeholder="Search events..."
value={filters.search}
onChange={(event) => setSearch(event.target.value)}
<SearchAutocomplete
value={filters.search}
onChange={(value) => setSearch(value)}
/>
</div>

Expand Down
Loading
Loading