diff --git a/package.json b/package.json index 2df14fd05d..8ca1f06e61 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@appwrite.io/console": "^0.6.4", "@appwrite.io/pink": "~0.26.0", "@appwrite.io/pink-icons": "~0.26.0", - "@appwrite.io/repo": "github:appwrite/appwrite#1.8.x", + "@appwrite.io/repo": "github:appwrite/appwrite#attempt-small-size-for-website", "@eslint/compat": "^1.2.7", "@eslint/js": "^9.21.0", "@fingerprintjs/fingerprintjs": "^4.5.1", diff --git a/playwright.config.ts b/playwright.config.ts index 5e3803c2fc..243e1fd0f7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -9,7 +9,7 @@ const config: PlaywrightTestConfig = { } }, fullyParallel: true, - testDir: 'tests', + testDir: 'tests/redirects', testMatch: /(.+\.)?(test|spec)\.[jt]s/, projects: [ { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c170218a2..9ab056d25f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,8 +28,8 @@ importers: specifier: ~0.26.0 version: 0.26.0 '@appwrite.io/repo': - specifier: github:appwrite/appwrite#1.8.x - version: https://codeload.github.com/appwrite/appwrite/tar.gz/07a11aa15c164a9da4211db13bb7495cb7b7047f + specifier: github:appwrite/appwrite#attempt-small-size-for-website + version: https://codeload.github.com/appwrite/appwrite/tar.gz/3114f572df92cf45f5f24da07c98aac620111803 '@eslint/compat': specifier: ^1.2.7 version: 1.3.2(eslint@9.34.0(jiti@2.5.1)) @@ -295,8 +295,8 @@ packages: '@appwrite.io/pink@0.26.0': resolution: {integrity: sha512-iPeGE56pauzxuIXt15ZswjKCErwp3QdF3XOlJZfyYY7J2nirra85JNTL+3lWuFIf8yYWL7NbvCjhf8ig79TgwA==} - '@appwrite.io/repo@https://codeload.github.com/appwrite/appwrite/tar.gz/07a11aa15c164a9da4211db13bb7495cb7b7047f': - resolution: {tarball: https://codeload.github.com/appwrite/appwrite/tar.gz/07a11aa15c164a9da4211db13bb7495cb7b7047f} + '@appwrite.io/repo@https://codeload.github.com/appwrite/appwrite/tar.gz/3114f572df92cf45f5f24da07c98aac620111803': + resolution: {tarball: https://codeload.github.com/appwrite/appwrite/tar.gz/3114f572df92cf45f5f24da07c98aac620111803} version: 0.0.0 '@babel/runtime@7.28.3': @@ -4322,7 +4322,7 @@ snapshots: normalize.css: 8.0.1 the-new-css-reset: 1.11.3 - '@appwrite.io/repo@https://codeload.github.com/appwrite/appwrite/tar.gz/07a11aa15c164a9da4211db13bb7495cb7b7047f': {} + '@appwrite.io/repo@https://codeload.github.com/appwrite/appwrite/tar.gz/3114f572df92cf45f5f24da07c98aac620111803': {} '@babel/runtime@7.28.3': {} diff --git a/tests/redirects.test.ts b/tests/redirects/main.test.ts similarity index 59% rename from tests/redirects.test.ts rename to tests/redirects/main.test.ts index 34f26806f9..2a23280d01 100644 --- a/tests/redirects.test.ts +++ b/tests/redirects/main.test.ts @@ -1,9 +1,9 @@ import { expect, test } from '@playwright/test'; -import redirects from '../src/redirects.json' with { type: 'json' }; +import redirects from '../../src/redirects.json' with { type: 'json' }; redirects.forEach(({ link, redirect }) => { test(`redirected from ${link} to ${redirect} exists`, async ({ page }) => { - const response = await page.goto(redirect); + const response = await page.goto(link, { waitUntil: 'domcontentloaded' }); expect(response?.ok()).toBeTruthy(); }); diff --git a/src/lib/utils/clamp.test.ts b/tests/unit/clamp.test.ts similarity index 84% rename from src/lib/utils/clamp.test.ts rename to tests/unit/clamp.test.ts index 36df58a918..bc8646977d 100644 --- a/src/lib/utils/clamp.test.ts +++ b/tests/unit/clamp.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect } from 'vitest'; -import { clamp } from './clamp'; -import type { TestCases } from './test'; +import { clamp } from '$lib/utils/clamp'; +import type { TestCases } from '$lib/utils/test'; const testCases: TestCases = [ { diff --git a/tests/unit/specs.test.ts b/tests/unit/specs.test.ts new file mode 100644 index 0000000000..d8c80fedc4 --- /dev/null +++ b/tests/unit/specs.test.ts @@ -0,0 +1,43 @@ +import { describe, expect, it } from 'vitest'; + +import path from 'node:path'; +import fs from 'node:fs/promises'; +import { VERSIONS, type Variant } from '../utils/constants'; + +export type Version = (typeof VERSIONS)[number]; + +const VARIANTS: Variant[] = ['client', 'server', 'console']; + +function getSpecPath(version: Version, variant: Variant): string { + return path.join( + process.cwd(), + `/node_modules/@appwrite.io/repo/app/config/specs/open-api3-${version}-${variant}.json` + ); +} + +async function readJSON(filePath: string): Promise { + const raw = await fs.readFile(filePath, 'utf8'); + return JSON.parse(raw.replace(/^\uFEFF/, '')); +} + +describe.each(VERSIONS)('OpenAPI specs validation for version %s', (version) => { + describe.each(VARIANTS)('%s variant', (variant) => { + it('spec file exists and is a valid OpenAPI 3 document', async () => { + const file = getSpecPath(version, variant); + + await expect(fs.access(file)).resolves.toBeUndefined(); + + const json = await readJSON(file); + + expect(json && typeof json === 'object').toBeTruthy(); + expect(typeof json.openapi).toBe('string'); + + expect(json.openapi.startsWith('3')).toBe(true); + + expect(json.info && typeof json.info.title === 'string').toBe(true); + expect(json.paths && typeof json.paths === 'object').toBe(true); + + expect(Object.keys(json.paths).length).toBeGreaterThan(0); + }); + }); +}); diff --git a/src/lib/utils/toScale.test.ts b/tests/unit/toScale.test.ts similarity index 85% rename from src/lib/utils/toScale.test.ts rename to tests/unit/toScale.test.ts index 8337a3329f..9a45162296 100644 --- a/src/lib/utils/toScale.test.ts +++ b/tests/unit/toScale.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect } from 'vitest'; -import { toScale } from './toScale'; -import type { TestCases } from './test'; +import { toScale } from '$lib/utils/toScale'; +import type { TestCases } from '$lib/utils/test'; const testCases: TestCases = [ { diff --git a/src/lib/utils/withPrevious.test.ts b/tests/unit/withPrevious.test.ts similarity index 94% rename from src/lib/utils/withPrevious.test.ts rename to tests/unit/withPrevious.test.ts index 6c4d4c9f1e..aa30a5505a 100644 --- a/src/lib/utils/withPrevious.test.ts +++ b/tests/unit/withPrevious.test.ts @@ -1,6 +1,7 @@ import { describe, expect, test } from 'vitest'; -import { withPrevious } from './withPrevious'; + import { get } from 'svelte/store'; +import { withPrevious } from '$lib/utils/withPrevious'; describe('withPrevious', () => { test('Should retain previous value (number)', () => { diff --git a/tests/utils/constants.ts b/tests/utils/constants.ts new file mode 100644 index 0000000000..4f2bb0f17b --- /dev/null +++ b/tests/utils/constants.ts @@ -0,0 +1,16 @@ +export type Variant = 'client' | 'server' | 'console'; + +export const VERSIONS = [ + '1.8.x', + '1.7.x', + '1.6.x', + '1.5.x', + '1.4.x', + '1.3.x', + '1.2.x', + '1.1.x', + '1.0.x', + '0.15.x' +] as const; + +export type Version = (typeof VERSIONS)[number]; diff --git a/vite.config.ts b/vite.config.ts index 47173153c1..92a763c809 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -39,6 +39,6 @@ export default defineConfig({ reportCompressedSize: false }, test: { - include: ['src/**/*.{test,spec}.{js,ts}'] + include: ['tests/unit/**/*.{test,spec}.{js,ts}'] } });