Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update playwright version, add basic tests #103

Merged
merged 1 commit into from
Mar 9, 2024
Merged
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
52 changes: 40 additions & 12 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@playwright/test": "^1.28.1",
"@playwright/test": "^1.41.2",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const TMDB_BACKDROP_SMALL = 'https://www.themoviedb.org/t/p/w780';
export const TMDB_POSTER_SMALL = 'https://www.themoviedb.org/t/p/w342';
export const TMDB_PROFILE_SMALL = 'https://www.themoviedb.org/t/p/w185';

export const PLACEHOLDER_BACKDROP = '/plcaeholder.jpg';
export const PLACEHOLDER_BACKDROP = '/placeholder.jpg';
122 changes: 122 additions & 0 deletions tests/UI.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//@ts-check
import { expect, test } from '@playwright/test';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';

const file = fileURLToPath(new URL('../package.json', import.meta.url));
const json = readFileSync(file, 'utf8');
const pkg = JSON.parse(json);

test.describe('UI Tests', () => {
test('Home page', async ({ page }) => {
await page.goto('/');
await expect(page.getByText('Home')).toBeVisible();
await page.getByText('Home').click();
await test.step('Check top bar links exist', async () => {
await expect(page.getByRole('link', {name: 'Reiverr', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Reiverr', exact: true})).toHaveAttribute('href', '/')
await expect(page.getByRole('link', {name: 'Home', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Home', exact: true})).toHaveAttribute('href', '/')
await expect(page.getByRole('link', {name: 'Library', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Library', exact: true})).toHaveAttribute('href', '/library')
await expect(page.getByRole('link', {name: 'Sources', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Sources', exact: true})).toHaveAttribute('href', '/sources')
await expect(page.getByRole('link', {name: 'Settings', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Settings', exact: true})).toHaveAttribute('href', '/settings')
});

await test.step('Check Carousel sections exist', async () => {
await expect(page.getByText('Popular People', {exact: true})).toBeVisible();
await expect(page.getByText('Upcoming Movies', {exact: true})).toBeVisible();
await expect(page.getByText('Upcoming Series', {exact: true})).toBeVisible();
await expect(page.getByText('Genres', {exact: true})).toBeVisible();
await expect(page.getByText('New Digital Releases', {exact: true})).toBeVisible();
await expect(page.getByText('Streaming Now', {exact: true})).toBeVisible();
await expect(page.getByText('TV Networks', {exact: true})).toBeVisible();
});
});

test('Library', async ({ page }) => {
await page.goto('/library');
await expect(page.getByText('Latest Addition')).toBeVisible();
await expect(page.getByRole('button', {name: 'Available', exact: true})).toBeVisible();
await expect(page.getByRole('button', {name: 'Watched', exact: true})).toBeVisible();
await expect(page.getByRole('button', {name: 'Unavailable', exact: true})).toBeVisible();
await expect(page.getByRole('button', {name: 'Play', exact: true})).toBeVisible();
await expect(page.getByRole('button', {name: 'Details', exact: true})).toBeVisible();
});

test('Sources', async ({ page }) => {
await page.goto('/sources');
await expect(page.getByText('Movies Provider')).toBeVisible();
await expect(page.getByText('Radarr')).toBeVisible();
await expect(page.getByText('Shows Provider')).toBeVisible();
await expect(page.getByText('Sonarr')).toBeVisible();
});

test('Settings', async ({ page }) => {
await page.goto('/settings');

await test.step('Check top bar links exist', async () => {
await expect(page.getByRole('link', {name: 'Reiverr', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Reiverr', exact: true})).toHaveAttribute('href', '/')
await expect(page.getByRole('link', {name: 'Home', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Home', exact: true})).toHaveAttribute('href', '/')
await expect(page.getByRole('link', {name: 'Library', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Library', exact: true})).toHaveAttribute('href', '/library')
await expect(page.getByRole('link', {name: 'Sources', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Sources', exact: true})).toHaveAttribute('href', '/sources')
await expect(page.getByRole('link', {name: 'Settings', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Settings', exact: true})).toHaveAttribute('href', '/settings')
});

await test.step('Check side buttons exist', async () => {
await expect(page.getByRole('button', {name: 'General', exact: true})).toBeVisible();
await expect(page.getByRole('button', {name: 'Integrations', exact: true})).toBeVisible();
});

await test.step('Check bottom bar links exist', async () => {
await expect(page.getByText(pkg.version)).toBeVisible();
await expect(page.getByRole('link', {name: 'Changelog', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'Changelog', exact: true})).toHaveAttribute('href', 'https://github.com/aleksilassila/reiverr/releases');
await expect(page.getByRole('link', {name: 'GitHub', exact: true})).toBeVisible();
await expect(page.getByRole('link', {name: 'GitHub', exact: true})).toHaveAttribute('href', 'https://github.com/aleksilassila/reiverr');
});
await test.step('Check User Interface section', async () => {
await expect(page.getByRole('heading', {name: 'User Interface'})).toBeVisible();
await expect(page.getByRole('heading', { name: 'Language', exact: true })).toBeVisible();
await expect(page.getByRole('combobox').first()).toBeVisible();
await expect(page.getByRole('button', {name: 'Save Changes'})).toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('en')
await expect(page.getByRole('button', {name: 'Save Changes'})).toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('de')
await expect(page.getByRole('button', {name: 'Save Changes'})).not.toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('es')
await expect(page.getByRole('button', {name: 'Save Changes'})).not.toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('fr')
await expect(page.getByRole('button', {name: 'Save Changes'})).not.toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('it')
await expect(page.getByRole('button', {name: 'Save Changes'})).not.toHaveClass(/cursor-not-allowed/);
await page.getByRole('combobox').first().click()
await page.getByRole('combobox').first().selectOption('en')
await expect(page.getByRole('button', {name: 'Save Changes'})).toHaveClass(/cursor-not-allowed/);
await expect(page.locator('.w-11').first()).toBeEnabled();
await expect(page.getByRole('spinbutton')).toHaveValue('150')
});

await test.step('Check Discovery section', async () => {
await expect(page.getByRole('heading', {name: 'Discovery', exact: true})).toBeVisible();
await expect(page.getByRole('heading', { name: 'Region', exact: true })).toBeVisible();
await expect(page.getByRole('combobox').nth(1)).toBeVisible();
await expect(page.getByRole('heading', { name: 'Exclude library items from Discovery', exact: true })).toBeVisible();
await expect(page.locator('.w-11').nth(1)).toBeEnabled();
await expect(page.getByText('Filter results based on spoken language. Takes ISO 639-1 language codes separated with commas. Leave empty to disable.')).toBeVisible();
await expect(page.getByPlaceholder('en,fr,de')).toBeVisible();
});
});
});
6 changes: 0 additions & 6 deletions tests/test.ts

This file was deleted.