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

More work on organizing tests with new playwright #43

Merged
merged 3 commits into from
Jul 22, 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
51 changes: 34 additions & 17 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
// workers: process.env.CI ? 1 : undefined,
workers: undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand All @@ -33,40 +34,56 @@ export default defineConfig({

/* Configure projects for major browsers */
projects: [
{
name: 'base tests',
testMatch: '**/base.spec.ts',
},
{
name: 'mask tests',
testMatch: '**/mask.spec.ts',
dependencies: ['base tests'],
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
dependencies: ['base tests', 'mask tests'],
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
dependencies: ['base tests', 'mask tests'],
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
dependencies: ['base tests', 'mask tests'],
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
dependencies: ['base tests', 'mask tests'],
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
dependencies: ['base tests', 'mask tests'],
},

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
dependencies: ['base tests', 'mask tests'],
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
dependencies: ['base tests', 'mask tests'],
},
],

/* Run your local dev server before starting the tests */
Expand Down
24 changes: 24 additions & 0 deletions tests/base.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from '@playwright/test';
import * as path from 'path';

const projectDir = path.resolve(__dirname, '../');
const filePath = path.join(projectDir, 'examples/index.html');
const fileUrl = `file://${filePath}`;

test.describe('base tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto(fileUrl);
});

test('sanity startup', async ({ page }) => {
const currencyInput = await page.locator('#currency-input');
await expect(currencyInput).toHaveValue('$0.00 USD');
});

test('undefined value results in correct 0 of input', async ({ page }) => {
const nullInputTest = await page.locator('#null-input-test');
await expect(nullInputTest).toHaveValue('$0.00 USD');
});
});

// TODO: add tests for each of the possible parameters
16 changes: 0 additions & 16 deletions tests/test.spec.ts → tests/caret-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@ const projectDir = path.resolve(__dirname, '../');
const filePath = path.join(projectDir, 'examples/index.html');
const fileUrl = `file://${filePath}`;

test.describe('test', () => {
test.beforeEach(async ({ page }) => {
await page.goto(fileUrl);
});

test('sanity startup', async ({ page }) => {
const currencyInput = await page.locator('#currency-input');
await expect(currencyInput).toHaveValue('$0.00 USD');
});

test('undefined value results in correct 0 of input', async ({ page }) => {
const nullInputTest = await page.locator('#null-input-test');
await expect(nullInputTest).toHaveValue('$0.00 USD');
});
});

test.describe('input caret selection', () => {
const suffix = ' USD';
const prefix = '$';
Expand Down