Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1263180
request-multiple-items.subtest.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
request-multiple-items.subtest.js
View Options
const
assert
=
require
(
"assert"
);
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
{
with_running_app
}
=
locreq
(
"test_utils/with-test-app.js"
);
const
{
assert_throws_async
}
=
locreq
(
"test_utils"
);
describe
(
"request multiple items"
,
()
=>
{
const
items
=
{};
async
function
create_resources
(
app
,
rest_api
)
{
app
.
createChip
(
app
.
Sealious
.
Collection
,
{
name
:
"water_areas"
,
fields
:
[
{
name
:
"name"
,
type
:
"text"
,
required
:
true
,
},
{
name
:
"temperature"
,
type
:
"int"
,
required
:
true
,
},
],
});
app
.
createChip
(
app
.
Sealious
.
Collection
,
{
name
:
"seals"
,
fields
:
[
{
name
:
"name"
,
type
:
"text"
,
required
:
true
,
},
{
name
:
"favorite_number"
,
type
:
"int"
,
required
:
true
,
},
{
name
:
"water_area"
,
type
:
"single_reference"
,
params
:
{
collection
:
"water_areas"
},
},
],
});
items
.
baltic_sea
=
await
rest_api
.
post
(
"/api/v1/collections/water_areas"
,
{
name
:
"Baltic Sea"
,
temperature
:
10
,
}
);
items
.
arabic_sea
=
await
rest_api
.
post
(
"/api/v1/collections/water_areas"
,
{
name
:
"Arabic Sea"
,
temperature
:
20
,
}
);
const
seals
=
[
{
name
:
"Hoover"
,
favorite_number
:
3
,
water_area
:
items
.
arabic_sea
.
id
,
},
{
name
:
"Maksiu"
,
favorite_number
:
3
,
water_area
:
items
.
baltic_sea
.
id
,
},
{
name
:
"Nelly"
,
favorite_number
:
8
,
water_area
:
items
.
baltic_sea
.
id
,
},
];
for
(
let
seal
of
seals
)
{
items
[
seal
.
name
]
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"seals"
],
"create"
,
seal
);
}
}
it
(
"returns requested items when using run_action"
,
async
()
=>
with_running_app
(
async
({
app
,
rest_api
})
=>
{
await
create_resources
(
app
,
rest_api
);
const
{
items
:
[
hoover
,
nelly
],
}
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"seals"
,
[
items
.
Hoover
.
id
,
items
.
Nelly
.
id
]],
"show"
);
assert
.
equal
(
hoover
.
name
,
"Hoover"
);
assert
.
equal
(
nelly
.
name
,
"Nelly"
);
}));
it
(
"returns requested items when using rest api"
,
async
()
=>
with_running_app
(
async
({
app
,
rest_api
})
=>
{
await
create_resources
(
app
,
rest_api
);
const
response
=
await
rest_api
.
getSealiousResponse
(
`/api/v1/collections/seals/
${
items
.
Hoover
.
id
}
+
${
items
.
Nelly
.
id
}
?attachments[water_area]=true`
);
assert
.
equal
(
response
.
items
.
length
,
2
);
const
[
hoover
,
nelly
]
=
response
.
items
;
assert
.
equal
(
hoover
.
name
,
"Hoover"
);
assert
.
equal
(
hoover
.
water_area
.
name
,
"Arabic Sea"
);
assert
.
equal
(
nelly
.
name
,
"Nelly"
);
assert
.
equal
(
nelly
.
water_area
.
name
,
"Baltic Sea"
);
}));
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 16:50 (10 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599807
Default Alt Text
request-multiple-items.subtest.js (2 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment