Compare commits
1 commit
main
...
playwright
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6679e50ace |
13 changed files with 264 additions and 6 deletions
45
.github/workflows/playwright.yml
vendored
Normal file
45
.github/workflows/playwright.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
name: e2e Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
saleorApiUrl:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
appManifestUrl:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
E2E_TAXES_SALEOR_API_URL: ${{ inputs.saleorApiUrl }}
|
||||||
|
E2E_TAXES_ADMIN_USER_EMAIL: ${{ inputs.email }}
|
||||||
|
E2E_TAXES_ADMIN_USER_PASSWORD: ${{ inputs.password }}
|
||||||
|
E2E_TAXES_TESTED_APP_MANIFEST: ${{ inputs.appManifestUrl }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
timeout-minutes: 60
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
- name: Install Playwright Browsers
|
||||||
|
run: pnpm exec playwright install --with-deps
|
||||||
|
- name: Run Playwright tests
|
||||||
|
run: pnpm run e2e
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: playwright-report
|
||||||
|
path: playwright-report/
|
||||||
|
retention-days: 30
|
|
@ -7,4 +7,11 @@ PORT=
|
||||||
VERCEL_URL=
|
VERCEL_URL=
|
||||||
REST_APL_ENDPOINT=
|
REST_APL_ENDPOINT=
|
||||||
REST_APL_TOKEN=
|
REST_APL_TOKEN=
|
||||||
ALLOWED_DOMAIN_PATTERN=
|
ALLOWED_DOMAIN_PATTERN=
|
||||||
|
|
||||||
|
# e2e
|
||||||
|
|
||||||
|
E2E_TAXES_SALEOR_API_URL=
|
||||||
|
E2E_TAXES_ADMIN_USER_EMAIL=
|
||||||
|
E2E_TAXES_ADMIN_USER_PASSWORD=
|
||||||
|
E2E_TAXES_TESTED_APP_MANIFEST=
|
4
apps/taxes/.gitignore
vendored
4
apps/taxes/.gitignore
vendored
|
@ -4,3 +4,7 @@
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
next.config.original.js
|
next.config.original.js
|
||||||
|
node_modules/
|
||||||
|
/test-results/
|
||||||
|
/playwright-report/
|
||||||
|
/playwright/.cache/
|
||||||
|
|
64
apps/taxes/e2e/installation.spec.ts
Normal file
64
apps/taxes/e2e/installation.spec.ts
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { createClient } from "urql";
|
||||||
|
import { AuthorizeDocument, InstallAppDocument, JobStatusEnum } from "../generated/graphql";
|
||||||
|
|
||||||
|
const saleorUrl = process.env.E2E_TAXES_SALEOR_API_URL!;
|
||||||
|
const email = process.env.E2E_TAXES_ADMIN_USER_EMAIL!;
|
||||||
|
const password = process.env.E2E_TAXES_ADMIN_USER_PASSWORD!;
|
||||||
|
const testedAppManifest = process.env.E2E_TAXES_TESTED_APP_MANIFEST!;
|
||||||
|
|
||||||
|
const client = createClient({
|
||||||
|
url: saleorUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
let token = "";
|
||||||
|
|
||||||
|
test.describe("Taxes Installation @taxes", () => {
|
||||||
|
test.beforeAll(async () => {
|
||||||
|
const tokenResp = await client
|
||||||
|
.mutation(AuthorizeDocument, {
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
})
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
token = tokenResp.data!.tokenCreate!.token as string;
|
||||||
|
|
||||||
|
return expect(token).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should it be taxes/e2e or maybe move it to packages/e2e and run all apps installations there?
|
||||||
|
* Having a package will be hard to orchestrate when tests should run
|
||||||
|
*/
|
||||||
|
test("Installs app via Manifest", async () => {
|
||||||
|
const installationResp = await client
|
||||||
|
.mutation(
|
||||||
|
InstallAppDocument,
|
||||||
|
{ manifestUrl: testedAppManifest },
|
||||||
|
{
|
||||||
|
fetchOptions: {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
|
expect(installationResp.data!.appInstall!.appInstallation!.status).toBe(JobStatusEnum.Pending);
|
||||||
|
expect(installationResp.data!.appInstall!.appInstallation!.id).toEqual(expect.any(String));
|
||||||
|
|
||||||
|
// todo - fetch installed app after job completed
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Fetches manifest", async ({ request }) => {
|
||||||
|
expect(await request.get(testedAppManifest!).then((r) => r.json())).toMatchObject(
|
||||||
|
expect.objectContaining({
|
||||||
|
name: expect.any(String),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
5
apps/taxes/graphql/mutations/Authorize.graphql
Normal file
5
apps/taxes/graphql/mutations/Authorize.graphql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
mutation Authorize($email: String!, $password: String!) {
|
||||||
|
tokenCreate(email: $email, password: $password) {
|
||||||
|
token
|
||||||
|
}
|
||||||
|
}
|
13
apps/taxes/graphql/mutations/InstallApp.graphql
Normal file
13
apps/taxes/graphql/mutations/InstallApp.graphql
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
mutation InstallApp ($manifestUrl: String) {
|
||||||
|
appInstall(
|
||||||
|
input: { manifestUrl: $manifestUrl, appName: "E2E TEST APP", activateAfterInstallation: true }
|
||||||
|
) {
|
||||||
|
errors {
|
||||||
|
code
|
||||||
|
}
|
||||||
|
appInstallation {
|
||||||
|
id
|
||||||
|
status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,8 @@
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"fetch-schema": "curl https://raw.githubusercontent.com/saleor/saleor/${npm_package_saleor_schemaVersion}/saleor/graphql/schema.graphql > graphql/schema.graphql",
|
"fetch-schema": "curl https://raw.githubusercontent.com/saleor/saleor/${npm_package_saleor_schemaVersion}/saleor/graphql/schema.graphql > graphql/schema.graphql",
|
||||||
"generate": "graphql-codegen",
|
"generate": "graphql-codegen",
|
||||||
"test": "vitest"
|
"test": "vitest",
|
||||||
|
"e2e": "playwright test"
|
||||||
},
|
},
|
||||||
"saleor": {
|
"saleor": {
|
||||||
"schemaVersion": "3.10"
|
"schemaVersion": "3.10"
|
||||||
|
@ -58,6 +59,7 @@
|
||||||
"@graphql-codegen/typescript-urql": "^3.7.3",
|
"@graphql-codegen/typescript-urql": "^3.7.3",
|
||||||
"@graphql-codegen/urql-introspection": "2.2.1",
|
"@graphql-codegen/urql-introspection": "2.2.1",
|
||||||
"@graphql-typed-document-node/core": "^3.1.2",
|
"@graphql-typed-document-node/core": "^3.1.2",
|
||||||
|
"@playwright/test": "^1.32.3",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
"@testing-library/react-hooks": "^8.0.1",
|
||||||
"@types/node": "^18.8.1",
|
"@types/node": "^18.8.1",
|
||||||
|
|
85
apps/taxes/playwright.config.ts
Normal file
85
apps/taxes/playwright.config.ts
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read environment variables from file.
|
||||||
|
* https://github.com/motdotla/dotenv
|
||||||
|
*/
|
||||||
|
// require('dotenv').config();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: "./e2e",
|
||||||
|
/* Run tests in files in parallel */
|
||||||
|
fullyParallel: true,
|
||||||
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
/* Retry on CI only */
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
/* Opt out of parallel tests on CI. */
|
||||||
|
workers: process.env.CI ? 1 : 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. */
|
||||||
|
use: {
|
||||||
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
|
// baseURL: 'http://127.0.0.1:3000',
|
||||||
|
|
||||||
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
|
trace: "on-first-retry",
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configure projects for major browsers */
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: "chromium",
|
||||||
|
use: { ...devices["Desktop Chrome"] },
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* {
|
||||||
|
* 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: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* name: 'Google Chrome',
|
||||||
|
* use: { ..devices['Desktop Chrome'], channel: 'chrome' },
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
],
|
||||||
|
|
||||||
|
/* Run your local dev server before starting the tests */
|
||||||
|
/*
|
||||||
|
* webServer: {
|
||||||
|
* command: 'npm run start',
|
||||||
|
* url: 'http://127.0.0.1:3000',
|
||||||
|
* reuseExistingServer: !process.env.CI,
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
});
|
|
@ -12,7 +12,12 @@
|
||||||
"VERCEL_URL",
|
"VERCEL_URL",
|
||||||
"REST_APL_ENDPOINT",
|
"REST_APL_ENDPOINT",
|
||||||
"REST_APL_TOKEN",
|
"REST_APL_TOKEN",
|
||||||
"ALLOWED_DOMAIN_PATTERN"
|
"ALLOWED_DOMAIN_PATTERN",
|
||||||
|
"CI",
|
||||||
|
"E2E_TAXES_ADMIN_USER_EMAIL",
|
||||||
|
"E2E_TAXES_ADMIN_USER_PASSWORD",
|
||||||
|
"E2E_TAXES_TESTED_APP_MANIFEST",
|
||||||
|
"E2E_TAXES_SALEOR_API_URL"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
"test:ci": "turbo run test:ci",
|
"test:ci": "turbo run test:ci",
|
||||||
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
||||||
"generate": "turbo run generate",
|
"generate": "turbo run generate",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install",
|
||||||
|
"e2e": "turbo run e2e"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/cli": "^2.26.0",
|
"@changesets/cli": "^2.26.0",
|
||||||
|
|
|
@ -14,7 +14,13 @@ module.exports = {
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: ["src/pages/**/*", "src/pages/api/**/*", "vitest.config.ts", "generated/graphql.ts"],
|
files: [
|
||||||
|
"src/pages/**/*",
|
||||||
|
"src/pages/api/**/*",
|
||||||
|
"vitest.config.ts",
|
||||||
|
"generated/graphql.ts",
|
||||||
|
"playwright.config.ts",
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
"import/no-default-export": "off",
|
"import/no-default-export": "off",
|
||||||
},
|
},
|
||||||
|
|
|
@ -1575,6 +1575,9 @@ importers:
|
||||||
'@graphql-typed-document-node/core':
|
'@graphql-typed-document-node/core':
|
||||||
specifier: ^3.1.2
|
specifier: ^3.1.2
|
||||||
version: 3.1.2(graphql@16.6.0)
|
version: 3.1.2(graphql@16.6.0)
|
||||||
|
'@playwright/test':
|
||||||
|
specifier: ^1.32.3
|
||||||
|
version: 1.32.3
|
||||||
'@testing-library/react':
|
'@testing-library/react':
|
||||||
specifier: ^13.4.0
|
specifier: ^13.4.0
|
||||||
version: 13.4.0(react-dom@18.2.0)(react@18.2.0)
|
version: 13.4.0(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
@ -4647,6 +4650,17 @@ packages:
|
||||||
tiny-glob: 0.2.9
|
tiny-glob: 0.2.9
|
||||||
tslib: 2.5.0
|
tslib: 2.5.0
|
||||||
|
|
||||||
|
/@playwright/test@1.32.3:
|
||||||
|
resolution: {integrity: sha512-BvWNvK0RfBriindxhLVabi8BRe3X0J9EVjKlcmhxjg4giWBD/xleLcg2dz7Tx0agu28rczjNIPQWznwzDwVsZQ==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
hasBin: true
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 18.13.0
|
||||||
|
playwright-core: 1.32.3
|
||||||
|
optionalDependencies:
|
||||||
|
fsevents: 2.3.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@popperjs/core@2.11.6:
|
/@popperjs/core@2.11.6:
|
||||||
resolution: {integrity: sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==}
|
resolution: {integrity: sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -13773,6 +13787,12 @@ packages:
|
||||||
mlly: 1.2.0
|
mlly: 1.2.0
|
||||||
pathe: 1.1.0
|
pathe: 1.1.0
|
||||||
|
|
||||||
|
/playwright-core@1.32.3:
|
||||||
|
resolution: {integrity: sha512-SB+cdrnu74ZIn5Ogh/8278ngEh9NEEV0vR4sJFmK04h2iZpybfbqBY0bX6+BLYWVdV12JLLI+JEFtSnYgR+mWg==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
hasBin: true
|
||||||
|
dev: true
|
||||||
|
|
||||||
/png-js@1.0.0:
|
/png-js@1.0.0:
|
||||||
resolution: {integrity: sha512-k+YsbhpA9e+EFfKjTCH3VW6aoKlyNYI6NYdTfDL4CIvFnvsuO84ttonmZE7rc+v23SLTH8XX+5w/Ak9v0xGY4g==}
|
resolution: {integrity: sha512-k+YsbhpA9e+EFfKjTCH3VW6aoKlyNYI6NYdTfDL4CIvFnvsuO84ttonmZE7rc+v23SLTH8XX+5w/Ak9v0xGY4g==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
},
|
},
|
||||||
"generate": {
|
"generate": {
|
||||||
"outputs": ["generated/"]
|
"outputs": ["generated/"]
|
||||||
}
|
},
|
||||||
|
"e2e": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue