Skip to content

Commit 3df6dbe

Browse files
silverwindclaude
andcommitted
Add e2e test for relative-time rendering
Verify that the relative-time web component renders correctly and sets tooltip attributes. Add shared assertNoJsError helper to detect JS errors shown in the error banner. Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
1 parent 117f4dd commit 3df6dbe

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/e2e/relative-time.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {test, expect} from '@playwright/test';
2+
import {loginUser, apiCreateUser, apiDeleteUser, apiCreateRepo, apiUserHeaders, assertNoJsError} from './utils.ts';
3+
4+
test('relative-time renders without errors', async ({page, request}) => {
5+
const name = `rt-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
6+
await apiCreateUser(request, name);
7+
await apiCreateRepo(request, {name, headers: apiUserHeaders(name)});
8+
await loginUser(page, name);
9+
10+
// Dashboard should have relative-time elements from the repo creation event.
11+
// The component renders relative text (e.g. "now", "1 minute ago") and sets a tooltip.
12+
const relativeTime = page.locator('relative-time').first();
13+
await expect(relativeTime).toHaveAttribute('data-tooltip-content', /.+/);
14+
await expect(relativeTime).toContainText(/now|ago|minute|hour|day/);
15+
await assertNoJsError(page);
16+
17+
await apiDeleteUser(request, name);
18+
});

tests/e2e/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export async function login(page: Page, username = env.GITEA_TEST_E2E_USER, pass
104104
await expect(page.getByRole('link', {name: 'Sign In'})).toBeHidden();
105105
}
106106

107+
export async function assertNoJsError(page: Page) {
108+
await expect(page.locator('.js-global-error')).toHaveCount(0);
109+
}
110+
107111
export async function logout(page: Page) {
108112
await page.context().clearCookies(); // workaround issues related to fomantic dropdown
109113
await page.goto('/');

0 commit comments

Comments
 (0)