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
12 changes: 8 additions & 4 deletions backend/app/modules/admin/io/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from app.modules.events.models import Event
from app.modules.fields.models import Field
from app.modules.tags.crud import get_or_create_tags
from app.modules.tags.models import Tag
from app.shared.models import EventField, EventTag
from app.shared.service import assert_db_empty
Expand Down Expand Up @@ -82,14 +81,19 @@ def import_bundle(bundle: ImportBundle, db: Session):
example=field_data.example,
)
db.add(field)
db.flush() # Ensures ID is available before linking
db.flush()
field_map[field.name] = field

all_tag_ids = {tag.id for tag in bundle.tags}
tag_definitions = {tag.id: tag for tag in bundle.tags}

all_tag_ids = set(tag_definitions.keys())
for event in bundle.events:
all_tag_ids.update(event.tags)

_ = get_or_create_tags(db, list(all_tag_ids))
for tag_id in all_tag_ids:
tag_def = tag_definitions.get(tag_id)
db.add(Tag(id=tag_id, description=tag_def.description if tag_def else None))

db.flush()

for event_data in bundle.events:
Expand Down
9 changes: 4 additions & 5 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
]
license = "MIT"
readme = "README.md"
requires-python = ">=3.9,<4"
requires-python = ">=3.10,<4"
dependencies = [
"fastapi[all] (>=0.115.12,<0.116.0)",
"sqlalchemy (>=2.0.40,<3.0.0)",
Expand Down
53 changes: 36 additions & 17 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,36 @@
from app.modules.auth.token import create_access_token
from app.settings import Settings

# Load test settings from .env.test
test_settings = Settings(_env_file=".env.test")

# Initialize DB objects for test (engine + SessionLocal)
test_engine, TestingSessionLocal = init_db(test_settings)
@pytest.fixture(scope="session")
def test_settings():
"""Session-scoped fixture for test settings, using a file-based SQLite DB."""
settings = Settings(_env_file=".env.test")
settings.database_url = "sqlite:///./test.db"
return settings


# Create the test app
app = create_app(test_settings, TestingSessionLocal)
@pytest.fixture(scope="session")
def db_engine_session(test_settings: Settings):
"""Session-scoped fixture for the database engine and session factory."""
engine, session_local = init_db(test_settings)
return engine, session_local


# Override FastAPI's get_db dependency
@pytest.fixture(scope="session")
def override_get_db():
def app(test_settings: Settings, db_engine_session):
"""Session-scoped fixture for the FastAPI application instance."""
_, session_local = db_engine_session
return create_app(test_settings, session_local)


@pytest.fixture(scope="session")
def override_get_db(db_engine_session):
"""Session-scoped fixture to override the `get_db` dependency."""
_, session_local = db_engine_session

def _override_get_db():
db: Session = TestingSessionLocal()
db: Session = session_local()
try:
yield db
finally:
Expand All @@ -32,13 +47,16 @@ def _override_get_db():
return _override_get_db


# Set up and tear down the database
@pytest.fixture(scope="session", autouse=True)
def setup_database(override_get_db):
Base.metadata.create_all(bind=test_engine)
def setup_database(app, db_engine_session, override_get_db):
"""
Session-scoped, autouse fixture to set up the database schema and dependency overrides.
"""
engine, _ = db_engine_session
Base.metadata.create_all(bind=engine)
app.dependency_overrides[get_db] = override_get_db
yield
Base.metadata.drop_all(bind=test_engine)
Base.metadata.drop_all(bind=engine)


@pytest.fixture(scope="session")
Expand All @@ -56,19 +74,20 @@ def test_user(override_get_db):

@pytest.fixture(scope="session")
def access_token(test_user):
"""Create an access token for the test user."""
return create_access_token({"sub": str(test_user.email)})


# FastAPI test client
@pytest.fixture(scope="module")
def client():
def client(app):
"""Module-scoped test client for unauthenticated requests."""
with TestClient(app) as c:
yield c


@pytest.fixture
def auth_client(access_token):
# Create a fresh client for authenticated requests to avoid polluting the shared client
def auth_client(app, access_token):
"""Function-scoped test client for authenticated requests."""
with TestClient(app) as auth_client:
auth_client.headers.update({"Authorization": f"Bearer {access_token}"})
yield auth_client
1 change: 0 additions & 1 deletion backend/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@pytest.fixture
def sample_event():
"""Тестовое событие"""
return EventCreate(
name="Test Event",
description="Some event description.",
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/modules/auth/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ const onSubmit = handleSubmit(values => runLogin(values))
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input type="email" placeholder="name@example.com" v-bind="componentField" />
<Input
type="email"
placeholder="name@example.com"
v-bind="componentField"
autocomplete="email"
/>
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -76,7 +81,7 @@ const onSubmit = handleSubmit(values => runLogin(values))
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input type="password" v-bind="componentField" />
<Input type="password" v-bind="componentField" autocomplete="current-password" />
</FormControl>
<FormMessage />
</FormItem>
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/modules/auth/components/SignupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ const onSubmit = handleSubmit(values => runSignup(values))
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input type="email" placeholder="name@example.com" v-bind="componentField" />
<Input
type="email"
placeholder="name@example.com"
v-bind="componentField"
autocomplete="email"
/>
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -79,7 +84,7 @@ const onSubmit = handleSubmit(values => runSignup(values))
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input type="password" v-bind="componentField" />
<Input type="password" v-bind="componentField" autocomplete="new-password" />
</FormControl>
<FormMessage />
</FormItem>
Expand Down
17 changes: 1 addition & 16 deletions frontend/src/modules/switchboard/components/ResetPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ import { Button } from '@/shared/ui/button'
import { useEnhancedToast } from '@/shared/composables/useEnhancedToast'
import type { ResetPreview } from '../types'
import { Badge } from '@/shared/ui/badge'
import { Icon } from '@iconify/vue'

const queryClient = useQueryClient()
const { showSuccess } = useEnhancedToast()

const {
data: preview,
isLoading: isFetching,
refetch: fetchPreview,
} = useQuery({
const { data: preview } = useQuery({
queryKey: ['resetPreview'],
queryFn: () => resetDatabase(true),
select: data => (data as ResetPreview).would_delete,
Expand Down Expand Up @@ -57,16 +52,6 @@ const { mutate: handleReset, isPending: isResetting } = useMutation({
<span v-if="preview" :key="preview.tags">{{ preview.tags }} tags</span>
</Transition>
</Badge>
<Button
variant="ghost"
size="icon"
:disabled="isFetching"
@click="fetchPreview"
title="Refresh counts"
>
<Icon v-if="isFetching" icon="radix-icons:reload" class="h-4 w-4 animate-spin" />
<Icon v-else icon="radix-icons:reload" class="h-4 w-4" />
</Button>
</div>
</div>
</template>
Expand Down
38 changes: 0 additions & 38 deletions frontend/src/shared/composables/useAsyncTask.ts

This file was deleted.

Loading