fix: iterate all tools from home

This commit is contained in:
ShareVB 2024-06-23 23:27:41 +02:00
parent 2bd17e94cc
commit 601673d095
4 changed files with 60 additions and 20 deletions

View file

@ -9,7 +9,7 @@ const theme = useThemeVars();
</script>
<template>
<router-link :to="tool.path" class="decoration-none">
<router-link :to="tool.path" class="it-tool-link decoration-none">
<c-card class="h-full transition transition-duration-0.5s !border-2px !hover:border-primary">
<div flex items-center justify-between>
<n-icon class="text-neutral-400 dark:text-neutral-600" size="40" :component="tool.icon" />

View file

@ -1,15 +1,37 @@
import { expect, test } from '@playwright/test';
import _ from 'lodash';
import { toolsByCategory } from './index';
for (const tool of _.flatten(toolsByCategory.map(category => category.components))) {
test.describe(`Tool - ${tool.name}`, () => {
test.beforeEach(async ({ page }) => {
await page.goto(tool.path);
test.describe('IT Tool', () => {
test('Loads all tools correctly', async ({ page }) => {
test.slow();
const allTools: string[] = [];
await page.goto('/');
await page.waitForSelector('.it-tool-link');
const allLinks = await page.locator('.it-tool-link').all();
for (const a of allLinks) {
allTools.push((await a.getAttribute('href')) || '/');
}
expect(allTools.length).toBeGreaterThan(0);
const errors: Array<Error> = [];
page.on('pageerror', (error) => {
errors.push(error);
});
test('Loads correctly (has correct title)', async ({ page }) => {
await expect(page).toHaveTitle(`${tool.name} - IT Tools`);
});
for (const toolHref of allTools) {
await test.step(toolHref, async () => {
errors.splice(0, errors.length);
await page.goto(toolHref);
await page.waitForSelector('.tool-header');
await expect(page).toHaveTitle(/.+ - IT Tools/);
expect(errors).toHaveLength(0);
});
}
});
}
});

View file

@ -1,8 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
},
},
}