Next.js Supabase V3 (#463)
Version 3 of the kit: - Radix UI replaced with Base UI (using the Shadcn UI patterns) - next-intl replaces react-i18next - enhanceAction deprecated; usage moved to next-safe-action - main layout now wrapped with [locale] path segment - Teams only mode - Layout updates - Zod v4 - Next.js 16.2 - Typescript 6 - All other dependencies updated - Removed deprecated Edge CSRF - Dynamic Github Action runner
This commit is contained in:
committed by
GitHub
parent
4912e402a3
commit
7ebff31475
@@ -1,4 +1,3 @@
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
@@ -6,6 +5,8 @@ import {
|
||||
createKitTranslationsService,
|
||||
} from '../kit-translations.service';
|
||||
|
||||
import path from 'node:path';
|
||||
|
||||
function createDeps(
|
||||
files: Record<string, string>,
|
||||
directories: string[],
|
||||
@@ -91,7 +92,7 @@ function createDeps(
|
||||
|
||||
describe('KitTranslationsService.list', () => {
|
||||
it('lists and flattens translations with missing namespace fallback', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({
|
||||
@@ -122,7 +123,7 @@ describe('KitTranslationsService.list', () => {
|
||||
|
||||
describe('KitTranslationsService.update', () => {
|
||||
it('updates nested translation keys', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -143,7 +144,7 @@ describe('KitTranslationsService.update', () => {
|
||||
});
|
||||
|
||||
it('rejects paths outside locales root', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -164,7 +165,7 @@ describe('KitTranslationsService.update', () => {
|
||||
});
|
||||
|
||||
it('rejects namespace path segments', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -187,7 +188,7 @@ describe('KitTranslationsService.update', () => {
|
||||
|
||||
describe('KitTranslationsService.stats', () => {
|
||||
it('computes coverage using base locale keys', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({
|
||||
@@ -213,7 +214,7 @@ describe('KitTranslationsService.stats', () => {
|
||||
|
||||
describe('KitTranslationsService.addNamespace', () => {
|
||||
it('creates namespace JSON in all locale directories', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -237,7 +238,7 @@ describe('KitTranslationsService.addNamespace', () => {
|
||||
});
|
||||
|
||||
it('throws if namespace already exists', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -253,7 +254,7 @@ describe('KitTranslationsService.addNamespace', () => {
|
||||
});
|
||||
|
||||
it('throws if no locales exist', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
@@ -264,7 +265,7 @@ describe('KitTranslationsService.addNamespace', () => {
|
||||
});
|
||||
|
||||
it('rejects path traversal in namespace', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -286,7 +287,7 @@ describe('KitTranslationsService.addNamespace', () => {
|
||||
|
||||
describe('KitTranslationsService.addLocale', () => {
|
||||
it('creates locale directory with namespace files', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({ hello: 'Hello' }),
|
||||
@@ -310,7 +311,7 @@ describe('KitTranslationsService.addLocale', () => {
|
||||
});
|
||||
|
||||
it('throws if locale already exists', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -326,7 +327,7 @@ describe('KitTranslationsService.addLocale', () => {
|
||||
});
|
||||
|
||||
it('works when no namespaces exist yet', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
@@ -337,7 +338,7 @@ describe('KitTranslationsService.addLocale', () => {
|
||||
});
|
||||
|
||||
it('rejects path traversal in locale', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
@@ -354,7 +355,7 @@ describe('KitTranslationsService.addLocale', () => {
|
||||
|
||||
describe('KitTranslationsService.removeNamespace', () => {
|
||||
it('deletes namespace files from all locales', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -377,7 +378,7 @@ describe('KitTranslationsService.removeNamespace', () => {
|
||||
});
|
||||
|
||||
it('throws if namespace does not exist', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -393,7 +394,7 @@ describe('KitTranslationsService.removeNamespace', () => {
|
||||
});
|
||||
|
||||
it('rejects path traversal', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
@@ -406,7 +407,7 @@ describe('KitTranslationsService.removeNamespace', () => {
|
||||
|
||||
describe('KitTranslationsService.removeLocale', () => {
|
||||
it('deletes entire locale directory', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -426,7 +427,7 @@ describe('KitTranslationsService.removeLocale', () => {
|
||||
});
|
||||
|
||||
it('throws if locale does not exist', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
@@ -437,7 +438,7 @@ describe('KitTranslationsService.removeLocale', () => {
|
||||
});
|
||||
|
||||
it('throws when trying to delete base locale', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps(
|
||||
{
|
||||
[`${localesRoot}/en/common.json`]: JSON.stringify({}),
|
||||
@@ -454,7 +455,7 @@ describe('KitTranslationsService.removeLocale', () => {
|
||||
});
|
||||
|
||||
it('rejects path traversal', async () => {
|
||||
const localesRoot = '/repo/apps/web/public/locales';
|
||||
const localesRoot = '/repo/apps/web/i18n/messages';
|
||||
const deps = createDeps({}, [localesRoot]);
|
||||
|
||||
const service = createKitTranslationsService(deps);
|
||||
|
||||
Reference in New Issue
Block a user