|
1 | 1 | # frozen_string_literal: true
|
2 | 2 | require "test_helper"
|
3 | 3 |
|
4 |
| -class DashboardOperationStoreClientsControllerTest < ActionDispatch::IntegrationTest |
5 |
| - def test_it_manages_clients |
6 |
| - assert_equal 0, DummySchema.operation_store.all_clients(page: 1, per_page: 1).total_count |
7 |
| - get graphql_dashboard.operation_store_clients_path |
8 |
| - assert_includes response.body, "0 Clients" |
9 |
| - assert_includes response.body, "To get started, create" |
10 |
| - |
11 |
| - get graphql_dashboard.new_operation_store_client_path |
12 |
| - assert_includes response.body, "New Client" |
13 |
| - |
14 |
| - post graphql_dashboard.operation_store_clients_path, params: { |
15 |
| - client: { |
16 |
| - name: "client-1", |
17 |
| - secret: "abcdefedcba" |
18 |
| - } |
19 |
| - } |
| 4 | +if defined?(GraphQL::Pro) |
| 5 | + class DashboardOperationStoreClientsControllerTest < ActionDispatch::IntegrationTest |
| 6 | + def test_it_manages_clients |
| 7 | + assert_equal 0, DummySchema.operation_store.all_clients(page: 1, per_page: 1).total_count |
| 8 | + get graphql_dashboard.operation_store_clients_path |
| 9 | + assert_includes response.body, "0 Clients" |
| 10 | + assert_includes response.body, "To get started, create" |
20 | 11 |
|
21 |
| - get graphql_dashboard.operation_store_clients_path |
22 |
| - assert_includes response.body, "1 Client" |
| 12 | + get graphql_dashboard.new_operation_store_client_path |
| 13 | + assert_includes response.body, "New Client" |
23 | 14 |
|
24 |
| - get graphql_dashboard.edit_operation_store_client_path(name: "client-1") |
25 |
| - assert_includes response.body, "abcdefedcba" |
| 15 | + post graphql_dashboard.operation_store_clients_path, params: { |
| 16 | + client: { |
| 17 | + name: "client-1", |
| 18 | + secret: "abcdefedcba" |
| 19 | + } |
| 20 | + } |
26 | 21 |
|
27 |
| - patch graphql_dashboard.operation_store_client_path(name: "client-1"), params: { client: { secret: "123456789" } } |
28 |
| - get graphql_dashboard.edit_operation_store_client_path(name: "client-1") |
29 |
| - assert_includes response.body, "123456789" |
| 22 | + get graphql_dashboard.operation_store_clients_path |
| 23 | + assert_includes response.body, "1 Client" |
30 | 24 |
|
31 |
| - delete graphql_dashboard.operation_store_client_path(name: "client-1") |
32 |
| - assert_equal 0, DummySchema.operation_store.all_clients(page: 1, per_page: 1).total_count |
33 |
| - ensure |
34 |
| - DummySchema.operation_store.delete_client("client-1") |
35 |
| - end |
| 25 | + get graphql_dashboard.edit_operation_store_client_path(name: "client-1") |
| 26 | + assert_includes response.body, "abcdefedcba" |
36 | 27 |
|
37 |
| - def test_it_paginates |
38 |
| - 5.times do |i| |
39 |
| - DummySchema.operation_store.upsert_client("client-#{i}", "abcdef") |
| 28 | + patch graphql_dashboard.operation_store_client_path(name: "client-1"), params: { client: { secret: "123456789" } } |
| 29 | + get graphql_dashboard.edit_operation_store_client_path(name: "client-1") |
| 30 | + assert_includes response.body, "123456789" |
| 31 | + |
| 32 | + delete graphql_dashboard.operation_store_client_path(name: "client-1") |
| 33 | + assert_equal 0, DummySchema.operation_store.all_clients(page: 1, per_page: 1).total_count |
| 34 | + ensure |
| 35 | + DummySchema.operation_store.delete_client("client-1") |
40 | 36 | end
|
41 |
| - get graphql_dashboard.operation_store_clients_path(per_page: 2) |
42 |
| - assert_includes response.body, "5 Clients" |
43 |
| - assert_includes response.body, "?page=2&per_page=2" |
44 |
| - assert_includes response.body, "disabled>« prev</button>" |
45 |
| - |
46 |
| - get graphql_dashboard.operation_store_clients_path(per_page: 2, page: 2) |
47 |
| - assert_includes response.body, "?page=1&per_page=2" |
48 |
| - assert_includes response.body, "?page=3&per_page=2" |
49 |
| - |
50 |
| - get graphql_dashboard.operation_store_clients_path(per_page: 2, page: 3) |
51 |
| - assert_includes response.body, "disabled>next »</button>" |
52 |
| - assert_includes response.body, "?page=2&per_page=2" |
53 |
| - ensure |
54 |
| - 5.times do |i| |
55 |
| - DummySchema.operation_store.delete_client("client-#{i}") |
| 37 | + |
| 38 | + def test_it_paginates |
| 39 | + 5.times do |i| |
| 40 | + DummySchema.operation_store.upsert_client("client-#{i}", "abcdef") |
| 41 | + end |
| 42 | + get graphql_dashboard.operation_store_clients_path(per_page: 2) |
| 43 | + assert_includes response.body, "5 Clients" |
| 44 | + assert_includes response.body, "?page=2&per_page=2" |
| 45 | + assert_includes response.body, "disabled>« prev</button>" |
| 46 | + |
| 47 | + get graphql_dashboard.operation_store_clients_path(per_page: 2, page: 2) |
| 48 | + assert_includes response.body, "?page=1&per_page=2" |
| 49 | + assert_includes response.body, "?page=3&per_page=2" |
| 50 | + |
| 51 | + get graphql_dashboard.operation_store_clients_path(per_page: 2, page: 3) |
| 52 | + assert_includes response.body, "disabled>next »</button>" |
| 53 | + assert_includes response.body, "?page=2&per_page=2" |
| 54 | + ensure |
| 55 | + 5.times do |i| |
| 56 | + DummySchema.operation_store.delete_client("client-#{i}") |
| 57 | + end |
56 | 58 | end
|
57 |
| - end |
58 | 59 |
|
59 |
| - def test_it_checks_installed |
60 |
| - get graphql_dashboard.new_operation_store_client_path, params: { schema: GraphQL::Schema } |
61 |
| - assert_includes response.body, "isn't installed for this schema yet" |
| 60 | + def test_it_checks_installed |
| 61 | + get graphql_dashboard.new_operation_store_client_path, params: { schema: GraphQL::Schema } |
| 62 | + assert_includes response.body, "isn't installed for this schema yet" |
| 63 | + end |
62 | 64 | end
|
63 | 65 | end
|
0 commit comments