forgejo/tests/e2e/user-cards.test.e2e.ts
0ko 3bf4f0275a chore(e2e): use expect().toBeCloseTo instead of Math.round (#10257)
Followup to https://codeberg.org/forgejo/forgejo/pulls/6799, https://codeberg.org/forgejo/forgejo/pulls/9057

toBeCloseTo() recently popped in autocomplete suggestions and it seems like a cleaner way than using Math.round

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10257
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
2025-11-29 16:59:17 +01:00

29 lines
880 B
TypeScript

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
// @watch start
// templates/repo/user_cards.tmpl
// web_src/css/modules/user-cards.css
// @watch end
import {expect} from '@playwright/test';
import {test} from './utils_e2e.ts';
test('Usercards width', async ({page}) => {
await page.goto('/user8?tab=followers');
// Regardless of whether cards in a grid or flex mode, they should be ~same
// width. Verifying this relies on fixtures with users that have long website
// link or other content that could push the card width.
const widths = [];
const amount = 3;
for (let i = 1; i <= amount; i++) {
const card = await page.locator(`.user-cards .card:nth-child(${i})`).boundingBox();
widths.push(card.width);
}
for (const width of widths) {
expect(width).toBeCloseTo(widths[0], 0);
}
});