Skip to content

Commit 8111720

Browse files
committed
add: test for edge case of empty Select in Rollup
- testing the edge case of the fix "65-rollup-with-empty-select-fix"
1 parent 2507d0f commit 8111720

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

tests/EndpointDatabaseTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,32 @@ public function it_throws_a_notion_exception_bad_request()
157157

158158
Notion::database('8284f3ff77e24d4a939d19459e4d6bdc')->query();
159159
}
160+
161+
## EDGE CASES
162+
163+
/** @test */
164+
public function it_queries_a_database_with_a_rollup_property_with_empty_selects()
165+
{
166+
// success /v1/databases/DATABASE_DOES_EXIST/query
167+
Http::fake([
168+
'https://api.notion.com/v1/databases/11971214ce574df7a58389c1deda61d7/query*' => Http::response(
169+
json_decode(file_get_contents("tests/stubs/endpoints/databases/response_query_rollup_empty_select_200.json"), true),
170+
200,
171+
['Headers']
172+
),
173+
]);
174+
175+
$result = Notion::database('11971214ce574df7a58389c1deda61d7')->query();
176+
177+
$this->assertInstanceOf(PageCollection::class, $result);
178+
179+
$resultCollection = $result->asCollection();
180+
181+
$this->assertIsIterable($resultCollection);
182+
$this->assertContainsOnly(Page::class, $resultCollection);
183+
184+
// check page object
185+
$page = $resultCollection->first();
186+
$this->assertEquals(0, $page->getProperty('Rollup')->getContent()->count());
187+
}
160188
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"object": "list",
3+
"results": [
4+
{
5+
"object": "page",
6+
"id": "1321e6b6-0771-48bb-9814-6501c2ec3c32",
7+
"created_time": "2022-07-09T10:29:00.000Z",
8+
"last_edited_time": "2022-07-09T10:45:00.000Z",
9+
"created_by": {
10+
"object": "user",
11+
"id": "04536682-601a-4531-a18f-4fa89fdf14a8"
12+
},
13+
"last_edited_by": {
14+
"object": "user",
15+
"id": "04531682-603a-4531-a18f-1fa89fdfb4a8"
16+
},
17+
"cover": null,
18+
"icon": null,
19+
"parent": {
20+
"type": "database_id",
21+
"database_id": "15971224-ce57-4df1-a583-89c1deca63d7"
22+
},
23+
"archived": false,
24+
"properties": {
25+
"Test Rollup Problem": {
26+
"id": "G|zT",
27+
"type": "relation",
28+
"relation": [
29+
{
30+
"id": "dcad104b-222c-4d63-b83e-852f22612f4a"
31+
},
32+
{
33+
"id": "3611ce31-ae52-45dc-bc5a-10626ca19ab5"
34+
}
35+
]
36+
},
37+
"Rollup": {
38+
"id": "JCh`",
39+
"type": "rollup",
40+
"rollup": {
41+
"type": "array",
42+
"array": [
43+
{
44+
"type": "select",
45+
"select": null
46+
}
47+
],
48+
"function": "show_original"
49+
}
50+
},
51+
"Name": {
52+
"id": "title",
53+
"type": "title",
54+
"title": []
55+
}
56+
},
57+
"url": "https:\/\/www.notion.so\/132de616077648bb98146501c2ec3c32"
58+
},
59+
{
60+
"object": "page",
61+
"id": "43dd6b90-6bde-48ea-9f06-79fee96de99c",
62+
"created_time": "2022-07-09T10:29:00.000Z",
63+
"last_edited_time": "2022-07-09T10:29:00.000Z",
64+
"created_by": {
65+
"object": "user",
66+
"id": "04d36682-603a-4531-a18f-4fa19fdfb4a8"
67+
},
68+
"last_edited_by": {
69+
"object": "user",
70+
"id": "04d36682-603a-4531-a18f-4fa891dfb4a8"
71+
},
72+
"cover": null,
73+
"icon": null,
74+
"parent": {
75+
"type": "database_id",
76+
"database_id": "1d9712d4-ce57-4df7-a583-89c1dedac3d7"
77+
},
78+
"archived": false,
79+
"properties": {
80+
"Test Rollup Problem": {
81+
"id": "G|zT",
82+
"type": "relation",
83+
"relation": []
84+
},
85+
"Rollup": {
86+
"id": "JCh`",
87+
"type": "rollup",
88+
"rollup": {
89+
"type": "array",
90+
"array": [],
91+
"function": "show_original"
92+
}
93+
},
94+
"Name": {
95+
"id": "title",
96+
"type": "title",
97+
"title": []
98+
}
99+
},
100+
"url": "https:\/\/www.notion.so\/430d6b9d6b9e48ea9f067cfee96de9d9"
101+
},
102+
{
103+
"object": "page",
104+
"id": "788c67fe-84d2-4cf8-aab6-6cd6448d98b2",
105+
"created_time": "2022-07-09T10:29:00.000Z",
106+
"last_edited_time": "2022-07-09T10:29:00.000Z",
107+
"created_by": {
108+
"object": "user",
109+
"id": "04536682-613a-4531-a18f-4fd89fdfb4a8"
110+
},
111+
"last_edited_by": {
112+
"object": "user",
113+
"id": "04436622-603a-4531-a18f-4fa89fdfb4a8"
114+
},
115+
"cover": null,
116+
"icon": null,
117+
"parent": {
118+
"type": "database_id",
119+
"database_id": "15972224-ce57-4df7-a583-89c1de1a63dd"
120+
},
121+
"archived": false,
122+
"properties": {
123+
"Test Rollup Problem": {
124+
"id": "G|zT",
125+
"type": "relation",
126+
"relation": []
127+
},
128+
"Rollup": {
129+
"id": "JCh`",
130+
"type": "rollup",
131+
"rollup": {
132+
"type": "array",
133+
"array": [],
134+
"function": "show_original"
135+
}
136+
},
137+
"Name": {
138+
"id": "title",
139+
"type": "title",
140+
"title": []
141+
}
142+
},
143+
"url": "https:\/\/www.notion.so\/788c67de84d24cf8dab660d64c8998b2"
144+
}
145+
],
146+
"next_cursor": null,
147+
"has_more": false
148+
}

0 commit comments

Comments
 (0)