mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
Merge pull request #894 from coralproject/asset-graph-api
Added graph API for assets
This commit is contained in:
+28
-3
@@ -25,8 +25,33 @@ const genAssetsByID = (context, ids) => AssetModel.find({
|
||||
* @param {Object} query the query
|
||||
* @return {Promise} resolves the assets
|
||||
*/
|
||||
const getAssetsByQuery = (context, query) => {
|
||||
return AssetsService.search(query);
|
||||
const getAssetsByQuery = async (context, query) => {
|
||||
|
||||
// If we are requesting based on a limit, ask for one more than we want.
|
||||
const limit = query.limit;
|
||||
if (limit) {
|
||||
query.limit += 1;
|
||||
}
|
||||
|
||||
const nodes = await AssetsService.search(query);
|
||||
|
||||
// The hasNextPage is always handled the same (ask for one more than we need,
|
||||
// if there is one more, than there is more).
|
||||
let hasNextPage = false;
|
||||
if (limit && nodes.length > limit) {
|
||||
|
||||
// There was one more than we expected! Set hasNextPage = true and remove
|
||||
// the last item from the array that we requested.
|
||||
hasNextPage = true;
|
||||
nodes.splice(limit, 1);
|
||||
}
|
||||
|
||||
return {
|
||||
startCursor: nodes && nodes.length > 0 ? nodes[0].created_at : null,
|
||||
endCursor: nodes && nodes.length > 0 ? nodes[nodes.length - 1].created_at : null,
|
||||
hasNextPage,
|
||||
nodes,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,7 +109,7 @@ module.exports = (context) => ({
|
||||
getByURL: (url) => findOrCreateAssetByURL(context, url),
|
||||
|
||||
findByUrl: (url) => findByUrl(context, url),
|
||||
search: (query) => getAssetsByQuery(context, query),
|
||||
getByQuery: (query) => getAssetsByQuery(context, query),
|
||||
getByID: new DataLoader((ids) => genAssetsByID(context, ids)),
|
||||
getForMetrics: () => getAssetsForMetrics(context),
|
||||
getAll: new util.SingletonResolver(() => AssetModel.find({}))
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const errors = require('../../errors');
|
||||
const {
|
||||
UPDATE_ASSET_SETTINGS,
|
||||
UPDATE_ASSET_STATUS,
|
||||
} = require('../../perms/constants');
|
||||
|
||||
const AssetsService = require('../../services/assets');
|
||||
const AssetModel = require('../../models/asset');
|
||||
|
||||
/**
|
||||
* updateSettings will update the settings on an asset.
|
||||
*
|
||||
* @param {Object} ctx graphql context
|
||||
* @param {String} id the asset's id to update
|
||||
* @param {Object} settings the settings to update on the asset.
|
||||
*/
|
||||
const updateSettings = async (ctx, id, settings) => AssetsService.overrideSettings(id, settings);
|
||||
|
||||
/**
|
||||
* updateStatus will update the status of an asset.
|
||||
*
|
||||
* @param {Object} ctx graphql context
|
||||
* @param {String} id the asset's id to update
|
||||
* @param {Object} status the status to change on the asset relating to it's
|
||||
* current state.
|
||||
*/
|
||||
const updateStatus = async (ctx, id, {closedAt, closedMessage}) => AssetModel.update({
|
||||
id,
|
||||
}, {
|
||||
$set: {
|
||||
closedAt,
|
||||
closedMessage
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = (ctx) => {
|
||||
let mutators = {
|
||||
Asset: {
|
||||
updateSettings: () => Promise.reject(errors.ErrNotAuthorized),
|
||||
updateStatus: () => Promise.reject(errors.ErrNotAuthorized)
|
||||
}
|
||||
};
|
||||
|
||||
if (ctx.user) {
|
||||
if (ctx.user.can(UPDATE_ASSET_SETTINGS)) {
|
||||
mutators.Asset.updateSettings = (id, settings) => updateSettings(ctx, id, settings);
|
||||
}
|
||||
|
||||
if (ctx.user.can(UPDATE_ASSET_STATUS)) {
|
||||
mutators.Asset.updateStatus = (id, status) => updateStatus(ctx, id, status);
|
||||
}
|
||||
}
|
||||
|
||||
return mutators;
|
||||
};
|
||||
@@ -3,6 +3,7 @@ const debug = require('debug')('talk:graph:mutators');
|
||||
|
||||
const Comment = require('./comment');
|
||||
const Action = require('./action');
|
||||
const Asset = require('./asset');
|
||||
const Settings = require('./settings');
|
||||
const Tag = require('./tag');
|
||||
const Token = require('./token');
|
||||
@@ -15,6 +16,7 @@ let mutators = [
|
||||
// Load in the core mutators.
|
||||
Comment,
|
||||
Action,
|
||||
Asset,
|
||||
Settings,
|
||||
Tag,
|
||||
Token,
|
||||
|
||||
@@ -25,6 +25,12 @@ const RootMutation = {
|
||||
rejectUsername(_, {input: {id, message}}, {mutators: {User}}) {
|
||||
return wrapResponse(null)(User.rejectUsername({id, message}));
|
||||
},
|
||||
updateAssetSettings(_, {id, input: settings}, {mutators: {Asset}}) {
|
||||
return wrapResponse(null)(Asset.updateSettings(id, settings));
|
||||
},
|
||||
updateAssetStatus(_, {id, input: status}, {mutators: {Asset}}) {
|
||||
return wrapResponse(null)(Asset.updateStatus(id, status));
|
||||
},
|
||||
ignoreUser(_, {id}, {mutators: {User}}) {
|
||||
return wrapResponse(null)(User.ignoreUser({id}));
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ const RootQuery = {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Assets.search(query);
|
||||
return Assets.getByQuery(query);
|
||||
},
|
||||
asset(_, query, {loaders: {Assets}}) {
|
||||
if (query.id) {
|
||||
|
||||
+104
-11
@@ -164,7 +164,19 @@ input AssetsQuery {
|
||||
|
||||
# Limit the number of results to be returned
|
||||
limit: Int = 10
|
||||
|
||||
# open filters assets that are open/closed/all. Not providing this parameter
|
||||
# will return all the assets, true will return assets that are open, and false
|
||||
# will return assets that are closed.
|
||||
open: Boolean
|
||||
|
||||
# sortOrder specifies the order of the sort for the returned Assets.
|
||||
sortOrder: SORT_ORDER = DESC
|
||||
|
||||
# Skip results from the last created_at timestamp.
|
||||
cursor: Cursor
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Tags
|
||||
################################################################################
|
||||
@@ -706,6 +718,22 @@ type Asset {
|
||||
author: String
|
||||
}
|
||||
|
||||
# AssetConnection represents a paginable subset of a asset list.
|
||||
type AssetConnection {
|
||||
|
||||
# Indicates that there are more assets after this subset.
|
||||
hasNextPage: Boolean!
|
||||
|
||||
# Cursor of first asset in subset.
|
||||
startCursor: Cursor
|
||||
|
||||
# Cursor of last asset in subset.
|
||||
endCursor: Cursor
|
||||
|
||||
# Subset of assets.
|
||||
nodes: [Asset!]!
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Errors
|
||||
################################################################################
|
||||
@@ -793,7 +821,7 @@ type RootQuery {
|
||||
comment(id: ID!): Comment
|
||||
|
||||
# All assets. Requires the `ADMIN` role.
|
||||
assets(query: AssetsQuery): [Asset]
|
||||
assets(query: AssetsQuery): AssetConnection
|
||||
|
||||
# Find or create an asset by url, or just find with the ID.
|
||||
asset(id: ID, url: String): Asset
|
||||
@@ -963,6 +991,56 @@ input RejectUsernameInput {
|
||||
message: String!
|
||||
}
|
||||
|
||||
# Configurable settings that can be overridden for the Asset. You must specify
|
||||
# all fields that should be updated.
|
||||
input AssetSettingsInput {
|
||||
|
||||
# premodLinksEnable will put all comments that contain links into premod.
|
||||
premodLinksEnable: Boolean
|
||||
|
||||
# moderation is the moderation mode for the asset.
|
||||
moderation: MODERATION_MODE
|
||||
|
||||
# questionBoxEnable will enable the Question Boxs' content to be visable above
|
||||
# the comment box.
|
||||
questionBoxEnable: Boolean
|
||||
|
||||
# questionBoxContent is the content of the Question Box.
|
||||
questionBoxContent: String
|
||||
|
||||
# questionBoxIcon is the icon for the Question Box.
|
||||
questionBoxIcon: String
|
||||
}
|
||||
|
||||
# UpdateAssetStatusInput contains the input to change the status of a comment as
|
||||
# it relates to being open/closed for commenting.
|
||||
input UpdateAssetStatusInput {
|
||||
|
||||
# closedAt is the time that the asset will be closed for commenting. If this
|
||||
# is null or in the future, it will be open for commenting.
|
||||
closedAt: Date
|
||||
|
||||
# closedMessage is the message to be set on the asset when it is closed. If it
|
||||
# is null, then the message will default to the globally set `closedMessage`.
|
||||
closedMessage: String
|
||||
}
|
||||
|
||||
# UpdateAssetStatusResponse is the response returned with possibly some errors
|
||||
# relating to the update status attempt.
|
||||
type UpdateAssetStatusResponse implements Response {
|
||||
|
||||
# An array of errors relating to the mutation that occurred.
|
||||
errors: [UserError!]
|
||||
}
|
||||
|
||||
# UpdateAssetSettingsResponse is the response returned with possibly some errors
|
||||
# relating to the update settings attempt.
|
||||
type UpdateAssetSettingsResponse implements Response {
|
||||
|
||||
# An array of errors relating to the mutation that occurred.
|
||||
errors: [UserError!]
|
||||
}
|
||||
|
||||
# DeleteActionResponse is the response returned with possibly some errors
|
||||
# relating to the delete action attempt.
|
||||
type DeleteActionResponse implements Response {
|
||||
@@ -1176,31 +1254,35 @@ type RevokeTokenResponse implements Response {
|
||||
type RootMutation {
|
||||
|
||||
# Creates a comment on the asset.
|
||||
createComment(comment: CreateCommentInput!): CreateCommentResponse
|
||||
createComment(comment: CreateCommentInput!): CreateCommentResponse!
|
||||
|
||||
# Creates a flag on an entity.
|
||||
createFlag(flag: CreateFlagInput!): CreateFlagResponse
|
||||
createFlag(flag: CreateFlagInput!): CreateFlagResponse!
|
||||
|
||||
# Creates a don't agree action on an entity.
|
||||
createDontAgree(dontagree: CreateDontAgreeInput!): CreateDontAgreeResponse
|
||||
createDontAgree(dontagree: CreateDontAgreeInput!): CreateDontAgreeResponse!
|
||||
|
||||
# Delete an action based on the action id.
|
||||
deleteAction(id: ID!): DeleteActionResponse
|
||||
|
||||
# Edit a comment
|
||||
editComment(id: ID!, asset_id: ID!, edit: EditCommentInput): EditCommentResponse
|
||||
editComment(id: ID!, asset_id: ID!, edit: EditCommentInput): EditCommentResponse!
|
||||
|
||||
# Sets User status. Requires the `ADMIN` role.
|
||||
setUserStatus(id: ID!, status: USER_STATUS!): SetUserStatusResponse
|
||||
# Mutation is restricted.
|
||||
setUserStatus(id: ID!, status: USER_STATUS!): SetUserStatusResponse!
|
||||
|
||||
# Suspends a user. Requires the `ADMIN` role.
|
||||
suspendUser(input: SuspendUserInput!): SuspendUserResponse
|
||||
# Mutation is restricted.
|
||||
suspendUser(input: SuspendUserInput!): SuspendUserResponse!
|
||||
|
||||
# Reject a username. Requires the `ADMIN` role.
|
||||
rejectUsername(input: RejectUsernameInput!): RejectUsernameResponse
|
||||
# Mutation is restricted.
|
||||
rejectUsername(input: RejectUsernameInput!): RejectUsernameResponse!
|
||||
|
||||
# Sets Comment status. Requires the `ADMIN` role.
|
||||
setCommentStatus(id: ID!, status: COMMENT_STATUS!): SetCommentStatusResponse
|
||||
# Mutation is restricted.
|
||||
setCommentStatus(id: ID!, status: COMMENT_STATUS!): SetCommentStatusResponse!
|
||||
|
||||
# Add a tag.
|
||||
addTag(tag: ModifyTagInput!): ModifyTagResponse!
|
||||
@@ -1208,6 +1290,15 @@ type RootMutation {
|
||||
# Removes a tag.
|
||||
removeTag(tag: ModifyTagInput!): ModifyTagResponse!
|
||||
|
||||
# Updates settings on a given asset.
|
||||
# Mutation is restricted.
|
||||
updateAssetSettings(id: ID!, input: AssetSettingsInput!): UpdateAssetSettingsResponse!
|
||||
|
||||
# Updates the status of an asset allowing you to close/reopen an asset for
|
||||
# commenting.
|
||||
# Mutation is restricted.
|
||||
updateAssetStatus(id: ID!, input: UpdateAssetStatusInput!): UpdateAssetStatusResponse!
|
||||
|
||||
# updateSettings will update the global settings.
|
||||
# Mutation is restricted.
|
||||
updateSettings(input: UpdateSettingsInput!): UpdateSettingsResponse!
|
||||
@@ -1220,13 +1311,15 @@ type RootMutation {
|
||||
ignoreUser(id: ID!): IgnoreUserResponse
|
||||
|
||||
# CreateToken will create a token that is attached to the current user.
|
||||
# Mutation is restricted.
|
||||
createToken(input: CreateTokenInput!): CreateTokenResponse!
|
||||
|
||||
# RevokeToken will revoke an existing token.
|
||||
# Mutation is restricted.
|
||||
revokeToken(input: RevokeTokenInput!): RevokeTokenResponse!
|
||||
|
||||
# Stop Ignoring comments by another user
|
||||
stopIgnoringUser(id: ID!): StopIgnoringUserResponse
|
||||
# Stop Ignoring comments by another user.
|
||||
stopIgnoringUser(id: ID!): StopIgnoringUserResponse!
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -16,6 +16,8 @@ module.exports = {
|
||||
UPDATE_CONFIG: 'UPDATE_CONFIG',
|
||||
CREATE_TOKEN: 'CREATE_TOKEN',
|
||||
REVOKE_TOKEN: 'REVOKE_TOKEN',
|
||||
UPDATE_ASSET_SETTINGS: 'UPDATE_ASSET_SETTINGS',
|
||||
UPDATE_ASSET_STATUS: 'UPDATE_ASSET_STATUS',
|
||||
UPDATE_SETTINGS: 'UPDATE_SETTINGS',
|
||||
UPDATE_WORDLIST: 'UPDATE_WORDLIST',
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ module.exports = (user, perm) => {
|
||||
case types.CREATE_TOKEN:
|
||||
case types.REVOKE_TOKEN:
|
||||
return check(user, ['ADMIN']);
|
||||
case types.UPDATE_ASSET_SETTINGS:
|
||||
return check(user, ['ADMIN', 'MODERATOR']);
|
||||
case types.UPDATE_ASSET_STATUS:
|
||||
return check(user, ['ADMIN', 'MODERATOR']);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const scraper = require('../../../services/scraper');
|
||||
const errors = require('../../../errors');
|
||||
const AssetsService = require('../../../services/assets');
|
||||
|
||||
@@ -88,25 +87,6 @@ router.get('/:asset_id', async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Adds the asset id to the queue to be scraped.
|
||||
router.post('/:asset_id/scrape', async (req, res, next) => {
|
||||
try {
|
||||
|
||||
// Send back the asset.
|
||||
let asset = await AssetsService.findById(req.params.asset_id);
|
||||
if (!asset) {
|
||||
return next(errors.ErrNotFound);
|
||||
}
|
||||
|
||||
let job = await scraper.create(asset);
|
||||
|
||||
// Send the job back for monitoring.
|
||||
res.status(201).json(job);
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
}
|
||||
});
|
||||
|
||||
router.put('/:asset_id/settings', async (req, res, next) => {
|
||||
try {
|
||||
await AssetsService.overrideSettings(req.params.asset_id, req.body);
|
||||
|
||||
+51
-14
@@ -108,19 +108,57 @@ module.exports = class AssetsService {
|
||||
* @param {String} value string to search by.
|
||||
* @return {Promise}
|
||||
*/
|
||||
static search({value, skip, limit} = {}) {
|
||||
if (!value) {
|
||||
return AssetsService.all(skip, limit);
|
||||
} else {
|
||||
return AssetModel
|
||||
.find({
|
||||
$text: {
|
||||
$search: value
|
||||
}
|
||||
})
|
||||
.skip(skip)
|
||||
.limit(limit);
|
||||
static search({value, limit, open, sortOrder, cursor} = {}) {
|
||||
let assets = AssetModel.find({});
|
||||
|
||||
if (value) {
|
||||
assets.merge({
|
||||
$text: {
|
||||
$search: value
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (open != null) {
|
||||
if (open) {
|
||||
assets.merge({
|
||||
$or: [
|
||||
{
|
||||
closedAt: null
|
||||
},
|
||||
{
|
||||
closedAt: {
|
||||
$gt: Date.now()
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
} else {
|
||||
assets.merge({
|
||||
closedAt: {
|
||||
$lt: Date.now()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor) {
|
||||
if (sortOrder === 'DESC') {
|
||||
assets.merge({
|
||||
created_at: {
|
||||
$lt: cursor,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
assets.merge({
|
||||
created_at: {
|
||||
$gt: cursor,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return assets.sort({created_at: sortOrder === 'DESC' ? -1 : 1}).limit(limit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,10 +223,9 @@ module.exports = class AssetsService {
|
||||
// That's it!
|
||||
}
|
||||
|
||||
static all(skip = null, limit = null) {
|
||||
static all(limit = undefined) {
|
||||
return AssetModel
|
||||
.find({})
|
||||
.skip(skip)
|
||||
.limit(limit);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
const {graphql} = require('graphql');
|
||||
|
||||
const schema = require('../../../../graph/schema');
|
||||
const Context = require('../../../../graph/context');
|
||||
const UserModel = require('../../../../models/user');
|
||||
const SettingsService = require('../../../../services/settings');
|
||||
const AssetModel = require('../../../../models/asset');
|
||||
|
||||
const {expect} = require('chai');
|
||||
|
||||
describe('graph.mutations.updateAssetSettings', () => {
|
||||
let asset;
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init();
|
||||
asset = await AssetModel.create({url: 'http://new.test.com/'});
|
||||
});
|
||||
|
||||
const QUERY = `
|
||||
mutation UpdateAssetStatus($id: ID!, $settings: AssetSettingsInput!) {
|
||||
updateAssetSettings(id: $id, input: $settings) {
|
||||
errors {
|
||||
translation_key
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
describe('context with different user roles', () => {
|
||||
|
||||
[
|
||||
{error: 'NOT_AUTHORIZED'},
|
||||
{roles: ['ADMIN', 'MODERATOR']},
|
||||
{roles: ['MODERATOR']},
|
||||
].forEach(({roles, error}) => {
|
||||
it(roles ? roles.join(', ') : '<None>', async () => {
|
||||
const user = new UserModel({roles});
|
||||
const ctx = new Context({user});
|
||||
|
||||
const settings = {
|
||||
premodLinksEnable: false,
|
||||
moderation: 'POST',
|
||||
questionBoxEnable: true,
|
||||
questionBoxContent: 'Question?',
|
||||
questionBoxIcon: '<Icon>',
|
||||
};
|
||||
|
||||
const res = await graphql(schema, QUERY, {}, ctx, {
|
||||
id: asset.id,
|
||||
settings,
|
||||
});
|
||||
if (res.errors) {
|
||||
console.error(res.errors);
|
||||
}
|
||||
expect(res.errors).to.be.empty;
|
||||
|
||||
if (error) {
|
||||
expect(res.data.updateAssetSettings.errors).to.not.be.empty;
|
||||
expect(res.data.updateAssetSettings.errors[0]).to.have.property('translation_key', error);
|
||||
} else {
|
||||
expect(res.data.updateAssetSettings.errors).to.be.null;
|
||||
|
||||
const retrievedAsset = await AssetModel.findOne({id: asset.id});
|
||||
Object.keys(settings).forEach((key) => {
|
||||
expect(retrievedAsset.settings).to.have.property(key, settings[key]);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
const {graphql} = require('graphql');
|
||||
|
||||
const schema = require('../../../../graph/schema');
|
||||
const Context = require('../../../../graph/context');
|
||||
const UserModel = require('../../../../models/user');
|
||||
const SettingsService = require('../../../../services/settings');
|
||||
const AssetModel = require('../../../../models/asset');
|
||||
|
||||
const {expect} = require('chai');
|
||||
|
||||
describe('graph.mutations.updateAssetStatus', () => {
|
||||
let asset;
|
||||
beforeEach(async () => {
|
||||
await SettingsService.init();
|
||||
asset = await AssetModel.create({url: 'http://new.test.com/'});
|
||||
});
|
||||
|
||||
const QUERY = `
|
||||
mutation UpdateAssetStatus($id: ID!, $status: UpdateAssetStatusInput!) {
|
||||
updateAssetStatus(id: $id, input: $status) {
|
||||
errors {
|
||||
translation_key
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
describe('context with different user roles', () => {
|
||||
|
||||
[
|
||||
{error: 'NOT_AUTHORIZED'},
|
||||
{roles: ['ADMIN', 'MODERATOR']},
|
||||
{roles: ['MODERATOR']},
|
||||
].forEach(({roles, error}) => {
|
||||
it(roles ? roles.join(', ') : '<None>', async () => {
|
||||
const user = new UserModel({roles});
|
||||
const ctx = new Context({user});
|
||||
|
||||
const closedAt = (new Date()).toISOString();
|
||||
const closedMessage = 'my closed message!';
|
||||
|
||||
const res = await graphql(schema, QUERY, {}, ctx, {
|
||||
id: asset.id,
|
||||
status: {
|
||||
closedAt,
|
||||
closedMessage,
|
||||
},
|
||||
});
|
||||
if (res.errors) {
|
||||
console.error(res.errors);
|
||||
}
|
||||
expect(res.errors).to.be.empty;
|
||||
|
||||
if (error) {
|
||||
expect(res.data.updateAssetStatus.errors).to.not.be.empty;
|
||||
expect(res.data.updateAssetStatus.errors[0]).to.have.property('translation_key', error);
|
||||
} else {
|
||||
expect(res.data.updateAssetStatus.errors).to.be.null;
|
||||
|
||||
const retrievedAsset = await AssetModel.findOne({id: asset.id});
|
||||
expect(retrievedAsset.closedAt).to.not.be.null;
|
||||
expect(retrievedAsset).to.have.property('closedMessage', closedMessage);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -74,12 +74,10 @@ describe('graph.queries.asset', () => {
|
||||
|
||||
expect(asset.nodes).to.have.length(2);
|
||||
expect(asset.hasNextPage).to.be.false;
|
||||
expect(asset.nodes[0]).to.have.property('id', comments[1].id);
|
||||
expect(asset.nodes[1]).to.have.property('id', comments[0].id);
|
||||
expect(asset.nodes.map(({id}) => id)).to.have.members(comments.slice(0, 2).map(({id}) => id));
|
||||
expect(otherAsset.nodes).to.have.length(2);
|
||||
expect(otherAsset.hasNextPage).to.be.false;
|
||||
expect(otherAsset.nodes[0]).to.have.property('id', comments[3].id);
|
||||
expect(otherAsset.nodes[1]).to.have.property('id', comments[2].id);
|
||||
expect(otherAsset.nodes.map(({id}) => id)).to.have.members(comments.slice(2, 4).map(({id}) => id));
|
||||
|
||||
for (let node of asset.nodes) {
|
||||
for (let otherNode of otherAsset.nodes) {
|
||||
|
||||
Reference in New Issue
Block a user