Открыть боковую панель
Медведев Антон Павлович
universo-phaser
Коммиты
1e66c3a3
Коммит
1e66c3a3
создал
Мар 04, 2024
по автору
Медведев Антон Павлович
Просмотр файлов
Слияние ветки 'develop' с 'develop'
Develop Посмотреть запрос на слияние
!4
владельцы
64371028
707e13c3
Конвейер
#7962
неудачно с этапами
Изменения
9
Конвейеры
1
Скрыть пробелы
Построчно
Рядом
babel.config.cjs
Просмотр файла @
1e66c3a3
/* eslint-disable */
module
.
exports
=
(
api
)
=>
{
return
{
presets
:
[
[
'
@quasar/babel-preset-app
'
,
api
.
caller
((
caller
)
=>
caller
&&
caller
.
target
===
'
node
'
)
?
{
targets
:
{
node
:
'
current
'
}
}
:
{},
],
const
isTest
=
api
.
env
(
'
test
'
);
const
presets
=
[
[
'
@quasar/babel-preset-app
'
,
isTest
?
{
targets
:
{
node
:
'
current
'
}
}
:
{},
],
};
];
if
(
isTest
)
{
// Дополнительные настройки или пресеты для тестирования
presets
.
push
([
'
@babel/preset-env
'
,
{
targets
:
{
node
:
'
current
'
}
}]);
}
return
{
presets
};
};
jest.config.mjs
Просмотр файла @
1e66c3a3
...
...
@@ -12,13 +12,17 @@ export default {
// statements: 50
// },
// },
testMatch
:
[
'
**/__tests__/**/*.+(ts|tsx|js)
'
,
'
**/?(*.)+(spec|test).+(ts|tsx|js)
'
,
],
transform
:
{
[
`^(
${
quasarEsModulesPackageNames
}
).+\\.js$`
]:
'
babel-jest
'
,
'
^.+
\\
.vue$
'
:
'
@vue/vue3-jest
'
,
'
^.+
\\
.(ts|js|html)$
'
:
[
'
ts-jest
'
,
{
// Remove if using `const enums`
// See https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules/
isolatedModules
:
true
,
},
],
...
...
package-lock.json
Просмотр файла @
1e66c3a3
...
...
@@ -15,6 +15,8 @@
"axios": "^1.6.7",
"core-js": "^3.36.0",
"dotenv": "^16.4.5",
"cross-fetch": "^4.0.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"phaser": "^3.80.1",
"phaser3-rex-plugins": "github:rexrainbow/phaser3-rex-notes",
...
...
@@ -33,9 +35,9 @@
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vue/test-utils": "^2.4.4",
"eslint": "^8.5
7
.0",
"eslint-config-prettier": "^9.
1
.0",
"eslint-plugin-vue": "^9.
22.0
",
"eslint": "^8.5
4
.0",
"eslint-config-prettier": "^9.
0
.0",
"eslint-plugin-vue": "^9.
18.1
",
"jest": "^29.7.0",
"prettier": "^3.2.5"
},
...
...
@@ -8229,6 +8231,12 @@
"node": ">=0.4.0"
}
},
"node_modules/flush-promises": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/flush-promises/-/flush-promises-1.0.2.tgz",
"integrity": "sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA==",
"dev": true
},
"node_modules/follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
...
...
src/components/colorSelector.vue
Просмотр файла @
1e66c3a3
<
template
>
<div
class=
'color-selector'
>
<q-btn
dense
>
<q-avatar
size=
"42px"
rounded
>
<img
src=
"phaser/editicon_880x881.png"
width=
"48px"
/>
<q-menu
persistent
auto-close
>
<q-list
style=
"min-width: 100px"
>
<q-item
clickable
v-for=
"(colorkey, colorvalue) in colors"
:key=
'colorvalue'
@
click=
'changeColor(colorkey)'
>
<q-item-section>
<div
class=
'color'
:style=
'
{ background: colorkey }'>
<q-tooltip>
{{
colorvalue
}}
</q-tooltip>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-avatar>
</q-btn>
<div
class=
"color-selector"
>
<q-avatar
class=
"toolbar-button"
text-color=
"black"
color=
"white"
icon=
"menu_open"
square
size=
"48px"
font-size=
"36px"
>
<q-menu
persistent
>
<q-list
style=
"min-width: 100px"
>
<q-item
clickable
>
<q-item-section
top
avatar
>
<q-avatar
square
>
<img
src=
"phaser/editicon_880x881.png"
width=
"48px"
/>
</q-avatar>
</q-item-section>
<q-item-section>
<q-item-label>
Цвет фона
</q-item-label>
</q-item-section>
<q-item-section
side
>
<q-icon
name=
"chevron_right"
color=
"black"
/>
</q-item-section>
<q-menu>
<q-list
style=
"min-width: 100px"
>
<q-separator
/>
<q-item
clickable
v-for=
"(colorCode, colorName) in colors"
:key=
"colorName"
@
click=
"changeColor(colorCode)"
class=
"color-item"
>
<q-item-section
avatar
>
<div
class=
"color"
:style=
"
{ background: colorCode }">
</div>
</q-item-section>
<q-item-section
class=
"color-name"
>
{{
colorName
}}
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-item>
</q-list>
</q-menu>
</q-avatar>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
usePhaserStore
}
from
'
../stores/phaserStore
'
;
import
{
useUiStore
}
from
'
../stores/UI
'
;
import
{
mapState
,
mapActions
}
from
'
pinia
'
;
export
default
defineComponent
({
name
:
'
colorSelector
'
,
data
()
{
return
{
colors
:
{
red
:
'
#ff0000
'
,
красный
:
'
#ff0000
'
,
green
:
'
#00ff00
'
,
blue
:
'
#0000ff
'
,
tomato
:
'
#f36
'
,
...
...
@@ -108,12 +126,31 @@ export default defineComponent({
gap
:
1px
;
pointer-events
:
initial
;
height
:
100%
;
}
.color-item
{
display
:
flex
;
align-items
:
center
;
}
.color
{
width
:
8px
;
height
:
100%
;
width
:
20px
;
/* Установленный размер для круга */
height
:
20px
;
/* Установленный размер для круга */
border-radius
:
50%
;
/* Делает элемент круглым */
cursor
:
pointer
;
display
:
inline-block
;
}
.color-name
{
margin-left
:
-20px
;
/* Расстояние между цветом и его названием */
display
:
inline-block
;
}
.toolbar-button
{
border-radius
:
5px
;
}
</
style
>
test/jest/__tests__/LoginPage.spec.ts
Просмотр файла @
1e66c3a3
...
...
@@ -67,13 +67,22 @@ describe('LoginPage.vue', () => {
);
});
it
(
'
Наличи регистрации
'
,
()
=>
{
it
(
'
Наличи регистрации
'
,
async
()
=>
{
await
router
.
isReady
();
console
.
log
(
wrapper
.
html
());
const
registrationLink
=
wrapper
.
findComponent
({
name
:
'
RouterLink
'
,
props
:
{
to
:
{
name
:
'
registration
'
}
},
});
expect
(
registrationLink
.
exists
()).
toBeTruthy
();
await
registrationLink
.
trigger
(
'
click
'
);
// Дожидаемся, чтобы Vue Router обработал переход
await
wrapper
.
vm
.
$nextTick
();
console
.
log
(
router
.
currentRoute
.
value
.
name
);
expect
(
router
.
currentRoute
.
value
.
name
).
toBe
(
'
start
'
);
});
it
(
'
проверка текста "Не удается войти?"
'
,
()
=>
{
...
...
test/jest/__tests__/RegForm.spec.ts
0 → 100644
Просмотр файла @
1e66c3a3
import
RegForm
from
'
../../../src/components/RegForm.vue
'
;
import
{
describe
,
it
,
expect
,
jest
,
beforeEach
}
from
'
@jest/globals
'
;
import
{
createRouter
,
createWebHistory
}
from
'
vue-router
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
Quasar
,
QLayout
,
QPageContainer
,
QPage
}
from
'
quasar
'
;
import
routes
from
'
../../../src/router/routes
'
;
import
{
createPinia
,
defineStore
}
from
'
pinia
'
;
jest
.
mock
(
'
src/boot/apollo
'
,
()
=>
({
apollo
:
{
default
:
{
query
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
// Возвращаем промис с пустыми данными
mutate
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
},
},
}));
const
router
=
createRouter
({
history
:
createWebHistory
(
process
.
env
.
BASE_URL
),
routes
,
});
const
pinia
=
createPinia
();
describe
(
'
RegForm
'
,
()
=>
{
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
mount
(
RegForm
,
{
global
:
{
plugins
:
[
Quasar
,
router
,
pinia
],
},
});
});
it
(
'
renders input fields for name, last name, username, and passwords
'
,
async
()
=>
{
expect
(
wrapper
.
find
(
'
#first_name
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
#last_name
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
#username
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
input[type="password"]
'
).
exists
()).
toBe
(
true
);
// Adjust if you have specific selectors for password fields
// Add more assertions as needed
});
it
(
'
renders selects for gender and language
'
,
()
=>
{
const
wrapper
=
mount
(
RegForm
);
expect
(
wrapper
.
findAll
(
'
select
'
).
length
).
toBe
(
2
);
// Пол и язык
});
// Проверка наличия кнопки регистрации
it
(
'
renders a submit button
'
,
()
=>
{
const
wrapper
=
mount
(
RegForm
);
expect
(
wrapper
.
find
(
'
button[type="submit"]
'
).
exists
()).
toBeTruthy
();
});
// Проверка наличия контейнера капчи
it
(
'
renders a captcha container
'
,
()
=>
{
const
wrapper
=
mount
(
RegForm
);
expect
(
wrapper
.
find
(
'
#captcha-container
'
).
exists
()).
toBeTruthy
();
});
});
test/jest/__tests__/RigistrationPage.spec.ts
0 → 100644
Просмотр файла @
1e66c3a3
import
{
describe
,
it
,
expect
,
jest
,
beforeEach
}
from
'
@jest/globals
'
;
import
{
createRouter
,
createWebHistory
}
from
'
vue-router
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
Quasar
,
QLayout
,
QPageContainer
,
QPage
}
from
'
quasar
'
;
import
routes
from
'
../../../src/router/routes
'
;
import
RegistrationPage
from
'
../../../src/pages/RegistrationPage.vue
'
;
import
{
createPinia
,
defineStore
}
from
'
pinia
'
;
import
RegForm
from
'
../../../src/components/RegForm.vue
'
;
// Mocks for any plugins or modules
jest
.
mock
(
'
src/boot/apollo
'
,
()
=>
({
apollo
:
{
default
:
{
query
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
// Возвращаем промис с пустыми данными
mutate
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
},
registrado
:
{
query
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
mutate
:
jest
.
fn
(()
=>
Promise
.
resolve
({
data
:
{}
})),
},
},
}));
// Create instances of router and pinia
const
router
=
createRouter
({
history
:
createWebHistory
(
process
.
env
.
BASE_URL
),
routes
,
});
const
pinia
=
createPinia
();
// The describe block contains your test suite
describe
(
'
RegistrationPage
'
,
()
=>
{
let
wrapper
;
// This runs before each test case
beforeEach
(()
=>
{
wrapper
=
mount
(
{
template
:
`
<q-layout>
<q-page-container>
<q-page>
<registration-page />
</q-page>
</q-page-container>
</q-layout>
`
,
components
:
{
RegistrationPage
},
},
{
global
:
{
plugins
:
[
Quasar
,
router
,
pinia
],
},
},
);
});
it
(
'
Проверка Наличие верхнего тулбарчика
'
,
()
=>
{
console
.
log
(
wrapper
.
html
());
const
Title
=
wrapper
.
findComponent
(
QPageContainer
);
expect
(
Title
.
exists
()).
toBeTruthy
();
expect
(
Title
.
text
()).
toContain
(
'
Регистрация в Universo
'
);
});
it
(
'
Проверка центральной надписи
'
,
()
=>
{
const
page
=
wrapper
.
findComponent
(
QPage
);
expect
(
page
.
exists
()).
toBeTruthy
();
expect
(
page
.
text
()).
toContain
(
'
На следующих шагах вы можете зарегистрироваться на портале
'
,
);
});
it
(
'
increments "step" by 1 when the "Accept" button is clicked
'
,
async
()
=>
{
// Проверяем, что начальное значение step равно 1
expect
(
wrapper
.
vm
.
step
).
toBe
(
1
);
// Находим кнопку "Принимаю". Предполагается, что в вашем компоненте есть только одна такая кнопка.
// Если кнопка имеет уникальный класс, идентификатор или другой атрибут, используйте его для поиска.
const
button
=
wrapper
.
find
(
'
button:contains("Принимаю")
'
);
// Замените селектор на корректный
// Симулируем клик на кнопке
await
button
.
trigger
(
'
click
'
);
// Дожидаемся асинхронного обновления данных компонента
await
wrapper
.
vm
.
$nextTick
();
// Проверяем, что значение step увеличилось
expect
(
wrapper
.
vm
.
step
).
toBe
(
2
);
});
it
(
'
Проверка центральной надписи
'
,
async
()
=>
{
console
.
log
(
wrapper
.
html
());
const
button
=
wrapper
.
findComponent
({
name
:
'
QBtn
'
});
// Или любой другой уникальный идентификатор
expect
(
button
.
exists
()).
toBe
(
true
);
// Убедитесь, что кнопка найдена
// Убедитесь, что кнопка найдена
await
button
.
trigger
(
'
click
'
);
});
});
tsconfig.json
Просмотр файла @
1e66c3a3
{
"extends"
:
"@quasar/app-webpack/tsconfig-preset"
,
"compilerOptions"
:
{
"module"
:
"CommonJS"
,
"baseUrl"
:
"."
,
"allowJs"
:
true
,
"sourceMap"
:
true
,
...
...
yarn.lock
Просмотр файла @
1e66c3a3
...
...
@@ -3494,7 +3494,7 @@ create-jest@^29.7.0:
jest-util "^29.7.0"
prompts "^2.0.1"
cross-fetch@4.0.0:
cross-fetch@^4.0.0,
cross-fetch@4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz"
integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==
...
...
@@ -4939,7 +4939,6 @@ hasown@^2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz"
integrity sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==
dependencies:
function-bind "^1.1.2"
he@^1.2.0:
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать