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", "Группа отвязана от курса")