Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spine-web",
"version": "1.9.0-SNAPSHOT.11",
"version": "1.9.0-SNAPSHOT.12",
"license": "Apache-2.0",
"description": "A JS client for interacting with Spine applications.",
"homepage": "https://spine.io",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void addChild(String key, StoredJson data) {
}

/**
* Adds a `null` child to the value under a specified key.
* Adds a {@code null} child to the value under a specified key.
*/
public void addNullChild(String key) {
value.add(key, null);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client-js-tests",
"version": "1.9.0-SNAPSHOT.11",
"version": "1.9.0-SNAPSHOT.12",
"license": "Apache-2.0",
"description": "Tests of a `spine-web` JS library against the Spine-based application.",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import assert from 'assert';
import {fail} from '../test-helpers';
import TestEnvironment from '../given/test-environment';
import {Task} from '@testProto/spine/web/test/given/task_pb';
import {client} from './given/firebase-client';

describe('Subscription made with FirebaseClient should', function () {

// Big timeout allows to receive model state changes during tests.
this.timeout(120 * 1000);

it('reflects updates of a task that gets created -> renamed -> deleted', (done) => {
const INITIAL_TASK_NAME = 'Initial task name';
const UPDATED_NAME = 'Updated task name';

const createCommand = TestEnvironment.createTaskCommand({
withPrefix: 'spine-web-test-entity-lifecycle-subscription',
named: INITIAL_TASK_NAME
});
const sendCreateTask = () => client.command(createCommand)
.onError(fail(done, 'Unexpected error while creating a task.'))
.onImmediateRejection(fail(done, 'Unexpected rejection while creating a task.'))
.post();

const taskId = createCommand.getId();
const taskIdValue = taskId.getValue();

const renameCommand = TestEnvironment.renameTaskCommand({
withId: taskIdValue,
to: UPDATED_NAME
});
const sendRenameTask = () => client.command(renameCommand)
.onError(fail(done, 'Unexpected error while renaming a task.'))
.onImmediateRejection(fail(done, 'Unexpected rejection while renaming a task.'))
.post();

const deleteCommand = TestEnvironment.deleteTaskCommand(taskId);
const sendDeleteTask = () => client.command(deleteCommand)
.onError(fail(done, 'Unexpected error while deleting a task.'))
.onImmediateRejection(fail(done, 'Unexpected rejection while deleting a task.'))
.post();

let reportTaskCreated, reportTaskRenamed, reportTaskDeleted;
const taskCreated = new Promise(resolve => reportTaskCreated = resolve);
const taskRenamed = new Promise(resolve => reportTaskRenamed = resolve);
const taskDeleted = new Promise(resolve => reportTaskDeleted = resolve);

client.subscribeTo(Task)
.byId(taskId)
.post()
.then(async ({itemAdded, itemChanged, itemRemoved, unsubscribe}) => {
itemAdded.subscribe(nextItem => {
const actualIdValue = nextItem.getId().getValue();
const actualTaskName = nextItem.getName();
assert.strictEqual(actualIdValue, taskIdValue,
`New task has ID "${actualIdValue}", expected "${taskIdValue}".`
);
assert.strictEqual(actualTaskName, INITIAL_TASK_NAME,
`Task is named "${actualTaskName}", expected "${INITIAL_TASK_NAME}".`
);

reportTaskCreated();
});

itemChanged.subscribe(nextItem => {
const actualIdValue = nextItem.getId().getValue();
const actualTaskName = nextItem.getName();
assert.strictEqual(actualIdValue, taskIdValue,
`Updated task has ID "${actualIdValue}", expected "${taskIdValue}".`
);
assert.strictEqual(actualTaskName, UPDATED_NAME,
`Renamed task is named "${actualTaskName}", expected "${UPDATED_NAME}".`
);

reportTaskRenamed();
});

itemRemoved.subscribe(nextItem => {
const actualIdValue = nextItem.getId().getValue();
assert.strictEqual(actualIdValue, taskIdValue,
`Deleted task has ID "${actualIdValue}", expected "${taskIdValue}".`
);

reportTaskDeleted();
});

sendCreateTask();
await taskCreated;

sendRenameTask();
await taskRenamed;

sendDeleteTask();
await taskDeleted;
})
.then(done)
.catch(fail(done));
});
});
11 changes: 10 additions & 1 deletion integration-tests/js-tests/test/given/test-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import {v4 as newUuid} from 'uuid';
import {TenantIds} from '@lib/client/tenant';
import {CreateTask, RenameTask} from '@testProto/spine/web/test/given/commands_pb';
import {CreateTask, RenameTask, DeleteTask} from '@testProto/spine/web/test/given/commands_pb';
import {TaskId} from '@testProto/spine/web/test/given/task_pb';
import {AddUserInfo} from '@testProto/spine/web/test/given/user_commands_pb';
import {UserId} from '@testProto/spine/core/user_id_pb';
Expand Down Expand Up @@ -106,7 +106,16 @@ export default class TestEnvironment {
command.setName(newName);

return command;
}

/**
* @param {TaskId} taskId
* @returns {DeleteTask}
*/
static deleteTaskCommand(taskId) {
const command = new DeleteTask();
command.setId(taskId);
return command;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ TaskReassigned handle(ReassignTask command) {
return taskReassigned.vBuild();
}

@Assign
TaskDeleted handle(DeleteTask command) {
TaskDeleted.Builder taskDeleted = TaskDeleted.newBuilder()
.setId(command.getId())
.setWhen(currentTime());
if (state().hasAssignee()) {
taskDeleted.setAssignee(state().getAssignee());
}

return taskDeleted.vBuild();
}

@Apply
private void on(TaskCreated event) {
builder().setId(event.getId())
Expand All @@ -96,4 +108,9 @@ private void on(TaskRenamed event) {
private void on(TaskReassigned event) {
builder().setAssignee(event.getTo());
}

@Apply
private void on(TaskDeleted event) {
setDeleted(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ message ReassignTask {
spine.core.UserId new_assignee = 2 [(required) = true];
}

message DeleteTask {

TaskId id = 1;
}

message CreateProject {

ProjectId id = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ message TaskReassigned {
google.protobuf.Timestamp when = 4 [(required) = true];
}

message TaskDeleted {

TaskId id = 1;

spine.core.UserId assignee = 2;

google.protobuf.Timestamp when = 3 [(required) = true];
}

message ProjectCreated {

Expand Down
32 changes: 16 additions & 16 deletions license-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client-js:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine:spine-client-js:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -370,10 +370,10 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:16 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:11:39 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).


#NPM dependencies of `spine-web@1.9.0-SNAPSHOT.11`
#NPM dependencies of `spine-web@1.9.0-SNAPSHOT.12`

## `Production` dependencies:

Expand Down Expand Up @@ -407,7 +407,7 @@ This report was generated on **Tue Jan 31 14:15:16 WET 2023** using [Gradle-Lice
1. **rxjs@7.8.0**
* Licenses: Apache-2.0
* Repository: [https://github.com/reactivex/rxjs](https://github.com/reactivex/rxjs)
1. **spine-web@1.9.0-SNAPSHOT.11**
1. **spine-web@1.9.0-SNAPSHOT.12**
* Licenses: Apache-2.0
* Repository: [https://github.com/SpineEventEngine/web](https://github.com/SpineEventEngine/web)
1. **tr46@0.0.3**
Expand Down Expand Up @@ -1969,7 +1969,7 @@ This report was generated on **Tue Jan 31 14:15:16 WET 2023** using [Gradle-Lice
1. **spdx-satisfies@4.0.1**
* Licenses: MIT
* Repository: [https://github.com/kemitchell/spdx-satisfies.js](https://github.com/kemitchell/spdx-satisfies.js)
1. **spine-web@1.9.0-SNAPSHOT.11**
1. **spine-web@1.9.0-SNAPSHOT.12**
* Licenses: Apache-2.0
* Repository: [https://github.com/SpineEventEngine/web](https://github.com/SpineEventEngine/web)
1. **sprintf-js@1.0.3**
Expand Down Expand Up @@ -2148,12 +2148,12 @@ This report was generated on **Tue Jan 31 14:15:16 WET 2023** using [Gradle-Lice
* Repository: [https://github.com/sindresorhus/yocto-queue](https://github.com/sindresorhus/yocto-queue)


This report was generated on **Tue Jan 31 2023 14:15:17 GMT+0000 (Western European Standard Time)** using [NPM License Checker](https://github.com/davglass/license-checker) library.
This report was generated on **Mon Mar 06 2023 15:11:40 GMT+0000 (Western European Standard Time)** using [NPM License Checker](https://github.com/davglass/license-checker) library.




# Dependencies of `io.spine.gcloud:spine-firebase-web:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine.gcloud:spine-firebase-web:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.fasterxml.jackson **Name:** jackson-bom **Version:** 2.14.2 **No license information found**
Expand Down Expand Up @@ -2996,12 +2996,12 @@ This report was generated on **Tue Jan 31 2023 14:15:17 GMT+0000 (Western Europe
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:25 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:11:46 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-js-tests:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine:spine-js-tests:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -3396,12 +3396,12 @@ This report was generated on **Tue Jan 31 14:15:25 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:31 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:11:53 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-test-app:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine:spine-test-app:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.fasterxml.jackson **Name:** jackson-bom **Version:** 2.14.2 **No license information found**
Expand Down Expand Up @@ -5031,12 +5031,12 @@ This report was generated on **Tue Jan 31 14:15:31 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:33 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:11:56 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-testutil-web:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine:spine-testutil-web:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -5497,12 +5497,12 @@ This report was generated on **Tue Jan 31 14:15:33 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:35 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:11:59 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-web:1.9.0-SNAPSHOT.11`
# Dependencies of `io.spine:spine-web:1.9.0-SNAPSHOT.12`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -6002,4 +6002,4 @@ This report was generated on **Tue Jan 31 14:15:35 WET 2023** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Tue Jan 31 14:15:39 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Mar 06 15:12:03 WET 2023** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-web</artifactId>
<version>1.9.0-SNAPSHOT.11</version>
<version>1.9.0-SNAPSHOT.12</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -58,7 +58,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-server</artifactId>
<version>1.9.0-SNAPSHOT.6</version>
<version>1.9.0-SNAPSHOT.10</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -94,7 +94,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-testutil-client</artifactId>
<version>1.9.0-SNAPSHOT.6</version>
<version>1.9.0-SNAPSHOT.10</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -168,7 +168,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-client</artifactId>
<version>1.9.0-SNAPSHOT.6</version>
<version>1.9.0-SNAPSHOT.10</version>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
Expand Down
Loading