Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (appengine) update region tag in appengine/websockets/app.js & appengine/websockets/views/index.pug #3956

Merged
merged 9 commits into from
Feb 8, 2025
Merged
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]
Comment on lines +17 to 18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Per the Samples Style Guide, it's best to remove the old region tags when they are no longer used. Since gae_websockets_app replaces appengine_websockets_app, the latter can be removed.

Suggested change
// [START gae_websockets_app]
// [START appengine_websockets_app]
// [START gae_websockets_app]
const app = require('express')();

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Per the Samples Style Guide, it's best to remove the old region tags when they are no longer used. Since gae_websockets_app replaces appengine_websockets_app, the latter can be removed.

Suggested change
// [END appengine_websockets_app]
// [END gae_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]

Loading