Skip to content

Commit

Permalink
fix: (appengine) update region tag in appengine/websockets/app.js & a…
Browse files Browse the repository at this point in the history
…ppengine/websockets/views/index.pug (#3956)

* fix: (appengine) update region tag in appengine/websockets/app.js

* fix: (appengine) update region tag in appengine/websockets/views/index.pug

* fix: (websockets) correct test name fromappengine_websockets_app to gae_websockets_app

* added the appengine_websockets_app test

---------

Co-authored-by: Jennifer Davis <[email protected]>
  • Loading branch information
hivanalejandro and iennae authored Feb 8, 2025
1 parent 8173aae commit 102eaed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions appengine/websockets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

'use strict';

// [START gae_websockets_app]
// [START appengine_websockets_app]
const app = require('express')();
app.set('view engine', 'pug');
Expand All @@ -39,5 +40,6 @@ if (module === require.main) {
});
}
// [END appengine_websockets_app]
// [END gae_websockets_app]

module.exports = server;
19 changes: 19 additions & 0 deletions appengine/websockets/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,22 @@ describe('appengine_websockets_app', () => {
assert.strictEqual(itemText, 'test');
});
});

describe('gae_websockets_app', () => {
it('should process chat message', async () => {
await browserPage.goto('http://localhost:8080');

await browserPage.evaluate(() => {
document.querySelector('input').value = 'test';
document.querySelector('button').click();
});

await new Promise(resolve => setTimeout(resolve, 100));

const itemText = await browserPage.evaluate(
() => document.querySelector('li').textContent
);

assert.strictEqual(itemText, 'test');
});
});
6 changes: 6 additions & 0 deletions appengine/websockets/views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- [START gae_websockets_index]
//- [START appengine_websockets_index]
doctype html
html(lang="en")
Expand All @@ -27,17 +28,20 @@ html(lang="en")
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
//- [START gae_websockets_form]
//- [START appengine_websockets_form]
body
ul(id="messages")
form(action="")
input(id="m" autocomplete="off")
button Send
//- [END appengine_websockets_form]
//- [END gae_websockets_form]
script(src="/socket.io/socket.io.js")
script(src="https://code.jquery.com/jquery-1.11.1.js")
script.
// [START gae_websockets_js]
// [START appengine_websockets_js]
$(function () {
var socket = io();
Expand All @@ -54,5 +58,7 @@ html(lang="en")
});
});
// [END appengine_websockets_js]
// [END gae_websockets_js]
//- [END appengine_websockets_index]
//- [END gae_websockets_index]

0 comments on commit 102eaed

Please sign in to comment.