Skip to content
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

Add general not found page #11737

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-add-not-found-page
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add not found page

We've added a not found page to communicate to users when they've navigated to a page that doesn't exist.

https://github.com/owncloud/web/pull/11737
https://github.com/owncloud/web/issues/5804
11 changes: 11 additions & 0 deletions packages/web-runtime/src/pages/notFound.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="oc-flex oc-flex-center oc-flex-middle oc-flex-column page-not-found">
<oc-icon name="emotion-normal" fill-type="line" size="xxlarge" />
<h1 class="oc-text-muted">404</h1>
<p
class="oc-text-xlarge oc-m-rm oc-text-muted"
v-text="$gettext('The page you are looking for does not exist.')"
/>
</div>
</template>
<script setup lang="ts"></script>
7 changes: 7 additions & 0 deletions packages/web-runtime/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AccessDeniedPage from '../pages/accessDenied.vue'
import Account from '../pages/account.vue'
import LoginPage from '../pages/login.vue'
import LogoutPage from '../pages/logout.vue'
import NotFoundPage from '../pages/notFound.vue'
import OidcCallbackPage from '../pages/oidcCallback.vue'
import ResolvePublicLinkPage from '../pages/resolvePublicLink.vue'
import ResolvePrivateLinkPage from '../pages/resolvePrivateLink.vue'
Expand Down Expand Up @@ -86,6 +87,12 @@ const routes = [
name: 'account',
component: Account,
meta: { title: $gettext('Account'), authContext: 'hybrid' }
},
{
path: '/:pathMatch(.*)*',
name: 'notFound',
component: NotFoundPage,
meta: { title: $gettext('Not found'), authContext: 'hybrid' }
}
]
export const router = patchRouter(
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/cucumber/features/navigation/pageNotFoud.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Page not found
As a user
I want to see a not found page
So that I know when I've navigated to a page that doesn't exist

Scenario: not found page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a second one for "the public" (i.e. anonymous access)? Important that the page also works unauthenticated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we found out in a meeting: we can't offer the notFound page in an anonymous context at the moment: user doesn't get initialized and more importantly, apps don't get initialized in an anonymous context. We might change that in the future, but for now we need to accept that the notFound page only works in user- and publicLink-contexts.

Given "Admin" creates following user using API
| id |
| Alice |
And "Alice" logs in
When "Alice" navigates to a non-existing page
Then "Alice" should see the not found page
And "Alice" logs out
20 changes: 19 additions & 1 deletion tests/e2e/cucumber/steps/ui/navigateByUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from '@cucumber/cucumber'
import { Then, When } from '@cucumber/cucumber'
import { World } from '../../environment'
import { objects } from '../../../support'

Expand Down Expand Up @@ -54,3 +54,21 @@ When(
await urlNavObject.openSpaceViaUrl({ user, space })
}
)

When(
'{string} navigates to a non-existing page',
async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const urlNavObject = new objects.urlNavigation.URLNavigation({ page })
await urlNavObject.navigateToNonExistingPage()
}
)

Then(
'{string} should see the not found page',
async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const urlNavObject = new objects.urlNavigation.URLNavigation({ page })
await urlNavObject.waitForNotFoundPageToBeVisible()
}
)
7 changes: 7 additions & 0 deletions tests/e2e/support/objects/url-navigation/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ const getTheFileIdOfSpaceFile = async (
spaceName
})
}

export const navigateToNonExistingPage = async ({ page }: { page: Page }) => {
await page.goto(`${config.backendUrl}/'a-non-existing-page'`)
}
export const waitForNotFoundPageToBeVisible = async ({ page }: { page: Page }) => {
await page.locator('.page-not-found').waitFor()
}
7 changes: 7 additions & 0 deletions tests/e2e/support/objects/url-navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ export class URLNavigation {
async openSpaceViaUrl(args: Omit<po.openResourceViaUrlArgs, 'page'>): Promise<void> {
await po.openSpaceViaUrl({ ...args, page: this.#page })
}

async navigateToNonExistingPage(): Promise<void> {
await po.navigateToNonExistingPage({ page: this.#page })
}
async waitForNotFoundPageToBeVisible(): Promise<void> {
await po.waitForNotFoundPageToBeVisible({ page: this.#page })
}
}