Make cypress tests run on bitbucket
This commit is contained in:
parent
b826a44af6
commit
52632708db
|
|
@ -30,9 +30,12 @@ pipelines:
|
|||
- pip
|
||||
- cypress
|
||||
script:
|
||||
- export IT_SERVE_VUE=false
|
||||
- export IT_ALLOW_LOCAL_LOGIN=true
|
||||
- source ./env/bitbucket/prepare_for_test.sh
|
||||
- pip install -r server/requirements/requirements-dev.txt
|
||||
- npm install
|
||||
- npm run build
|
||||
- ./prepare_server_cypress.sh --start-background
|
||||
- npm run cypress:ci
|
||||
# - npm run build
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import {createApp} from 'vue'
|
||||
import {createPinia} from 'pinia'
|
||||
|
||||
import {setupI18n} from './i18n'
|
||||
// import {setupI18n} from './i18n'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
import '../tailwind.css'
|
||||
|
||||
const i18n = setupI18n()
|
||||
// const i18n = setupI18n()
|
||||
const app = createApp(App)
|
||||
|
||||
// todo: define lang setup
|
||||
|
|
@ -15,6 +15,6 @@ const app = createApp(App)
|
|||
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
app.use(i18n)
|
||||
// app.use(i18n)
|
||||
|
||||
app.mount('#app')
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module.exports = defineConfig({
|
|||
toConsole: true,
|
||||
},
|
||||
e2e: {
|
||||
experimentalSessionAndOrigin: true,
|
||||
// experimentalSessionAndOrigin: true,
|
||||
// We've imported your old cypress plugins here.
|
||||
// You may want to clean this up later by importing these.
|
||||
setupNodeEvents(on, config) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,14 @@ const _ = Cypress._;
|
|||
Cypress.Commands.add('manageCommand', (command, preCommand = '') => {
|
||||
const execCommand = `${preCommand} python server/manage.py ${command} --settings=config.settings.test_cypress`;
|
||||
console.log(execCommand);
|
||||
return cy.exec(execCommand);
|
||||
return cy.exec(execCommand, { failOnNonZeroExit: false }).then(result => {
|
||||
if(result.code) {
|
||||
throw new Error(`Execution of "${command}" failed
|
||||
Exit code: ${result.code}
|
||||
Stdout:\n${result.stdout}
|
||||
Stderr:\n${result.stderr}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('manageShellCommand', (command) => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import os
|
|||
os.environ['IT_APP_ENVIRONMENT'] = 'development'
|
||||
|
||||
from .base import * # noqa
|
||||
from .base import env
|
||||
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
|
||||
import os
|
||||
|
||||
os.environ['IT_APP_ENVIRONMENT'] = 'development'
|
||||
|
||||
from .base import * # noqa
|
||||
|
||||
|
|
|
|||
|
|
@ -41,18 +41,14 @@ urlpatterns = [
|
|||
path('learnpath/', include("vbv_lernwelt.learnpath.urls")),
|
||||
path('api/completion/', include("vbv_lernwelt.completion.urls")),
|
||||
re_path(r'api/core/me/$', me_user_view, name='me_user_view'),
|
||||
re_path(r'core/login/$', django_view_authentication_exempt(vue_login), name='vue_login'),
|
||||
re_path(r'core/logout/$', vue_logout, name='vue_logout'),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
if settings.DEBUG:
|
||||
# Static file serving when using Gunicorn + Uvicorn for local web socket development
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
|
||||
if settings.ALLOW_LOCAL_LOGIN:
|
||||
urlpatterns += [
|
||||
re_path(r'core/login/$', django_view_authentication_exempt(vue_login), name='vue_login'),
|
||||
]
|
||||
|
||||
|
||||
# API URLS
|
||||
urlpatterns += [
|
||||
# API base url
|
||||
|
|
@ -112,4 +108,3 @@ if settings.DEBUG:
|
|||
|
||||
# serve everything else via the vue app
|
||||
urlpatterns += [re_path(r'^.*$', vue_home, name='home')]
|
||||
|
||||
|
|
|
|||
|
|
@ -48,20 +48,23 @@ def vue_home(request):
|
|||
@api_view(['POST'])
|
||||
@ensure_csrf_cookie
|
||||
def vue_login(request):
|
||||
try:
|
||||
username = request.data.get('username')
|
||||
password = request.data.get('password')
|
||||
if username and password:
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user:
|
||||
login(request, user)
|
||||
logger.debug('login successful', username=username, email=user.email, label='login')
|
||||
return Response(UserSerializer(user).data)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
if settings.ALLOW_LOCAL_LOGIN:
|
||||
try:
|
||||
username = request.data.get('username')
|
||||
password = request.data.get('password')
|
||||
if username and password:
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user:
|
||||
login(request, user)
|
||||
logger.debug('login successful', username=username, email=user.email, label='login')
|
||||
return Response(UserSerializer(user).data)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
logger.debug('login failed', username=username, label='login')
|
||||
return Response({'success': False}, status=401)
|
||||
logger.debug('login failed', username=username, label='login')
|
||||
return Response({'success': False}, status=401)
|
||||
else:
|
||||
return Response({'success': False, 'message': 'ALLOW_LOCAL_LOGIN=false'}, status=403)
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue