Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
722e1ce5cc | ||
![]() |
8cb9cbfbae | ||
![]() |
458835c731 | ||
![]() |
7ab001ecd6 |
20 changed files with 74204 additions and 217 deletions
5
.changeset/small-scissors-roll.md
Normal file
5
.changeset/small-scissors-roll.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"e2e-toolkit": major
|
||||
---
|
||||
|
||||
Introduce e2e-toolkit package (cli) with a single feature - removing all apps from provided env
|
4
packages/e2e-toolkit/.eslintrc
Normal file
4
packages/e2e-toolkit/.eslintrc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": ["saleor"]
|
||||
}
|
1
packages/e2e-toolkit/.gitignore
vendored
Normal file
1
packages/e2e-toolkit/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
dist/
|
16
packages/e2e-toolkit/.graphqlrc.yml
Normal file
16
packages/e2e-toolkit/.graphqlrc.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
schema: graphql/schema.graphql
|
||||
documents: [graphql/**/*.graphql, src/**/*.ts, src/**/*.tsx]
|
||||
extensions:
|
||||
codegen:
|
||||
overwrite: true
|
||||
generates:
|
||||
generated/graphql.ts:
|
||||
config:
|
||||
dedupeFragments: true
|
||||
plugins:
|
||||
- typescript
|
||||
- typescript-operations
|
||||
- typed-document-node
|
||||
generated/schema.graphql:
|
||||
plugins:
|
||||
- schema-ast
|
21125
packages/e2e-toolkit/generated/graphql.ts
Normal file
21125
packages/e2e-toolkit/generated/graphql.ts
Normal file
File diff suppressed because it is too large
Load diff
22579
packages/e2e-toolkit/generated/schema.graphql
Normal file
22579
packages/e2e-toolkit/generated/schema.graphql
Normal file
File diff suppressed because it is too large
Load diff
0
packages/e2e-toolkit/graphql/fragments/.gitkeep
Normal file
0
packages/e2e-toolkit/graphql/fragments/.gitkeep
Normal file
0
packages/e2e-toolkit/graphql/mutations/.gitkeep
Normal file
0
packages/e2e-toolkit/graphql/mutations/.gitkeep
Normal file
5
packages/e2e-toolkit/graphql/mutations/Authorize.graphql
Normal file
5
packages/e2e-toolkit/graphql/mutations/Authorize.graphql
Normal file
|
@ -0,0 +1,5 @@
|
|||
mutation Authorize($email: String!, $password: String!) {
|
||||
tokenCreate(email: $email, password: $password) {
|
||||
token
|
||||
}
|
||||
}
|
10
packages/e2e-toolkit/graphql/mutations/UninstallApp.graphql
Normal file
10
packages/e2e-toolkit/graphql/mutations/UninstallApp.graphql
Normal file
|
@ -0,0 +1,10 @@
|
|||
mutation UninstallApp($appId: ID!) {
|
||||
appDelete(id: $appId) {
|
||||
app {
|
||||
id
|
||||
}
|
||||
errors {
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
0
packages/e2e-toolkit/graphql/queries/.gitkeep
Normal file
0
packages/e2e-toolkit/graphql/queries/.gitkeep
Normal file
11
packages/e2e-toolkit/graphql/queries/FetchAllApps.graphql
Normal file
11
packages/e2e-toolkit/graphql/queries/FetchAllApps.graphql
Normal file
|
@ -0,0 +1,11 @@
|
|||
query FetchAllApps {
|
||||
apps(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
appUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29625
packages/e2e-toolkit/graphql/schema.graphql
Normal file
29625
packages/e2e-toolkit/graphql/schema.graphql
Normal file
File diff suppressed because it is too large
Load diff
0
packages/e2e-toolkit/graphql/subscriptions/.gitkeep
Normal file
0
packages/e2e-toolkit/graphql/subscriptions/.gitkeep
Normal file
42
packages/e2e-toolkit/package.json
Normal file
42
packages/e2e-toolkit/package.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "e2e-toolkit",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "pnpm generate && tsup src/cli.ts --watch",
|
||||
"build": "pnpm generate && tsup src/cli.ts",
|
||||
"start": "node dist/cli.ts",
|
||||
"lint": "next lint",
|
||||
"fetch-schema": "curl https://raw.githubusercontent.com/saleor/saleor/${npm_package_saleor_schemaVersion}/saleor/graphql/schema.graphql > graphql/schema.graphql",
|
||||
"generate": "graphql-codegen",
|
||||
"test": "vitest"
|
||||
},
|
||||
"saleor": {
|
||||
"schemaVersion": "3.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"@urql/exchange-auth": "^1.0.0",
|
||||
"@vitejs/plugin-react": "^3.0.1",
|
||||
"commander": "^10.0.0",
|
||||
"graphql": "^16.6.0",
|
||||
"graphql-tag": "^2.12.6",
|
||||
"jsdom": "^20.0.3",
|
||||
"tsup": "^6.7.0",
|
||||
"vite": "^4.0.4",
|
||||
"vitest": "^0.27.1",
|
||||
"graphql-request": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/cli": "2.13.3",
|
||||
"@graphql-codegen/introspection": "2.2.1",
|
||||
"@graphql-codegen/typed-document-node": "^2.3.3",
|
||||
"@graphql-codegen/typescript": "2.7.3",
|
||||
"@graphql-codegen/typescript-operations": "2.5.3",
|
||||
"@graphql-typed-document-node/core": "^3.1.1",
|
||||
"@types/node": "^18.11.18",
|
||||
"eslint": "8.31.0",
|
||||
"eslint-config-saleor": "workspace:*",
|
||||
"typescript": "4.9.4"
|
||||
}
|
||||
}
|
5
packages/e2e-toolkit/readme.md
Normal file
5
packages/e2e-toolkit/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Usage
|
||||
|
||||
1. `pnpm install`
|
||||
2. `pnpm build --filter="e2e-toolkit"`
|
||||
3. `pnpm start --filter="e2e-toolkit" remove-apps --email [your email] --password [your password] --saleor [saleor graphql/ url]`
|
95
packages/e2e-toolkit/src/cli.ts
Normal file
95
packages/e2e-toolkit/src/cli.ts
Normal file
|
@ -0,0 +1,95 @@
|
|||
import { Command } from "commander";
|
||||
import { GraphQLClient } from "graphql-request";
|
||||
import {
|
||||
AuthorizeDocument,
|
||||
FetchAllAppsDocument,
|
||||
UninstallAppDocument,
|
||||
} from "../generated/graphql";
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("e2e-util")
|
||||
.description("Perform operations for e2e test orchestration")
|
||||
.version("0.0.0");
|
||||
|
||||
program
|
||||
.command("remove-apps")
|
||||
.description("Removes all apps from provided env")
|
||||
.requiredOption("--email <type>", "Email for user with MANAGE_APPS permission")
|
||||
.requiredOption("--password <type>", "Password for the user")
|
||||
.requiredOption("--saleor <type>", "saleor api URL ending with /graphql/")
|
||||
.action(async (fields: { email: string; password: string; saleor: string }) => {
|
||||
const { email, password, saleor } = fields;
|
||||
|
||||
const client = new GraphQLClient(saleor);
|
||||
|
||||
const tokenResponse = await client
|
||||
.request(AuthorizeDocument, {
|
||||
email,
|
||||
password,
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error("Failed with authorization, check params");
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
const token = tokenResponse.tokenCreate?.token;
|
||||
|
||||
if (!token) {
|
||||
console.error("Cant fetch token, check auth");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
client.setHeader("Authorization", `Bearer ${token}`);
|
||||
|
||||
const allAppsResponse = await client.request(FetchAllAppsDocument).catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
console.log("Fetch apps");
|
||||
const apps = allAppsResponse.apps?.edges;
|
||||
|
||||
if (!apps) {
|
||||
console.error("Can fetch apps");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (apps.length === 0) {
|
||||
console.log("No apps installed");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const appsNodes = apps.map((appEdge) => appEdge.node);
|
||||
|
||||
appsNodes.forEach((app) => {
|
||||
console.log(`[${app.id}] ${app.name}`);
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
appsNodes.map((appNode) => {
|
||||
return client
|
||||
.request(UninstallAppDocument, { appId: appNode.id })
|
||||
|
||||
.then((resp) => {
|
||||
if (resp && resp.appDelete?.app?.id) {
|
||||
console.log(`Uninstalled ${appNode.id}`);
|
||||
} else {
|
||||
throw new Error("Failed removing app");
|
||||
}
|
||||
|
||||
return resp;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(`Failed uninstalling ${appNode.id}`);
|
||||
return;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
console.log("Removed apps");
|
||||
});
|
||||
|
||||
program.parse();
|
20
packages/e2e-toolkit/tsconfig.json
Normal file
20
packages/e2e-toolkit/tsconfig.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
13
packages/e2e-toolkit/vitest.config.ts
Normal file
13
packages/e2e-toolkit/vitest.config.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
passWithNoTests: true,
|
||||
environment: "jsdom",
|
||||
setupFiles: "./src/setup-tests.ts",
|
||||
css: false,
|
||||
},
|
||||
});
|
865
pnpm-lock.yaml
865
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue