From 7ef5c866a38159703ee04a1da7db115378484280 Mon Sep 17 00:00:00 2001 From: Vladislav Kopnin Date: Thu, 29 Oct 2026 20:01:40 +0300 Subject: [PATCH] =?UTF-8?q?fix(web):=20=D1=83=D1=81=D1=82=D0=BE=D0=B9?= =?UTF-8?q?=D1=87=D0=B8=D0=B2=D1=8B=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20courseNo=20=D0=B8=20login=20E2E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/lms.spec.ts | 5 ++++- .../ru/ysu/lms/web/admin/AdminLabController.kt | 7 ++++++- .../ru/ysu/lms/web/teacher/TeacherController.kt | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/e2e/lms.spec.ts b/e2e/lms.spec.ts index bc680ee..282b140 100644 --- a/e2e/lms.spec.ts +++ b/e2e/lms.spec.ts @@ -74,7 +74,10 @@ async function login(page: Page, login: string, password: string, expectedPath: await page.goto("/login"); await page.fill("#login", login); await page.fill("#password", password); - await Promise.all([page.waitForURL(expectedPath), page.click('button[type="submit"]')]); + await Promise.all([ + page.waitForURL(expectedPath, { waitUntil: "domcontentloaded", timeout: 60_000 }), + page.click('button[type="submit"]'), + ]); } test.beforeAll(async ({ playwright }) => { diff --git a/web/src/main/kotlin/ru/ysu/lms/web/admin/AdminLabController.kt b/web/src/main/kotlin/ru/ysu/lms/web/admin/AdminLabController.kt index 77f2a4c..ac4fb66 100644 --- a/web/src/main/kotlin/ru/ysu/lms/web/admin/AdminLabController.kt +++ b/web/src/main/kotlin/ru/ysu/lms/web/admin/AdminLabController.kt @@ -61,7 +61,12 @@ class AdminLabController( model: Model, ): String { val t = token(session) - val selected = courseNo?.trim()?.takeIf { it.isNotBlank() }?.let { api.courseByUrlNo(t, it) } + val selected = + courseNo?.trim()?.takeIf { it.isNotBlank() }?.let { + runCatching { api.courseByUrlNo(t, it) } + .onFailure { model.addAttribute("error", "Курс не найден") } + .getOrNull() + } model.addAttribute("labs", api.listLabs(t, selected?.id)) model.addAttribute("courses", coursesFor(session)) model.addAttribute("selectedCourseNo", selected?.courseNo) diff --git a/web/src/main/kotlin/ru/ysu/lms/web/teacher/TeacherController.kt b/web/src/main/kotlin/ru/ysu/lms/web/teacher/TeacherController.kt index 9e2b6ba..793c2b0 100644 --- a/web/src/main/kotlin/ru/ysu/lms/web/teacher/TeacherController.kt +++ b/web/src/main/kotlin/ru/ysu/lms/web/teacher/TeacherController.kt @@ -92,7 +92,13 @@ class TeacherController( redirect: RedirectAttributes, ): String { val token = token(session) ?: return "redirect:/login" - val course = api.courseByUrlNo(token, courseNo) + val course = + try { + api.courseByUrlNo(token, courseNo) + } catch (ex: ApiException) { + redirect.addFlashAttribute("error", ex.message) + return "redirect:/teacher" + } return try { val target = groupId.trim().ifBlank { throw ApiException(400, "Выберите группу") } api.attachCourseGroup(token, course.id, CourseGroupPayload(target)) @@ -112,7 +118,13 @@ class TeacherController( redirect: RedirectAttributes, ): String { val token = token(session) ?: return "redirect:/login" - val course = api.courseByUrlNo(token, courseNo) + val course = + try { + api.courseByUrlNo(token, courseNo) + } catch (ex: ApiException) { + redirect.addFlashAttribute("error", ex.message) + return "redirect:/teacher" + } return try { api.detachCourseGroup(token, course.id, groupId) redirect.addFlashAttribute("notice", "Группа отвязана от курса")