---

type:
- TestCase
tags:
- tests-activitypub-actor
uuid:
- 018c3df2-d6d8-7f62-805b-b71a96cc6170

respec:
  config:
    editors:
    - name: bengo
      url: "https://bengo.is"
      w3cid: 49026
---

# An ActivityPub Object `liked` Collection Must be a Collection

## Background [<sup>?</sup>][test-background]

[ActivityPub][activitypub] [§ 5.5 Liked Collection](https://www.w3.org/TR/activitypub/#liked):
> Every object MAY have a liked collection.
> &hellip;
> The liked collection MUST be either an OrderedCollection or a Collection

## About This Test

This is a Test Case describing a rule to determine whether an ActivityPub Object is in partial conformance with the following behaviors required by [ActivityPub][activitypub].

* [requirement d2db8da3-25d4-4dd9-9c9c-b2793fd899cf](https://socialweb.coop/activitypub/behaviors/d2db8da3-25d4-4dd9-9c9c-b2793fd899cf/) - The liked collection MUST be either an OrderedCollection or a Collection

### Identifier

The identifier of this test is `urn:uuid:018c3df2-d6d8-7f62-805b-b71a96cc6170`.

## Test Subject

The subject of this test is an ActivityPub Object.

## Input [<sup>?</sup>][test-input]

This test requires the following [inputs](act-rules-input) indicating parts of the test subject:

1. `object` - the object whose `liked` property will be tested
    * type: binary
    * constraints
        * should be JSON

## Applicability [<sup>?</sup>][test-applicability]

This test applies to each of the liked collections derived from the values of the property on `object` named `liked`.

### Prerequisites

* `object` is a JSON object
* `object` JSON object has a property named `liked`

### How to Derive Test Targets from Input

* let `targets` be a set
* let `likedValues` be the result of
    * if `object.liked` is an Array, return it
    * else return an Array whose only item is the value of `object.liked`
* for each item in `likedValues`
    * if item is a string
        * let itemFetched be the result of interpreting the string as an ActivityPub Object Identifier and fetching the corresponding ActivityPub Object.
        * add itemFetched to `targets`
    * else add item to `targets`
* return `targets`

## Expectations [<sup>?</sup>][test-expectations]

For every target `target`

* `target` is a JSON object
* `target` has a property named `type`
* the values of the `target`'s `type` property must be one of
    * an array containing the string "Collection"
    * an array containing the string "OrderedCollection"
    * the string "Collection"
    * the string "OrderedCollection"

## Assumptions [<sup>?</sup>][test-assumptions]

## Test Cases [<sup>?</sup>][test-test-cases]

What follows are some specific cases of applything this test.

### Passed Example 1

inputs

* `object`:

  ```json
  {
    "liked": {
      "type": "Collection"
    }
  }
  ```

test targets

* ```json
  {
    "type": "Collection"
  }
  ```

    * outcome: `passed`

### Passed Example 2

inputs

* `object`:

  ```json
  {
    "liked": {
      "type": "OrderedCollection"
    }
  }
  ```

test targets

* ```json
  {
    "type": "OrderedCollection"
  }
  ```

    * outcome: `passed`

### Passed Example 3

inputs

* `object`:

  ```json
  {
    "liked": {
      "type": ["FancyCollection", "OrderedCollection"]
    }
  }
  ```

test targets

* ```json
  {
    "type": ["FancyCollection", "OrderedCollection"]
  }
  ```

    * outcome: `passed`
        * rationale: `"FancyCollection"` is not well-defined here, but this object still passes the test because at least one of the `type` property values is `OrderedCollection` and thus satisfies the requirement as interpreted.

### Failed Example 1 - Likes is a number

inputs

* `object`:

  ```json
  {
    "liked": 1
  }
  ```

test targets

* ```json
  1
  ```

    * outcome: `failed`

### Failed Example 2 - Likes is an empty object

inputs

* `object`:

  ```json
  {
    "liked": {}
  }
  ```

test targets

* ```json
  {}
  ```

    * outcome: `failed`

### Failed Example 3 - Likes object type is array including only `"Link"`

inputs

* `object`:

  ```json
  {
    "liked": {
      "type": ["Link"]
    }
  }
  ```

test targets

* ```json
  {
    "type": ["Link"]
  }
  ```

    * outcome: `failed`

### Inapplicable Example 1

inputs

* `object`:

  ```json
  1
  ```

result

* outcome: `inapplicable`

### Inapplicable Example 2 - object has no likes property

inputs

* `object`:

  ```json
  { "foo": "bar" }
  ```

result

* outcome: `inapplicable`

## Glossary [<sup>?</sup>](https://www.w3.org/TR/act-rules-format/#glossary)

### `outcome`

An outcome is a conclusion that comes from evaluating a test on a test subject. An outcome can be one of the three following types:

* `inapplicable`: No part of the test subject matches the applicability
* `passed`: A test target meets all expectations
* `failed`: A test target does not meet all expectations

## Requirements Mapping [<sup>?</sup>][act-rules-requirements-mapping]

* [ActivityPub requirement d2db8da3-25d4-4dd9-9c9c-b2793fd899cf](https://socialweb.coop/activitypub/behaviors/d2db8da3-25d4-4dd9-9c9c-b2793fd899cf/) - The liked collection MUST be either an OrderedCollection or a Collection
    * Required for Conformance to [ActivityPub][activitypub]
    * Outcome Mapping
        * when every test target has outcome `passed`, the requirement is satisfied by the test subject
        * when any test target has outcome `failed`, the requirement is not satisfied by the test subject
        * when any test target has outcome `inapplicable`, further testing is needed to determine requirement satisfaction

## Issues [<sup>?</sup>][test-issues-list]

## Change Log

* 2023-12-06T07:07:25.913Z - init
* 2023-12-18T04:43:02.981Z - add test cases based on automating this test

[act-rules-requirements-mapping]: https://www.w3.org/TR/act-rules-format/#accessibility-requirements-mapping
[activitypub]: https://www.w3.org/TR/activitypub/
[test-applicability]: https://www.w3.org/TR/act-rules-format/#applicability
[test-assumptions]: https://www.w3.org/TR/act-rules-format/#assumptions
[test-background]: https://www.w3.org/TR/act-rules-format/#background
[test-expectations]: https://www.w3.org/TR/act-rules-format/#expectations
[test-input]: https://www.w3.org/TR/act-rules-format/#input
[test-issues-list]: https://www.w3.org/TR/act-rules-format/#issues-list
[test-test-cases]: https://www.w3.org/TR/act-rules-format/#test-cases
