Files
mostovik-backend/tests/apps/parsers/test_dashboard_page.py
Aleksandr Meshchriakov 82ba7b78cd
Some checks failed
CI/CD Pipeline / Quality Gate (push) Failing after 9s
CI/CD Pipeline / Build and Push Images (push) Has been skipped
CI/CD Pipeline / Deploy Dev in Dokploy (push) Has been skipped
CI/CD Pipeline / Internal Notify (push) Successful in 0s
Add v2 registry uploads and source CSV exports
2026-05-07 14:39:20 +02:00

176 lines
8.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Regression tests for the standalone parser dashboard page."""
from django.test import TestCase
class ParserDashboardPageTest(TestCase):
def test_dashboard_exposes_login_and_registration_flows(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn('id="loginForm"', content)
self.assertIn('id="registerForm"', content)
self.assertIn("/api/v1/users/login/", content)
self.assertIn("/api/v1/users/register/", content)
def test_dashboard_does_not_drop_jwt_on_registers_panel_failure(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("refreshRegisters().catch(renderRegistersUnavailable)", content)
self.assertIn("isAuthError(error)", content)
def test_dashboard_has_group_fallback_for_current_api_shape(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("function sourceGroups()", content)
self.assertIn("dashboardData?.file_sources", content)
def test_dashboard_uses_vue_component_table_for_source_results(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("https://cdn.jsdelivr.net/npm/vue@3/", content)
self.assertIn("https://cdn.jsdelivr.net/npm/element-plus@2/", content)
self.assertIn('id="sourceRecordsApp"', content)
self.assertIn("<el-table", content)
self.assertIn("Обновляю данные без сброса таблицы", content)
def test_dashboard_does_not_send_limit_to_paginated_source_result_api(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("if (!source.result_list_url) {", content)
self.assertIn("query.limit = this.pageSize", content)
def test_dashboard_humanizes_schedules_and_registry_completeness(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("function humanizeSchedule", content)
self.assertIn("registryCompletenessChart", content)
self.assertIn("chart-grid-full", content)
self.assertIn("function registryDisplayName", content)
self.assertIn('data-main-tab="endpoints"', content)
self.assertIn("function buildEndpointCatalog", content)
self.assertIn("checkAllEndpointsButton", content)
self.assertIn("endpointCheckModal", content)
self.assertIn("data-toggle", content)
self.assertIn("iconButton", content)
def test_dashboard_prioritizes_registry_enrichment_analytics(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("analyticsRegistryKpis", content)
self.assertIn("registrySourceCoverageChart", content)
self.assertIn("registrySourceMatrix", content)
self.assertIn("enrichmentPipelinePanel", content)
self.assertIn("analyticsActionQueue", content)
self.assertIn("technicalSourceCounters", content)
self.assertIn("renderRegistryEnrichmentAnalytics", content)
self.assertIn("renderRegistrySourceMatrix", content)
self.assertIn("Организации из реестров", content)
self.assertIn("Pipeline обогащения", content)
self.assertIn('href="/swagger/"', content)
self.assertIn("REGISTRY_MATRIX_SOURCE_ORDER", content)
self.assertIn("table-layout: fixed", content)
self.assertIn("white-space: normal", content)
self.assertIn("overflow: visible", content)
self.assertIn('"procurements_223fz"', content)
self.assertIn('"contracts"', content)
def test_dashboard_endpoint_checker_uses_row_details_modal(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("latestEndpointResultMap", content)
self.assertIn("endpointCheckSummary", content)
self.assertIn("data-endpoint-run", content)
self.assertIn("data-endpoint-detail", content)
self.assertIn("showEndpointDetail", content)
self.assertIn("без данных", content)
def test_dashboard_has_organizations_tab_with_v2_search_and_registry_filter(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn('data-main-tab="organizations"', content)
self.assertIn('id="organizationsPanel"', content)
self.assertIn('id="organizationSearch"', content)
self.assertIn('id="organizationRegistryFilter"', content)
self.assertIn('id="organizationDataSourceFilter"', content)
self.assertIn('id="organizationRows"', content)
self.assertIn("/api/v2/organizations/", content)
self.assertIn("exclude_data", content)
self.assertIn("registry: organizationState.registry", content)
self.assertIn("dataSource: organizationState.dataSource", content)
def test_dashboard_organization_rows_open_source_picker_and_data_tables(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("organizationSourceModal", content)
self.assertIn("organizationDataPanel", content)
self.assertIn("data-organization-uid", content)
self.assertIn("openOrganizationSourcePicker", content)
self.assertIn("loadOrganizationDetail", content)
self.assertIn("renderOrganizationDataTables", content)
self.assertIn("renderFnsReportYearTabs", content)
self.assertIn("data-organization-source", content)
self.assertIn("organizationDataSourcesCell", content)
self.assertIn("organizationDisplayName", content)
self.assertIn("normalized_name", content)
self.assertIn("organizationSourceTabs", content)
self.assertIn("renderOrganizationSourceTabs", content)
self.assertIn("data-organization-data-tab", content)
self.assertIn("tableColumnLabel", content)
self.assertIn('"certificate_number": "Номер сертификата"', content)
self.assertIn("organizationRecordDetailModal", content)
self.assertIn("openOrganizationRecordDetail", content)
self.assertIn("data-organization-record-detail", content)
self.assertIn("renderFnsAccountingForm", content)
self.assertIn("Бухгалтерский баланс", content)
self.assertIn("I. Внеоборотные активы", content)
self.assertIn("fns-balance-grid", content)
self.assertIn("renderFnsBalanceSection", content)
self.assertIn('renderFnsBalanceSection(index, "Актив"', content)
self.assertIn('renderFnsBalanceSection(index, "Пассив"', content)
self.assertIn("fns-code-column", content)
self.assertIn("На конец</th>", content)
self.assertIn("На начало</th>", content)
self.assertIn("Покрытие доп. данными", content)
def test_dashboard_uses_v2_registry_upload_routes(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("REGISTRY_UPLOAD_SLUGS_BY_NAME", content)
self.assertIn("/api/v2/registers/${registrySlug}/upload/", content)
self.assertIn("/api/v2/registers/opk/upload/", content)
self.assertIn("registryUploadUrlForSelectedRegistry", content)
def test_dashboard_exposes_v2_source_csv_downloads(self):
response = self.client.get("/dashboard")
self.assertEqual(response.status_code, 200)
content = response.content.decode()
self.assertIn("function sourceCsvDownloadUrl", content)
self.assertIn("/api/v2/sources/${source.api_route}/download/", content)
self.assertIn("data-source-download", content)
self.assertIn("downloadSourceCsv", content)
self.assertIn("CSV", content)
self.assertNotIn("/api/v2/sources/fns/reports/download/", content)