-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
264 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import { defineConfig, devices } from '@playwright/experimental-ct-svelte'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
webServer: { | ||
command: 'npm run build && npm run preview', | ||
port: 4173 | ||
export default defineConfig({ | ||
testDir: './tests/components', | ||
timeout: 10 * 1000, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: process.env.CI ? [['github'], ['html']] : [['html', { open: 'never' }]], | ||
use: { | ||
trace: 'retain-on-failure', | ||
video: 'retain-on-failure', | ||
ctPort: 3100, | ||
ctTemplateDir: './tests/components/boilerplate' | ||
}, | ||
testDir: 'tests' | ||
}; | ||
|
||
export default config; | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] } | ||
} | ||
] | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import Toaster from '../../../src/lib/components/Toaster.svelte'; | ||
import toast from '../../../src/lib/core/toast'; | ||
import type { ToastProps } from './types'; | ||
export let toastProps: ToastProps; | ||
onMount(() => { | ||
toast(toastProps[0], toastProps[1]); | ||
}); | ||
</script> | ||
|
||
<Toaster /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<html lang="en"> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./index.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Apply theme here, add anything your component needs at runtime here. | ||
// import '../src/common.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type toast from '$lib'; | ||
import type { test } from '@playwright/experimental-ct-svelte'; | ||
|
||
export type Mount = Parameters<Parameters<typeof test>[1]>['0']['mount']; | ||
export type ToastProps = Parameters<typeof toast>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { expect, test } from '@playwright/experimental-ct-svelte'; | ||
import App from './boilerplate/App.svelte'; | ||
|
||
test.use({ viewport: { width: 500, height: 500 } }); | ||
|
||
test.describe('LTR', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.evaluate(() => { | ||
document.documentElement.lang = 'en'; | ||
document.documentElement.dir = 'ltr'; | ||
}); | ||
}); | ||
|
||
test('top-start', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['Hello world!', { position: 'top-start' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be top left | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeLessThan(150); | ||
}); | ||
|
||
test('top-end', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['Hello world!', { position: 'top-end' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be top right | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeGreaterThan(350); | ||
}); | ||
|
||
test('bottom-start', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { | ||
toastProps: ['Hello world!', { position: 'bottom-start' }] | ||
} | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be bottom left | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeLessThan(150); | ||
}); | ||
|
||
test('bottom-end', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['Hello world!', { position: 'bottom-end' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be bottom right | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeGreaterThan(350); | ||
}); | ||
}); | ||
|
||
test.describe('RTL', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.evaluate(() => { | ||
document.documentElement.lang = 'ar'; | ||
document.documentElement.dir = 'rtl'; | ||
}); | ||
}); | ||
|
||
test('top-start', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['مرحبا', { position: 'top-start' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be top right | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeGreaterThan(350); | ||
}); | ||
|
||
test('top-end', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['مرحبا', { position: 'top-end' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be top left | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeLessThan(150); | ||
}); | ||
|
||
test('bottom-start', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['مرحبا', { position: 'bottom-start' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be bottom right | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeGreaterThan(350); | ||
}); | ||
|
||
test('bottom-end', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['مرحبا', { position: 'bottom-end' }] } | ||
}); | ||
|
||
const toast = component.getByRole('status'); | ||
// toast should be bottom left | ||
const toastRect = await toast.boundingBox(); | ||
expect(toastRect?.x).toBeLessThan(150); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { expect, test } from '@playwright/experimental-ct-svelte'; | ||
import App from './boilerplate/App.svelte'; | ||
|
||
test.use({ viewport: { width: 500, height: 500 } }); | ||
|
||
test('should render', async ({ mount }) => { | ||
const component = await mount(App, { | ||
props: { toastProps: ['Hello world!'] } | ||
}); | ||
await expect(component.getByText('Hello world!')).toBeVisible(); | ||
}); |