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

V14/qa/new acceptance tests #14435

Merged
merged 4 commits into from
Jun 23, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ preserve.belle

# Tests
/tests/Umbraco.Tests.AcceptanceTest/.env
/tests/Umbraco.Tests.AcceptanceTest/playwright/.auth
/tests/Umbraco.Tests.Integration.SqlCe/DatabaseContextTests.sdf
/tests/Umbraco.Tests.Integration.SqlCe/[Uu]mbraco/[Dd]ata/TEMP/
/tests/Umbraco.Tests.Integration/appsettings.Tests.Local.json
Expand Down
41 changes: 22 additions & 19 deletions tests/Umbraco.Tests.AcceptanceTest/package-lock.json

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

12 changes: 6 additions & 6 deletions tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
"createTest": "node createTest.js"
},
"devDependencies": {
"@playwright/test": "^1.32",
"typescript": "^4.8.3",
"tslib": "^2.4.0",
"@playwright/test": "^1.35",
"del": "^6.0.0",
"ncp": "^2.0.0",
"prompt": "^1.2.0",
"tslib": "^2.4.0",
"typescript": "^4.8.3",
"wait-on": "^6.0.1"
},
"dependencies": {
"@umbraco/json-models-builders": "^1.0.5",
"@umbraco/playwright-testhelpers": "^1.0.22",
"@umbraco/playwright-testhelpers": "2.0.0-beta",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.7",
"xhr2": "^0.2.1",
"dotenv": "^16.0.2"
"xhr2": "^0.2.1"
}
}
90 changes: 19 additions & 71 deletions tests/Umbraco.Tests.AcceptanceTest/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import dotenv from 'dotenv';
import {defineConfig, devices} from '@playwright/test';
import * as path from "path";

dotenv.config();
require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
export const STORAGE_STATE = path.join(__dirname, 'playwright/.auth/user.json');

export default defineConfig({
testDir: './tests/',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
Expand All @@ -23,84 +21,34 @@ const config: PlaywrightTestConfig = {
/* Retry on CI only */
retries: process.env.CI ? 5 : 2,
// We don't want to run parallel, as tests might differ in state
workers: 1,
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? 'line' : 'html',
outputDir : "./results",

outputDir: "./results",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:44332',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
// When working locally it can be a good idea to use trace: 'on-first-retry' instead of 'retain-on-failure', it can cut the local test times in half.
// When working locally it can be a good idea to use trace: 'on-first-retry' instead of 'retain-on-failure', it can cut the local test times in half.
trace: 'retain-on-failure',
ignoreHTTPSErrors: true,
ignoreHTTPSErrors: true,
},

/* Configure projects for major browsers */
projects: [
// Setup project
{
name: 'setup',
testMatch: '**/*.setup.ts',
},
{
name: 'chromium',
dependencies: ['setup'],
use: {
...devices['Desktop Chrome'],
// Use prepared auth state.
storageState: STORAGE_STATE,
},
},

// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },

// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },

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

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
};

export default config;
});
18 changes: 18 additions & 0 deletions tests/Umbraco.Tests.AcceptanceTest/tests/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {test as setup, expect, Page} from '@playwright/test';
import {STORAGE_STATE} from '../playwright.config'

// Update this setup with test ids in the future. Maybe also find better locators in general
setup('authenticate', async ({page}) => {
await page.goto(process.env.URL + '/umbraco');

await page.getByRole('textbox', { name: 'Email' }).fill(process.env.UMBRACO_USER_LOGIN);
await page.getByRole('textbox', { name: 'Password' }).fill(process.env.UMBRACO_USER_PASSWORD);
await page.getByRole('button', {name: 'Login'}).click();

await page.waitForURL(process.env.URL + '/umbraco');

// Assert
await expect(page.getByRole('tab', { name: 'Settings' })).toBeVisible();

await page.context().storageState({path: STORAGE_STATE});
});
Loading