@raketa-cloud/admin 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +0,0 @@
1
- import { describe, expect, test } from "@jest/globals";
2
- import app from "src/crud/tags";
3
- import { mockGraphql, assertPrivateRequestCalled } from "tests/support/helpers";
4
-
5
- const TAG_QUERY = `
6
- query TagByID($input: IdInput!) {
7
- tag(input: $input) {
8
- id
9
- slug
10
- name
11
- }
12
- }
13
- `;
14
-
15
- describe("Tag edit endpoint", () => {
16
- test("GET /tags/:id/edit", async () => {
17
- const tag = {
18
- id: 1,
19
- name: "Tag 1",
20
- slug: "tag-1",
21
- };
22
-
23
- const requestsMock = mockGraphql(
24
- Promise.resolve({
25
- tag: tag,
26
- }),
27
- );
28
-
29
- const res = await app.request("/tags/1/edit");
30
-
31
- assertPrivateRequestCalled(requestsMock, TAG_QUERY, {
32
- input: { locale: "en", id: 1 },
33
- });
34
-
35
- expect(res.status).toBe(200);
36
-
37
- const content = await res.text();
38
-
39
- expect(content).toContain("Tags");
40
- expect(content).toContain("Tag 1");
41
- expect(content).toContain("tag-1");
42
- });
43
- });
@@ -1,66 +0,0 @@
1
- import { describe, expect, test } from "@jest/globals";
2
- import app from "src/crud/tags";
3
- import { mockGraphql, assertPrivateRequestCalled } from "../../support/helpers";
4
-
5
- const TAGS_QUERY = `
6
- query Tags($input: TagsInput!) {
7
- tags(input: $input) {
8
- list {
9
- id
10
- name
11
- slug
12
- }
13
- pagination {
14
- currentPage
15
- pagesCount
16
- entriesCount
17
- pageSize
18
- }
19
- }
20
- }
21
- `;
22
-
23
- describe("Tags list endpoint", () => {
24
- test("GET /tags", async () => {
25
- const mockRequest = mockGraphql(
26
- Promise.resolve({
27
- tags: {
28
- list: [
29
- {
30
- id: 1,
31
- name: "Tag 1",
32
- slug: "tag-1",
33
- },
34
- {
35
- id: 2,
36
- name: "Tag 2",
37
- slug: "tag-2",
38
- },
39
- ],
40
- pagination: {
41
- currentPage: 1,
42
- pagesCount: 1,
43
- entriesCount: 2,
44
- pageSize: 25,
45
- },
46
- },
47
- }),
48
- );
49
-
50
- const res = await app.request("/tags");
51
-
52
- assertPrivateRequestCalled(mockRequest, TAGS_QUERY, {
53
- input: { locale: "en" },
54
- });
55
-
56
- expect(res.status).toBe(200);
57
-
58
- const content = await res.text();
59
-
60
- expect(content).toContain("Tags");
61
- expect(content).toContain("Tag 1");
62
- expect(content).toContain("tag-1");
63
- expect(content).toContain("Tag 2");
64
- expect(content).toContain("tag-2");
65
- });
66
- });
@@ -1,16 +0,0 @@
1
- import { describe, expect, test } from "@jest/globals";
2
- import app from "src/crud/tags";
3
-
4
- describe("Tags new endpoint", () => {
5
- test("GET /tags/new", async () => {
6
- const res = await app.request("/tags/new");
7
-
8
- expect(res.status).toBe(200);
9
-
10
- const content = await res.text();
11
-
12
- expect(content).toContain("Tags");
13
- expect(content).toContain("Name");
14
- expect(content).toContain("URL");
15
- });
16
- });
@@ -1,87 +0,0 @@
1
- import { describe, expect, test } from "@jest/globals";
2
- import app from "src/crud/tags";
3
- import {
4
- mockMultipleGraphql,
5
- assertPrivateRequestCalled,
6
- assertEmptyBody,
7
- } from "tests/support/helpers";
8
-
9
- const TAG_QUERY = `
10
- query TagByID($input: IdInput!) {
11
- tag(input: $input) {
12
- id
13
- slug
14
- name
15
- }
16
- }
17
- `;
18
-
19
- const UPDATE_TAG_MUTATION = `
20
- mutation UpdateTag($input: UpdateTagInput!) {
21
- updateTag(input: $input) {
22
- tag {
23
- id
24
- slug
25
- name
26
- }
27
- errors {
28
- key
29
- message
30
- codes {
31
- key
32
- placeholders
33
- }
34
- }
35
- }
36
- }
37
- `;
38
-
39
- describe("Tag update endpoint", () => {
40
- test("POST /tags/:id", async () => {
41
- const tag = {
42
- id: 1,
43
- name: "Tag 1",
44
- slug: "tag-1",
45
- };
46
-
47
- const requestsMock = mockMultipleGraphql([
48
- Promise.resolve({
49
- tag: tag,
50
- }),
51
- Promise.resolve({
52
- updateTag: {
53
- tag: tag,
54
- errors: null,
55
- },
56
- }),
57
- ]);
58
-
59
- const formData = new FormData();
60
- formData.set("name", "Updated name");
61
- formData.set("slug", "updated-slug");
62
-
63
- const res = await app.request("/tags/1", {
64
- method: "POST",
65
- body: formData,
66
- });
67
-
68
- assertPrivateRequestCalled(requestsMock, TAG_QUERY, {
69
- input: { locale: "en", id: 1 },
70
- });
71
-
72
- assertPrivateRequestCalled(requestsMock, UPDATE_TAG_MUTATION, {
73
- input: {
74
- locale: "en",
75
- id: 1,
76
- tag: {
77
- name: "Updated name",
78
- slug: "updated-slug",
79
- },
80
- },
81
- });
82
-
83
- expect(res.status).toBe(301);
84
- expect(res.headers.get("Location")).toBe("/tags");
85
- await assertEmptyBody(res);
86
- });
87
- });
@@ -1,53 +0,0 @@
1
- import { expect } from "@jest/globals";
2
- import * as gqlEngine from "../../src/lib/gqlEngine";
3
-
4
- export function mockGraphql(response: any) {
5
- return jest.spyOn(gqlEngine, "gqlRequest").mockImplementation(() => response);
6
- }
7
-
8
- export function mockMultipleGraphql(responses: any) {
9
- let mock = jest.spyOn(gqlEngine, "gqlRequest");
10
-
11
- responses.forEach((response: any) => {
12
- mock = mock.mockImplementationOnce(() => response);
13
- });
14
-
15
- return mock;
16
- }
17
-
18
- export function assertPrivateRequestCalled(
19
- mockRequest: jest.SpyInstance,
20
- query: string,
21
- input: any,
22
- ) {
23
- expect(mockRequest).toBeCalledWith(
24
- "http://gateway.example.com",
25
- query,
26
- input,
27
- {
28
- "x-raketa-identity": undefined,
29
- "x-raketa-project": "1-raketa-gw-priject",
30
- "x-raketa-service": "dxp-private-service",
31
- },
32
- );
33
- }
34
-
35
- export function assertAuthRequestCalled(
36
- mockRequest: jest.SpyInstance,
37
- query: string,
38
- input: any,
39
- ) {
40
- expect(mockRequest).toBeCalledWith(
41
- "https://gateway.raketa.cloud/auth",
42
- query,
43
- input,
44
- );
45
- }
46
-
47
- export async function assertJSONContent(res: Response, content: any) {
48
- expect(await res.text()).toBe(JSON.stringify(content));
49
- }
50
-
51
- export async function assertEmptyBody(res: Response) {
52
- expect(await res.text()).toBe("");
53
- }
@@ -1,9 +0,0 @@
1
- async function jestSetup() {
2
- process.env.RAKETA_GATEWAY_DISPATCH_URL = "http://gateway.example.com";
3
- process.env.RAKETA_GATEWAY_AUTH_URL = "https://gateway.raketa.cloud/auth";
4
- process.env.RAKETA_GATEWAY_PROJECT = "1-raketa-gw-priject";
5
- process.env.RAKETA_DXP_PRIVATE_SERVICE = "dxp-private-service";
6
- process.env.RAKETA_GATEWAY_PRIMARY_USER_POOL = "primary-user-pool";
7
- }
8
-
9
- module.exports = jestSetup;
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "extends": "@repo/typescript-config/react-library.json",
3
- "compilerOptions": {
4
- "jsx": "react-jsx",
5
- "jsxImportSource": "hono/jsx",
6
- "outDir": "dist",
7
- "types": ["node", "@types/jest"],
8
- "baseUrl": ".",
9
- "paths": {
10
- "@App/*": ["src/*"]
11
- }
12
- },
13
- "include": ["src"],
14
- "exclude": ["node_modules", "dist"]
15
- }
@@ -1,30 +0,0 @@
1
- import type { PlopTypes } from "@turbo/gen";
2
-
3
- // Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation
4
-
5
- export default function generator(plop: PlopTypes.NodePlopAPI): void {
6
- // A simple generator to add a new React component to the internal UI library
7
- plop.setGenerator("react-component", {
8
- description: "Adds a new react component",
9
- prompts: [
10
- {
11
- type: "input",
12
- name: "name",
13
- message: "What is the name of the component?",
14
- },
15
- ],
16
- actions: [
17
- {
18
- type: "add",
19
- path: "{{pascalCase name}}.tsx",
20
- templateFile: "templates/component.hbs",
21
- },
22
- {
23
- type: "append",
24
- path: "index.tsx",
25
- pattern: /(?<insertion>\/\/ component exports)/g,
26
- template: 'export * from "./{{pascalCase name}}";',
27
- },
28
- ],
29
- });
30
- }
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
-
3
- interface Props {
4
- children?: React.ReactNode;
5
- }
6
-
7
- export const {{ pascalCase name }} = ({ children }: Props) => {
8
- return (
9
- <div>
10
- <h1>{{ name }}</h1>
11
- {children}
12
- </div>
13
- );
14
- };
package/turbo.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "extends": ["//"],
4
- "pipeline": {
5
- "build": {
6
- "outputs": ["dist/**"]
7
- }
8
- }
9
- }