-
Notifications
You must be signed in to change notification settings - Fork 193
[full-ci] feat: [OCISDEV-541] add crash page #13426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,7 @@ config = { | |
| "suites": [ | ||
| "shares", | ||
| "search", | ||
| "runtime", | ||
| ], | ||
| }, | ||
| "4": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Enhancement: Add crash page | ||
|
|
||
| We've added a crash page to the application. This page is displayed when the application encounters an error that it cannot recover from. | ||
|
|
||
| https://github.com/owncloud/web/pull/13426 |
5 changes: 5 additions & 0 deletions
5
changelog/unreleased/enhancement-catch-spaces-loading-error.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Enhancement: Catch spaces loading error | ||
|
|
||
| In case there is any error during spaces loading, the application will now display a crash page instead of showing an infinite loading state. | ||
|
|
||
| https://github.com/owncloud/web/pull/13426 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /** | ||
| * Error codes for errors from which the application cannot recover. | ||
| */ | ||
| export const CRASH_CODES = Object.freeze({ | ||
| RUNTIME_BOOTSTRAP_SPACES_LOAD: 'RUNTIME-BOOTSTRAP-040' | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './types' | ||
| export * from './codes' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <template> | ||
| <div id="page-crash" class="container"> | ||
| <img class="logo" :src="logoImg" :alt="productName" /> | ||
| <div class="card"> | ||
| <h1 class="title"> | ||
| {{ | ||
| $pgettext( | ||
| 'Title of the crash page displayed when the application crashes', | ||
| 'Application crashed' | ||
| ) | ||
| }} | ||
| </h1> | ||
| <p v-if="errorCode !== ''" class="error-code"> | ||
| {{ errorCode }} | ||
| </p> | ||
| <p>{{ errorMessage }}</p> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { computed, unref } from 'vue' | ||
| import { useThemeStore } from '@ownclouders/web-pkg' | ||
| import { useHead } from '../composables/head' | ||
| import { storeToRefs } from 'pinia' | ||
| import { useRoute } from 'vue-router' | ||
| import { useGettext } from 'vue3-gettext' | ||
| import { CRASH_CODES } from '@ownclouders/web-pkg/src/errors/codes' | ||
|
|
||
| const route = useRoute() | ||
| const { $pgettext } = useGettext() | ||
|
|
||
| const themeStore = useThemeStore() | ||
| const { currentTheme } = storeToRefs(themeStore) | ||
|
|
||
| const errorCode = computed(() => route.query.code || '') | ||
|
|
||
| const errorMessage = computed(() => { | ||
| switch (unref(errorCode)) { | ||
| case CRASH_CODES.RUNTIME_BOOTSTRAP_SPACES_LOAD: | ||
| return $pgettext( | ||
| 'An error message displayed on crash page when loading spaces during runtime bootstrap fails due to whatever reason.', | ||
| 'An error occurred while loading your spaces. Please try to reload the page. If the problem persists, seek help from your Administrator.' | ||
| ) | ||
| default: | ||
| return $pgettext( | ||
| 'Generic error message displayed on crash page when either no error code is provided or the error code is not known.', | ||
| 'An unknown error occurred. Please try to reload the page. If the problem persists, seek help from your Administrator.' | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| const productName = computed(() => currentTheme.value.common.name) | ||
| const logoImg = computed(() => currentTheme.value.logo.login) | ||
|
|
||
| useHead() | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .container { | ||
| align-content: center; | ||
| align-items: center; | ||
| display: grid; | ||
| gap: var(--oc-space-large); | ||
| justify-items: center; | ||
| min-height: 100dvh; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .logo { | ||
| max-height: 12.5rem; | ||
| max-width: 12.5rem; | ||
| } | ||
|
|
||
| .card { | ||
| box-sizing: border-box; | ||
| background-color: var(--oc-color-background-default); | ||
| border-radius: 0.3125rem; | ||
| color: var(--oc-color-text-default); | ||
| padding: var(--oc-space-medium); | ||
| margin-inline: auto; | ||
| max-width: min(36rem, 100%); | ||
| text-align: center; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .title { | ||
| font-size: var(--oc-font-size-large); | ||
| font-weight: var(--oc-font-weight-semibold); | ||
| margin: 0; | ||
| } | ||
|
|
||
| .error-code { | ||
| margin-top: var(--oc-space-small); | ||
| font-size: var(--oc-font-size-xsmall); | ||
| color: var(--oc-color-text-muted); | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { test } from '@playwright/test' | ||
| import { config } from '../../../e2e/config.js' | ||
| import { ActorsEnvironment, UsersEnvironment } from '../../../e2e/support/environment' | ||
| import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken' | ||
| import * as api from '../../steps/api/api' | ||
| import * as ui from '../../steps/ui/index' | ||
| import { CRASH_CODES } from '../../../../packages/web-pkg/src/errors/codes' | ||
|
|
||
| test.describe('crash page', () => { | ||
| let actorsEnvironment: ActorsEnvironment | ||
| const usersEnvironment = new UsersEnvironment() | ||
|
|
||
| test.beforeEach(async ({ browser }) => { | ||
| actorsEnvironment = new ActorsEnvironment({ | ||
| context: { | ||
| acceptDownloads: config.acceptDownloads, | ||
| reportDir: config.reportDir, | ||
| tracingReportDir: config.tracingReportDir, | ||
| reportHar: config.reportHar, | ||
| reportTracing: config.reportTracing, | ||
| reportVideo: config.reportVideo, | ||
| failOnUncaughtConsoleError: config.failOnUncaughtConsoleError | ||
| }, | ||
| browser: browser | ||
| }) | ||
|
|
||
| await setAccessAndRefreshToken(usersEnvironment) | ||
| await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' }) | ||
| await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' }) | ||
| }) | ||
|
|
||
| test.afterEach(async () => { | ||
| await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' }) | ||
| }) | ||
|
|
||
| test('when spaces loading fails, the crash page is displayed', async () => { | ||
| const { page } = actorsEnvironment.getActor({ key: 'Alice' }) | ||
|
|
||
| await page.route('**/me/drives*', (route) => { | ||
| route.abort('failed') | ||
| }) | ||
| await page.reload() | ||
|
|
||
| await ui.expectCrashPageToBeVisible({ page }) | ||
| await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) | ||
| }) | ||
|
|
||
| test('the crash page does not have any accessibility violations', async () => { | ||
| const { page } = actorsEnvironment.getActor({ key: 'Alice' }) | ||
| await ui.openCrashPage({ | ||
| page, | ||
| errorCode: CRASH_CODES.RUNTIME_BOOTSTRAP_SPACES_LOAD | ||
| }) | ||
| await ui.expectCrashPageToBeVisible({ page }) | ||
| await ui.expectCrashPageHasNoAccessibilityViolations({ page }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { CrashPage } from '../../../e2e/support/objects/crash-page' | ||
| import { config } from '../../../e2e/config' | ||
| import { Page } from '@playwright/test' | ||
|
|
||
| export function expectCrashPageToBeVisible({ page }: { page: Page }) { | ||
| const crashPageObject = new CrashPage({ page }) | ||
| return crashPageObject.assertVisibility() | ||
| } | ||
|
|
||
| export function openCrashPage({ page, errorCode }: { page: Page; errorCode: string }) { | ||
| return page.goto(`${config.baseUrl}/crash?errorCode=${errorCode}`) | ||
| } | ||
|
|
||
| export async function expectCrashPageHasNoAccessibilityViolations({ page }: { page: Page }) { | ||
| if (config.skipA11y) { | ||
| return | ||
| } | ||
|
|
||
| const crashPageObject = new CrashPage({ page }) | ||
| const a11yViolations = await crashPageObject.getAccessibilityViolations() | ||
|
|
||
| expect( | ||
| a11yViolations, | ||
| `Found ${a11yViolations.length} severe accessibility violations in crash page` | ||
| ).toHaveLength(0) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { expect, Page } from '@playwright/test' | ||
| import { objects } from '../..' | ||
|
|
||
| const selectors = { | ||
| page: '#page-crash' | ||
| } | ||
|
|
||
| export class CrashPage { | ||
| #page: Page | ||
|
|
||
| constructor({ page }: { page: Page }) { | ||
| this.#page = page | ||
| } | ||
|
|
||
| assertVisibility() { | ||
| return expect(this.#page.locator(selectors.page).first()).toBeVisible() | ||
| } | ||
|
|
||
| getAccessibilityViolations() { | ||
| const a11yObject = new objects.a11y.Accessibility({ page: this.#page }) | ||
| return a11yObject.getSevereAccessibilityViolations(selectors.page) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to improve accessibility for this one? I guess some users won't be able to understand the connection between the error and the code. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, the error is there only for us. I.e. if we get a bug report, we know the code and know right away into which part of the code we should look into. In the future, we might consider adding some documentation where the codes could be listed and users/admins could orient themselves but as since we haven't got any error codes correlating with errors that the users could "fix" themselves I don't see too much value in doing that now.