Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config: PlaywrightTestConfig = {
}
},
fullyParallel: true,
testDir: 'tests',
testDir: 'tests/redirects',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
projects: [
{
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/redirects.test.ts → tests/redirects/main.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/clamp.test.ts → tests/unit/clamp.test.ts
Original file line number Diff line number Diff line change
@@ -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<typeof clamp> = [
{
Expand Down
43 changes: 43 additions & 0 deletions tests/unit/specs.test.ts
Original file line number Diff line number Diff line change
@@ -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<any> {
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);
});
});
});
4 changes: 2 additions & 2 deletions src/lib/utils/toScale.test.ts → tests/unit/toScale.test.ts
Original file line number Diff line number Diff line change
@@ -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<typeof toScale> = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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)', () => {
Expand Down
16 changes: 16 additions & 0 deletions tests/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -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];
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export default defineConfig({
reportCompressedSize: false
},
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
include: ['tests/unit/**/*.{test,spec}.{js,ts}']
}
});