Skip to content
Closed
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
42 changes: 42 additions & 0 deletions src/nodes/SetLiteral.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect, test } from 'vitest';
import evaluateCode from '@runtime/evaluate';

test('set literal with one element', () => {
expect(evaluateCode('{1}')?.toString()).toBe('{1}');
});

test('set literal with multiple elements', () => {
expect(evaluateCode('{1 2 3}')?.toString()).toBe('{1 2 3}');
});

test('set literal with string elements', () => {
expect(evaluateCode("{'a' 'b' 'c'}")?.toString()).toBe('{"a" "b" "c"}');
});

test('set literal removes duplicate elements', () => {
expect(evaluateCode('{1 1 2}')?.toString()).toBe('{1 2}');
});

test('set size via .size()', () => {
expect(evaluateCode('{1 2 3}.size()')?.toString()).toBe('3');
});

test('set is not equal to empty set', () => {
expect(evaluateCode('{1 2 3} = ø')?.toString()).toBe('⊥');
});

test('set is not empty', () => {
expect(evaluateCode('{1 2 3} ≠ ø')?.toString()).toBe('⊤');
});

test('set union combines two sets', () => {
expect(evaluateCode('{1 2}.union({3 4})')?.toString()).toBe('{1 2 3 4}');
});

test('set intersection finds common elements', () => {
expect(evaluateCode('{1 2 3}.intersection({2 3 4})')?.toString()).toBe('{2 3}');
});

test('set difference removes elements', () => {
expect(evaluateCode('{1 2 3}.difference({2 3})')?.toString()).toBe('{1}');
});
30 changes: 30 additions & 0 deletions tests/end2end/editor-output-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect, test } from '@playwright/test';

test.describe('Editor → Output cross-component flow', () => {

test('home page loads successfully', async ({ page }) => {
await page.goto('http://localhost:5173/en-US');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be hard coded with https://localhost:5173. Just pass the path, not the domain. Not every platform will use this port.

await expect(page).toHaveTitle(/Wordplay/, { timeout: 8000 });
});

test('navigating to Learn page works', async ({ page }) => {
await page.goto('http://localhost:5173/en-US');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the domain.

await page.getByRole('link', { name: 'Learn' }).first().click();
await page.waitForURL(/\/learn/, { timeout: 8000 });
await expect(page).toHaveURL(/learn/);
});

test('navigating to Guide page works', async ({ page }) => {
await page.goto('http://localhost:5173/en-US');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the domain.

await page.getByRole('link', { name: 'Guide' }).first().click();
await page.waitForURL(/\/guide/, { timeout: 8000 });
await expect(page).toHaveURL(/guide/);
});

test('language switcher is present on home page', async ({ page }) => {
await page.goto('http://localhost:5173/en-US');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the domain.

const langButton = page.getByText('English').or(page.locator('[aria-label*="language"]'));
await expect(langButton.first()).toBeVisible({ timeout: 8000 });
});

});
Loading