Рефакторинг тестов: интеграция с задачами
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 57s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 57s
This commit is contained in:
@@ -4,8 +4,7 @@ import FullStatistics from './components/FullStatistics'
|
||||
import ProjectPriorityManager from './components/ProjectPriorityManager'
|
||||
import WordList from './components/WordList'
|
||||
import AddWords from './components/AddWords'
|
||||
import TestConfigSelection from './components/TestConfigSelection'
|
||||
import AddConfig from './components/AddConfig'
|
||||
import DictionaryList from './components/DictionaryList'
|
||||
import TestWords from './components/TestWords'
|
||||
import Profile from './components/Profile'
|
||||
import TaskList from './components/TaskList'
|
||||
@@ -24,8 +23,8 @@ const CURRENT_WEEK_API_URL = '/playlife-feed'
|
||||
const FULL_STATISTICS_API_URL = '/d2dc349a-0d13-49b2-a8f0-1ab094bfba9b'
|
||||
|
||||
// Определяем основные табы (без крестика) и глубокие табы (с крестиком)
|
||||
const mainTabs = ['current', 'test-config', 'tasks', 'wishlist', 'profile']
|
||||
const deepTabs = ['add-words', 'add-config', 'test', 'task-form', 'wishlist-form', 'wishlist-detail', 'words', 'todoist-integration', 'telegram-integration', 'full', 'priorities']
|
||||
const mainTabs = ['current', 'tasks', 'wishlist', 'profile']
|
||||
const deepTabs = ['add-words', 'test', 'task-form', 'wishlist-form', 'wishlist-detail', 'words', 'dictionaries', 'todoist-integration', 'telegram-integration', 'full', 'priorities']
|
||||
|
||||
function AppContent() {
|
||||
const { authFetch, isAuthenticated, loading: authLoading } = useAuth()
|
||||
@@ -51,8 +50,7 @@ function AppContent() {
|
||||
full: false,
|
||||
words: false,
|
||||
'add-words': false,
|
||||
'test-config': false,
|
||||
'add-config': false,
|
||||
dictionaries: false,
|
||||
test: false,
|
||||
tasks: false,
|
||||
'task-form': false,
|
||||
@@ -71,8 +69,7 @@ function AppContent() {
|
||||
full: false,
|
||||
words: false,
|
||||
'add-words': false,
|
||||
'test-config': false,
|
||||
'add-config': false,
|
||||
dictionaries: false,
|
||||
test: false,
|
||||
tasks: false,
|
||||
'task-form': false,
|
||||
@@ -113,7 +110,7 @@ function AppContent() {
|
||||
// Состояние для кнопки Refresh (если она есть)
|
||||
const [isRefreshing, setIsRefreshing] = useState(false)
|
||||
const [prioritiesRefreshTrigger, setPrioritiesRefreshTrigger] = useState(0)
|
||||
const [testConfigRefreshTrigger, setTestConfigRefreshTrigger] = useState(0)
|
||||
const [dictionariesRefreshTrigger, setDictionariesRefreshTrigger] = useState(0)
|
||||
const [wordsRefreshTrigger, setWordsRefreshTrigger] = useState(0)
|
||||
const [wishlistRefreshTrigger, setWishlistRefreshTrigger] = useState(0)
|
||||
|
||||
@@ -128,7 +125,7 @@ function AppContent() {
|
||||
// Проверяем URL только для глубоких табов
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const tabFromUrl = urlParams.get('tab')
|
||||
const validTabs = ['current', 'priorities', 'full', 'words', 'add-words', 'test-config', 'add-config', 'test', 'tasks', 'task-form', 'wishlist', 'wishlist-form', 'wishlist-detail', 'profile', 'todoist-integration', 'telegram-integration']
|
||||
const validTabs = ['current', 'priorities', 'full', 'words', 'add-words', 'dictionaries', 'test', 'tasks', 'task-form', 'wishlist', 'wishlist-form', 'wishlist-detail', 'profile', 'todoist-integration', 'telegram-integration']
|
||||
|
||||
if (tabFromUrl && validTabs.includes(tabFromUrl) && deepTabs.includes(tabFromUrl)) {
|
||||
// Если в URL есть глубокий таб, восстанавливаем его
|
||||
@@ -381,8 +378,7 @@ function AppContent() {
|
||||
full: false,
|
||||
words: false,
|
||||
'add-words': false,
|
||||
'test-config': false,
|
||||
'add-config': false,
|
||||
dictionaries: false,
|
||||
test: false,
|
||||
tasks: false,
|
||||
'task-form': false,
|
||||
@@ -452,17 +448,17 @@ function AppContent() {
|
||||
// Возврат на таб - фоновая загрузка
|
||||
setPrioritiesRefreshTrigger(prev => prev + 1)
|
||||
}
|
||||
} else if (tab === 'test-config') {
|
||||
const isInitialized = tabsInitializedRef.current['test-config']
|
||||
} else if (tab === 'dictionaries') {
|
||||
const isInitialized = tabsInitializedRef.current['dictionaries']
|
||||
|
||||
if (!isInitialized) {
|
||||
// Первая загрузка таба
|
||||
setTestConfigRefreshTrigger(prev => prev + 1)
|
||||
tabsInitializedRef.current['test-config'] = true
|
||||
setTabsInitialized(prev => ({ ...prev, 'test-config': true }))
|
||||
setDictionariesRefreshTrigger(prev => prev + 1)
|
||||
tabsInitializedRef.current['dictionaries'] = true
|
||||
setTabsInitialized(prev => ({ ...prev, 'dictionaries': true }))
|
||||
} else if (isBackground) {
|
||||
// Возврат на таб - фоновая загрузка
|
||||
setTestConfigRefreshTrigger(prev => prev + 1)
|
||||
setDictionariesRefreshTrigger(prev => prev + 1)
|
||||
}
|
||||
} else if (tab === 'tasks') {
|
||||
const hasCache = cacheRef.current.tasks !== null
|
||||
@@ -502,7 +498,7 @@ function AppContent() {
|
||||
// Обработчик кнопки "назад" в браузере (только для глубоких табов)
|
||||
useEffect(() => {
|
||||
const handlePopState = (event) => {
|
||||
const validTabs = ['current', 'priorities', 'full', 'words', 'add-words', 'test-config', 'add-config', 'test', 'tasks', 'task-form', 'wishlist', 'wishlist-form', 'wishlist-detail', 'profile', 'todoist-integration', 'telegram-integration']
|
||||
const validTabs = ['current', 'priorities', 'full', 'words', 'add-words', 'dictionaries', 'test', 'tasks', 'task-form', 'wishlist', 'wishlist-form', 'wishlist-detail', 'profile', 'todoist-integration', 'telegram-integration']
|
||||
|
||||
// Проверяем state текущей записи истории (куда мы вернулись)
|
||||
if (event.state && event.state.tab) {
|
||||
@@ -617,15 +613,7 @@ function AppContent() {
|
||||
const isCurrentTabMain = mainTabs.includes(activeTab)
|
||||
const isNewTabMain = mainTabs.includes(tab)
|
||||
|
||||
// Сбрасываем tabParams при переходе с add-config на другой таб
|
||||
if (activeTab === 'add-config' && tab !== 'add-config') {
|
||||
setTabParams({})
|
||||
if (isNewTabMain) {
|
||||
clearUrl()
|
||||
} else if (isNewTabDeep) {
|
||||
updateUrl(tab, {}, activeTab)
|
||||
}
|
||||
} else {
|
||||
{
|
||||
// Для task-form и wishlist-form явно удаляем параметры, только если нет никаких параметров
|
||||
// task-form может иметь taskId (редактирование) или wishlistId (создание из желания)
|
||||
const isTaskFormWithNoParams = tab === 'task-form' && params.taskId === undefined && params.wishlistId === undefined
|
||||
@@ -723,7 +711,7 @@ function AppContent() {
|
||||
}, [activeTab])
|
||||
|
||||
// Определяем, нужно ли скрывать нижнюю панель (для fullscreen экранов)
|
||||
const isFullscreenTab = activeTab === 'test' || activeTab === 'add-words' || activeTab === 'add-config' || activeTab === 'task-form' || activeTab === 'wishlist-form' || activeTab === 'wishlist-detail' || activeTab === 'todoist-integration' || activeTab === 'telegram-integration' || activeTab === 'full' || activeTab === 'priorities'
|
||||
const isFullscreenTab = activeTab === 'test' || activeTab === 'add-words' || activeTab === 'task-form' || activeTab === 'wishlist-form' || activeTab === 'wishlist-detail' || activeTab === 'todoist-integration' || activeTab === 'telegram-integration' || activeTab === 'full' || activeTab === 'priorities' || activeTab === 'dictionaries'
|
||||
|
||||
// Определяем отступы для контейнера
|
||||
const getContainerPadding = () => {
|
||||
@@ -818,21 +806,11 @@ function AppContent() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loadedTabs['test-config'] && (
|
||||
<div className={activeTab === 'test-config' ? 'block' : 'hidden'}>
|
||||
<TestConfigSelection
|
||||
{loadedTabs.dictionaries && (
|
||||
<div className={activeTab === 'dictionaries' ? 'block' : 'hidden'}>
|
||||
<DictionaryList
|
||||
onNavigate={handleNavigate}
|
||||
refreshTrigger={testConfigRefreshTrigger}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loadedTabs['add-config'] && (
|
||||
<div className={activeTab === 'add-config' ? 'block' : 'hidden'}>
|
||||
<AddConfig
|
||||
key={tabParams.config?.id || 'new'}
|
||||
onNavigate={handleNavigate}
|
||||
editingConfig={tabParams.config}
|
||||
refreshTrigger={dictionariesRefreshTrigger}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -844,6 +822,7 @@ function AppContent() {
|
||||
wordCount={tabParams.wordCount}
|
||||
configId={tabParams.configId}
|
||||
maxCards={tabParams.maxCards}
|
||||
taskId={tabParams.taskId}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -948,27 +927,6 @@ function AppContent() {
|
||||
<div className="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-indigo-500 to-purple-500"></div>
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('test-config')}
|
||||
className={`min-w-max whitespace-nowrap px-4 py-4 transition-all duration-300 relative ${
|
||||
activeTab === 'test-config' || activeTab === 'test'
|
||||
? 'text-indigo-700 bg-white/50'
|
||||
: 'text-gray-600 hover:text-indigo-600 hover:bg-white/30'
|
||||
}`}
|
||||
title="Тест"
|
||||
>
|
||||
<span className="relative z-10 flex items-center justify-center">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
|
||||
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
|
||||
<path d="M8 7h6"></path>
|
||||
<path d="M8 11h4"></path>
|
||||
</svg>
|
||||
</span>
|
||||
{(activeTab === 'test-config' || activeTab === 'test') && (
|
||||
<div className="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-indigo-500 to-purple-500"></div>
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('tasks')}
|
||||
className={`min-w-max whitespace-nowrap px-4 py-4 transition-all duration-300 relative ${
|
||||
|
||||
Reference in New Issue
Block a user