Merge branch 'test' into dkr
This commit is contained in:
commit
29cf9b2a14
218 files changed
+2036
-180
No files matched your search
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Результаты тестов:</h2>
|
||||
|
||||
<!-- Общее состояние тестов -->
|
||||
<div v-if="results.success" class="success">✅ Все тесты успешно пройдены!</div>
|
||||
<div v-else-if="results.numFailedTestSuites > 0" class="error">
|
||||
❌ Ошибки в тестах: {{ results.numFailedTestSuites }} из {{ results.numTotalTestSuites }}
|
||||
</div>
|
||||
|
||||
<!-- Сводная информация -->
|
||||
<div v-if="results.testResults" class="summary">
|
||||
<h3>Сводка по тестам:</h3>
|
||||
<ul>
|
||||
<li><strong>Общее количество тестов:</strong> {{ results.numTotalTests }}</li>
|
||||
<li>
|
||||
<strong>Пройдено:</strong> {{ results.numPassedTests }} ({{
|
||||
getPercentage(results.numPassedTests, results.numTotalTests)
|
||||
}}%)
|
||||
</li>
|
||||
<li>
|
||||
<strong>Неудачных:</strong> {{ results.numFailedTests }} ({{
|
||||
getPercentage(results.numFailedTests, results.numTotalTests)
|
||||
}}%)
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Список успешных тестов -->
|
||||
<div v-if="passedTests.length">
|
||||
<h3>Успешные тесты:</h3>
|
||||
<ul>
|
||||
<li v-for="test in passedTests" :key="test.fullName">
|
||||
<strong>{{ test.fullName }}</strong> ✅ ({{ test.duration }} мс)
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Список неудачных тестов -->
|
||||
<div v-if="failedTests.length">
|
||||
<h3>Неудачные тесты:</h3>
|
||||
<ul>
|
||||
<li v-for="(test, index) in failedTests" :key="test.fullName">
|
||||
<strong>{{ test.fullName }}</strong> ❌ ({{ test.duration }} мс)
|
||||
<pre v-if="test.failureMessages.length" class="error-log">
|
||||
<button @click="toggleError(index)" class="error-toggle-btn">
|
||||
{{ isErrorVisible(index) ? 'Скрыть ошибки' : 'Показать ошибки' }}
|
||||
</button>
|
||||
<div v-if="isErrorVisible(index)">
|
||||
<strong>Ожидалось:</strong> {{ extractTestValue(test.failureMessages, 'Expected') }}
|
||||
<strong>Получено:</strong> {{ extractTestValue(test.failureMessages, 'Received') }}
|
||||
</div>
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
|
||||
const results = ref({});
|
||||
const errorMessage = ref('');
|
||||
const errorVisibility = ref({});
|
||||
|
||||
const toggleError = (index) => {
|
||||
errorVisibility.value[index] = !errorVisibility.value[index];
|
||||
};
|
||||
|
||||
const isErrorVisible = (index) => {
|
||||
return !!errorVisibility.value[index];
|
||||
};
|
||||
|
||||
const getPercentage = (num, total) => {
|
||||
return ((num / total) * 100).toFixed(2);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await fetch('/test-results.json');
|
||||
const data = await response.json();
|
||||
results.value = data;
|
||||
|
||||
if (!data.success) {
|
||||
errorMessage.value = data.testResults
|
||||
.map((t) => (t.failureMessages ? t.failureMessages.join('\n') : ''))
|
||||
.join('\n\n');
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage.value = error;
|
||||
}
|
||||
});
|
||||
|
||||
const passedTests = computed(() => {
|
||||
return (
|
||||
results.value?.testResults?.flatMap((testSuite) =>
|
||||
testSuite.assertionResults
|
||||
?.filter((test) => test.status === 'passed')
|
||||
.map((test) => ({
|
||||
...test,
|
||||
failureMessages: test.failureMessages || [],
|
||||
})),
|
||||
) || []
|
||||
);
|
||||
});
|
||||
|
||||
const failedTests = computed(() => {
|
||||
return (
|
||||
results.value?.testResults?.flatMap((testSuite) =>
|
||||
testSuite.assertionResults
|
||||
?.filter((test) => test.status === 'failed')
|
||||
.map((test) => ({
|
||||
...test,
|
||||
failureMessages: test.failureMessages || [],
|
||||
})),
|
||||
) || []
|
||||
);
|
||||
});
|
||||
|
||||
// Очистка от лишних данных и ANSI кодов
|
||||
/* eslint-disable no-control-regex */
|
||||
const cleanTestMessage = (message) => {
|
||||
return message.replace(/[\x1b][[0-?9;]*[mG]/g, '').trim();
|
||||
};
|
||||
/* eslint-enable no-control-regex */
|
||||
|
||||
// Универсальная функция для извлечения данных из сообщений
|
||||
const extractTestValue = (messages, type) => {
|
||||
const failureMessage = messages.find((msg) => msg.includes(type + ':'));
|
||||
if (failureMessage) {
|
||||
const match = failureMessage.match(new RegExp(`${type}: (.*)`));
|
||||
if (match) {
|
||||
return cleanTestMessage(match[1]);
|
||||
}
|
||||
}
|
||||
return 'Не указано';
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.success {
|
||||
color: green;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.warning {
|
||||
color: orange;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.error-log {
|
||||
background: rgba(255, 221, 221, 0.1);
|
||||
border-left: 4px solid red;
|
||||
padding: 5px;
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.error-toggle-btn {
|
||||
background-color: #ff6347;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 5px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.error-toggle-btn:hover {
|
||||
background-color: #ff4500;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,19 @@
|
||||
import DefaultTheme from 'vitepress/theme';
|
||||
import { withMermaid } from 'vitepress-plugin-mermaid';
|
||||
import TestRunner from './components/TestRunner.vue';
|
||||
|
||||
export default withMermaid({
|
||||
...DefaultTheme,
|
||||
themeConfig: {
|
||||
search: {
|
||||
provider: 'local',
|
||||
},
|
||||
},
|
||||
mermaid: {},
|
||||
mermaidPlugin: {
|
||||
class: 'mermaid my-class',
|
||||
},
|
||||
enhanceApp({ app }) {
|
||||
app.component('TestRunner', TestRunner);
|
||||
},
|
||||
});
|
||||
+15
-13
@@ -4,22 +4,24 @@ layout: home
|
||||
|
||||
hero:
|
||||
name: "Портал"
|
||||
text: "Документация по проекту"
|
||||
tagline: My great project tagline
|
||||
text: "Документация по порталу"
|
||||
actions:
|
||||
- theme: brand
|
||||
text: Markdown Examples
|
||||
link: /markdown-examples
|
||||
- theme: alt
|
||||
text: API Examples
|
||||
link: /api-examples
|
||||
text: Документация
|
||||
link: /README
|
||||
|
||||
features:
|
||||
- title: Feature A
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
- title: Feature B
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
- title: Feature C
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
- title: Инструкция
|
||||
details: Подробная инструкция по установке
|
||||
link: /guides/install
|
||||
- title: Инструкция по ведению и заполнению
|
||||
details: Подробная инструкция по ведению и заполнению
|
||||
link: /guides/usage
|
||||
- title: Правила коммитов
|
||||
details: Подробная инструкция по наименованию коммитов
|
||||
link: /guides/commits
|
||||
- title: Тестирование проекта
|
||||
details: Запуск автотестов
|
||||
link: /tests
|
||||
---
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# infoUserCard
|
||||
|
||||
## Описание пропсов
|
||||
|
||||
| Пропс | Тип | Значение по умолчанию | Комментарий |
|
||||
|-------|-----|-----------------------|-------------|
|
||||
| `opendialog` | `Boolean` | `false` | нет комментария |
|
||||
| `author` | `Object` | `{` | нет комментария |
|
||||
|
||||
|
||||
## Пример использования
|
||||
|
||||
```vue
|
||||
import infoUserCard from '@/components/components\UI\fiousercard\infoUserCard';
|
||||
```
|
||||
|
||||
```vue
|
||||
<infoUserCard />
|
||||
```
|
||||
|
||||
---
|
||||
> Документация сгенерирована автоматически.
|
||||
@@ -0,0 +1,25 @@
|
||||
# VoteAdmin
|
||||
|
||||
### <v-card-title>Голосование</v-card-title>
|
||||
|
||||
## Описание пропсов
|
||||
|
||||
| Пропс | Тип | Значение по умолчанию | Комментарий |
|
||||
|-------|-----|-----------------------|-------------|
|
||||
| `usersvotedbest` | `Array` | `()=>[]` | нет комментария |
|
||||
| `uservotedthanks` | `Array` | `()=>[]` | нет комментария |
|
||||
| `all_cod` | `Array` | `()=>[]` | нет комментария |
|
||||
|
||||
|
||||
## Пример использования
|
||||
|
||||
```vue
|
||||
import VoteAdmin from '@/components/components\vote\VoteAdmin';
|
||||
```
|
||||
|
||||
```vue
|
||||
<VoteAdmin />
|
||||
```
|
||||
|
||||
---
|
||||
> Документация сгенерирована автоматически.
|
||||
@@ -0,0 +1,22 @@
|
||||
# VoteCard
|
||||
|
||||
## Описание пропсов
|
||||
|
||||
| Пропс | Тип | Значение по умолчанию | Комментарий |
|
||||
|-------|-----|-----------------------|-------------|
|
||||
| `isFinished` | `Boolean` | `false` | нет комментария |
|
||||
| `voteCard` | `Object` | `() => {` | нет комментария |
|
||||
|
||||
|
||||
## Пример использования
|
||||
|
||||
```vue
|
||||
import VoteCard from '@/components/components\vote\VoteCard';
|
||||
```
|
||||
|
||||
```vue
|
||||
<VoteCard />
|
||||
```
|
||||
|
||||
---
|
||||
> Документация сгенерирована автоматически.
|
||||
@@ -0,0 +1,25 @@
|
||||
# VoteForm
|
||||
|
||||
### Форма голосования
|
||||
|
||||
## Описание пропсов
|
||||
|
||||
| Пропс | Тип | Значение по умолчанию | Комментарий |
|
||||
|-------|-----|-----------------------|-------------|
|
||||
| `type_fetch` | `String` | `'best'` | нет комментария |
|
||||
| `persons` | `Array` | `() => []` | нет комментария |
|
||||
| `myrealdep` | `Object` | `() => {` | нет комментария |
|
||||
|
||||
|
||||
## Пример использования
|
||||
|
||||
```vue
|
||||
import VoteForm from '@/components/components\vote\VoteForm';
|
||||
```
|
||||
|
||||
```vue
|
||||
<VoteForm />
|
||||
```
|
||||
|
||||
---
|
||||
> Документация сгенерирована автоматически.
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
# Тестирование
|
||||
|
||||
<ClientOnly>
|
||||
<TestRunner />
|
||||
</ClientOnly>
|
||||
|
||||
Reference in new issue
Block a user