|
1 | 1 | # frozen_string_literal: true
|
2 | 2 | require "test_helper"
|
3 | 3 |
|
4 |
| -class DashboardOperationStoreOperationsControllerTest < ActionDispatch::IntegrationTest |
5 |
| - def teardown |
6 |
| - DummySchema.operation_store.delete_client("client-1") |
7 |
| - DummySchema.operation_store.delete_client("client-2") |
8 |
| - super |
9 |
| - end |
10 |
| - def test_it_lists_shows_and_archives_operations |
11 |
| - get graphql_dashboard.operation_store_operations_path |
12 |
| - assert_includes response.body, "Add your first stored operations with" |
13 |
| - |
14 |
| - get graphql_dashboard.operation_store_operations_path(client_name: "client-5000") |
15 |
| - assert_includes response.body, "Add your first stored operations with" |
16 |
| - |
17 |
| - get graphql_dashboard.archived_operation_store_operations_path |
18 |
| - assert_includes response.body, "Archived operations</a> will appear here." |
19 |
| - |
20 |
| - get graphql_dashboard.archived_operation_store_client_operations_path(client_name: "client-5000") |
21 |
| - assert_includes response.body, "Archived operations</a> will appear here." |
22 |
| - |
23 |
| - os = DummySchema.operation_store |
24 |
| - os.upsert_client("client-1", "abcdef") |
25 |
| - os.add(body: "query GetTypename { __typename }", operation_alias: "GetTypename", client_name: "client-1") |
26 |
| - os.add(body: "query GetAliasedTypename { t: __typename }", operation_alias: "get-aliased-typename", client_name: "client-1") |
27 |
| - |
28 |
| - os.upsert_client("client-2", "abcdef") |
29 |
| - os.add(body: "query GetTypename { __typename }", operation_alias: "GetTypename2", client_name: "client-2") |
30 |
| - |
31 |
| - get graphql_dashboard.operation_store_operations_path |
32 |
| - assert_includes response.body, "2 Active" |
33 |
| - assert_includes response.body, "GetTypename" |
34 |
| - assert_includes response.body, "GetAliasedTypename" |
35 |
| - |
36 |
| - get graphql_dashboard.operation_store_operations_path(sort_by: "name", order_dir: "asc", per_page: 1) |
37 |
| - refute_includes response.body, "GetTypename" |
38 |
| - assert_includes response.body, "GetAliasedTypename" |
39 |
| - |
40 |
| - get graphql_dashboard.operation_store_operations_path(sort_by: "name", order_dir: "desc", per_page: 1) |
41 |
| - assert_includes response.body, "GetTypename" |
42 |
| - refute_includes response.body, "GetAliasedTypename" |
43 |
| - |
44 |
| - get graphql_dashboard.operation_store_operations_path(client_name: "client-2") |
45 |
| - assert_includes response.body, "1 Active" |
46 |
| - assert_includes response.body, "GetTypename" |
47 |
| - refute_includes response.body, "GetAliasedTypename" |
48 |
| - |
49 |
| - get graphql_dashboard.operation_store_operation_path(digest: "4cd12cc333c91f78e8f781933ecc783d") |
50 |
| - assert_includes response.body, "GetAliasedTypename" |
51 |
| - assert_includes response.body, "client-1" |
52 |
| - assert_includes response.body, "Query.__typename" |
53 |
| - |
54 |
| - post graphql_dashboard.archive_operation_store_client_operations_path(client_name: "client-1", operation_aliases: ["get-aliased-typename"]) |
55 |
| - post graphql_dashboard.archive_operation_store_operations_path(digests: ["b161214b11847649e7f36cc50e1257a1"]) |
56 |
| - |
57 |
| - get graphql_dashboard.operation_store_operations_path |
58 |
| - assert_includes response.body, "0 Active" |
59 |
| - assert_includes response.body, "2 Archived" |
60 |
| - |
61 |
| - get graphql_dashboard.archived_operation_store_operations_path |
62 |
| - assert_includes response.body, "2 Archived" |
63 |
| - assert_includes response.body, "0 Active" |
64 |
| - |
65 |
| - get graphql_dashboard.operation_store_operations_path(client_name: "client-2") |
66 |
| - assert_includes response.body, "0 Active" |
67 |
| - assert_includes response.body, "1 Archived" |
68 |
| - end |
69 |
| - |
70 |
| - def test_it_checks_installed |
71 |
| - get graphql_dashboard.new_operation_store_client_path, params: { schema: GraphQL::Schema } |
72 |
| - assert_includes response.body, "isn't installed for this schema yet" |
| 4 | +if defined?(GraphQL::Pro) |
| 5 | + class DashboardOperationStoreOperationsControllerTest < ActionDispatch::IntegrationTest |
| 6 | + def teardown |
| 7 | + DummySchema.operation_store.delete_client("client-1") |
| 8 | + DummySchema.operation_store.delete_client("client-2") |
| 9 | + super |
| 10 | + end |
| 11 | + def test_it_lists_shows_and_archives_operations |
| 12 | + get graphql_dashboard.operation_store_operations_path |
| 13 | + assert_includes response.body, "Add your first stored operations with" |
| 14 | + |
| 15 | + get graphql_dashboard.operation_store_operations_path(client_name: "client-5000") |
| 16 | + assert_includes response.body, "Add your first stored operations with" |
| 17 | + |
| 18 | + get graphql_dashboard.archived_operation_store_operations_path |
| 19 | + assert_includes response.body, "Archived operations</a> will appear here." |
| 20 | + |
| 21 | + get graphql_dashboard.archived_operation_store_client_operations_path(client_name: "client-5000") |
| 22 | + assert_includes response.body, "Archived operations</a> will appear here." |
| 23 | + |
| 24 | + os = DummySchema.operation_store |
| 25 | + os.upsert_client("client-1", "abcdef") |
| 26 | + os.add(body: "query GetTypename { __typename }", operation_alias: "GetTypename", client_name: "client-1") |
| 27 | + os.add(body: "query GetAliasedTypename { t: __typename }", operation_alias: "get-aliased-typename", client_name: "client-1") |
| 28 | + |
| 29 | + os.upsert_client("client-2", "abcdef") |
| 30 | + os.add(body: "query GetTypename { __typename }", operation_alias: "GetTypename2", client_name: "client-2") |
| 31 | + |
| 32 | + get graphql_dashboard.operation_store_operations_path |
| 33 | + assert_includes response.body, "2 Active" |
| 34 | + assert_includes response.body, "GetTypename" |
| 35 | + assert_includes response.body, "GetAliasedTypename" |
| 36 | + |
| 37 | + get graphql_dashboard.operation_store_operations_path(sort_by: "name", order_dir: "asc", per_page: 1) |
| 38 | + refute_includes response.body, "GetTypename" |
| 39 | + assert_includes response.body, "GetAliasedTypename" |
| 40 | + |
| 41 | + get graphql_dashboard.operation_store_operations_path(sort_by: "name", order_dir: "desc", per_page: 1) |
| 42 | + assert_includes response.body, "GetTypename" |
| 43 | + refute_includes response.body, "GetAliasedTypename" |
| 44 | + |
| 45 | + get graphql_dashboard.operation_store_operations_path(client_name: "client-2") |
| 46 | + assert_includes response.body, "1 Active" |
| 47 | + assert_includes response.body, "GetTypename" |
| 48 | + refute_includes response.body, "GetAliasedTypename" |
| 49 | + |
| 50 | + get graphql_dashboard.operation_store_operation_path(digest: "4cd12cc333c91f78e8f781933ecc783d") |
| 51 | + assert_includes response.body, "GetAliasedTypename" |
| 52 | + assert_includes response.body, "client-1" |
| 53 | + assert_includes response.body, "Query.__typename" |
| 54 | + |
| 55 | + post graphql_dashboard.archive_operation_store_client_operations_path(client_name: "client-1", operation_aliases: ["get-aliased-typename"]) |
| 56 | + post graphql_dashboard.archive_operation_store_operations_path(digests: ["b161214b11847649e7f36cc50e1257a1"]) |
| 57 | + |
| 58 | + get graphql_dashboard.operation_store_operations_path |
| 59 | + assert_includes response.body, "0 Active" |
| 60 | + assert_includes response.body, "2 Archived" |
| 61 | + |
| 62 | + get graphql_dashboard.archived_operation_store_operations_path |
| 63 | + assert_includes response.body, "2 Archived" |
| 64 | + assert_includes response.body, "0 Active" |
| 65 | + |
| 66 | + get graphql_dashboard.operation_store_operations_path(client_name: "client-2") |
| 67 | + assert_includes response.body, "0 Active" |
| 68 | + assert_includes response.body, "1 Archived" |
| 69 | + end |
| 70 | + |
| 71 | + def test_it_checks_installed |
| 72 | + get graphql_dashboard.new_operation_store_client_path, params: { schema: GraphQL::Schema } |
| 73 | + assert_includes response.body, "isn't installed for this schema yet" |
| 74 | + end |
73 | 75 | end
|
74 | 76 | end
|
0 commit comments