diff --git a/src/client/javascript/scripts/sample.js b/src/client/javascript/scripts/user1.js
similarity index 64%
rename from src/client/javascript/scripts/sample.js
rename to src/client/javascript/scripts/user1.js
index 71467d6..d5b0515 100644
--- a/src/client/javascript/scripts/sample.js
+++ b/src/client/javascript/scripts/user1.js
@@ -20,28 +20,24 @@ describe('Interactivity tests', function() {
describe('Basic connection tests', () => {
beforeEach(() => {
// Start a new test case.
+ task.bindListener('user2')
return task.startCase();
});
afterEach(() => {
// Stop a test case.
return task.stopCase();
});
- it('Each endpoint sends a message should success.', (done) => {
- task.addEventListener('test1', (event) => {
- if (event.sender != task.role) {
- // Execute done when received message from another endpoint.
- done();
- }
+ it('testConnect should success.', (done) => {
+ task.run(() => {
+ task.notifyWorkflowLock('user1', 'connect');
+ }).then(() => {
+ return task.waitWorkflowLock('user2', 'connect')
+ }).then(() => {
+ console.log("test success")
+ done()
+ }).catch(err => {
+ done(err)
})
- task.send('test1', 'Something useful.');
- });
- it('Each endpoint sends a message again should success.', (done) => {
- task.addEventListener('test2', (event) => {
- if (event.sender != task.role) {
- done();
- }
- })
- task.send('test2', 'Something more useful.');
});
});
diff --git a/src/client/javascript/scripts/user2.js b/src/client/javascript/scripts/user2.js
new file mode 100644
index 0000000..ede87ba
--- /dev/null
+++ b/src/client/javascript/scripts/user2.js
@@ -0,0 +1,50 @@
+import {
+ Task
+} from "../../sdk/javascript/task.js";
+
+const expect = chai.expect;
+const url = window.location.href;
+const task = new Task({
+ taskId: (new URL(document.location)).searchParams.get("taskId"),
+ role: (new URL(document.location)).searchParams.get('role'),
+ socketIoUrl: 'https://' + document.domain + ':8080/'
+});
+
+describe('Interactivity tests', function() {
+ this.timeout(50000); // Set a larger timeout value because it needs to wait for another endpoint's response.
+ document.getElementById('iatf-state').innerText = 'Preparing';
+ before(() => {
+ // Start a new task.
+ return task.start();
+ });
+ describe('Basic connection tests', () => {
+ beforeEach(() => {
+ // Start a new test case.
+ task.bindListener('user1')
+ return task.startCase();
+ });
+ afterEach(() => {
+ // Stop a test case.
+ return task.stopCase();
+ });
+ it('testConnect should success.', (done) => {
+ task.waitWorkflowLock('user1', 'connect').then(() => {
+ console.log("user1 connect")
+ }).then(() => {
+ task.run(() => {
+ task.notifyWorkflowLock('user2', 'connect');
+ })
+ done()
+ }).catch(err => {
+ done(err)
+ })
+ });
+ });
+
+ after(() => {
+ document.getElementById('iatf-state').innerText = 'Finished';
+ });
+}).timeout(50000);
+
+mocha.checkLeaks();
+mocha.run();
\ No newline at end of file
diff --git a/src/client/javascript/test.html b/src/client/javascript/user1.html
similarity index 92%
rename from src/client/javascript/test.html
rename to src/client/javascript/user1.html
index 18fbb4b..09ebb9e 100644
--- a/src/client/javascript/test.html
+++ b/src/client/javascript/user1.html
@@ -17,6 +17,6 @@
-
+