From 866f7174c84a4c9140867dbc5a3ca2f2c55406f4 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Thu, 3 Oct 2019 18:55:53 -0700 Subject: [PATCH] AppEngine: add region tags (#1504) --- appengine/cloudsql/test/createTables.test.js | 124 ++++++++-------- appengine/cloudsql/test/server.test.js | 96 +++++++------ .../test/createTables.test.js | 126 ++++++++-------- .../cloudsql_postgresql/test/server.test.js | 68 ++++----- .../hello-world/flexible/test/app.test.js | 15 +- .../hello-world/standard/test/app.test.js | 15 +- appengine/pubsub/test/app.test.js | 134 +++++++++--------- appengine/sendgrid/test/app.test.js | 36 ++--- appengine/twilio/test/app.test.js | 78 +++++----- appengine/websockets/test/index.test.js | 24 ++-- 10 files changed, 374 insertions(+), 342 deletions(-) diff --git a/appengine/cloudsql/test/createTables.test.js b/appengine/cloudsql/test/createTables.test.js index 446a9d882f..ac17f54e6a 100644 --- a/appengine/cloudsql/test/createTables.test.js +++ b/appengine/cloudsql/test/createTables.test.js @@ -61,72 +61,74 @@ const getSample = () => { beforeEach(tools.stubConsole); afterEach(tools.restoreConsole); -it('should create a table', async () => { - const sample = getSample(); - const expectedResult = `Successfully created 'visits' table.`; - - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, +describe('gae_flex_mysql_create_tables', () => { + it('should create a table', async () => { + const sample = getSample(); + const expectedResult = `Successfully created 'visits' table.`; + + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); + + assert.ok(sample.mocks.prompt.start.calledOnce); + assert.ok(sample.mocks.prompt.get.calledOnce); + assert.deepStrictEqual( + sample.mocks.prompt.get.firstCall.args[0], + exampleConfig + ); + + await new Promise(r => setTimeout(r, 10)); + assert.ok(sample.mocks.Knex.calledOnce); + assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ + { + client: 'mysql', + connection: exampleConfig, + }, + ]); + + assert.ok(sample.mocks.knex.schema.createTable.calledOnce); + assert.strictEqual( + sample.mocks.knex.schema.createTable.firstCall.args[0], + 'visits' + ); + + assert.ok(console.log.calledWith(expectedResult)); + assert.ok(sample.mocks.knex.destroy.calledOnce); }); - assert.ok(sample.mocks.prompt.start.calledOnce); - assert.ok(sample.mocks.prompt.get.calledOnce); - assert.deepStrictEqual( - sample.mocks.prompt.get.firstCall.args[0], - exampleConfig - ); - - await new Promise(r => setTimeout(r, 10)); - assert.ok(sample.mocks.Knex.calledOnce); - assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ - { - client: 'mysql', - connection: exampleConfig, - }, - ]); - - assert.ok(sample.mocks.knex.schema.createTable.calledOnce); - assert.strictEqual( - sample.mocks.knex.schema.createTable.firstCall.args[0], - 'visits' - ); - - assert.ok(console.log.calledWith(expectedResult)); - assert.ok(sample.mocks.knex.destroy.calledOnce); -}); + it('should handle prompt error', async () => { + const error = new Error('error'); + const sample = getSample(); + sample.mocks.prompt.get = sinon.stub().yields(error); -it('should handle prompt error', async () => { - const error = new Error('error'); - const sample = getSample(); - sample.mocks.prompt.get = sinon.stub().yields(error); + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, + await new Promise(r => setTimeout(r, 10)); + assert.ok(console.error.calledOnce); + assert.ok(console.error.calledWith(error)); + assert.ok(sample.mocks.Knex.notCalled); }); - await new Promise(r => setTimeout(r, 10)); - assert.ok(console.error.calledOnce); - assert.ok(console.error.calledWith(error)); - assert.ok(sample.mocks.Knex.notCalled); -}); - -it('should handle knex creation error', async () => { - const error = new Error('error'); - const sample = getSample(); - sample.mocks.knex.schema.createTable = sinon - .stub() - .returns(Promise.reject(error)); - - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, + it('should handle knex creation error', async () => { + const error = new Error('error'); + const sample = getSample(); + sample.mocks.knex.schema.createTable = sinon + .stub() + .returns(Promise.reject(error)); + + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); + await new Promise(r => setTimeout(r, 10)); + assert.ok(console.error.calledOnce); + assert.ok( + console.error.calledWith(`Failed to create 'visits' table:`, error) + ); + assert.ok(sample.mocks.knex.destroy.calledOnce); }); - await new Promise(r => setTimeout(r, 10)); - assert.ok(console.error.calledOnce); - assert.ok( - console.error.calledWith(`Failed to create 'visits' table:`, error) - ); - assert.ok(sample.mocks.knex.destroy.calledOnce); }); diff --git a/appengine/cloudsql/test/server.test.js b/appengine/cloudsql/test/server.test.js index f082b04225..cb36e4d066 100644 --- a/appengine/cloudsql/test/server.test.js +++ b/appengine/cloudsql/test/server.test.js @@ -77,59 +77,63 @@ const getSample = () => { beforeEach(tools.stubConsole); afterEach(tools.restoreConsole); -it('should set up sample in Postgres', () => { - const sample = getSample(); - - assert.ok(sample.mocks.express.calledOnce); - assert.ok(sample.mocks.Knex.calledOnce); - assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ - { - client: 'mysql', - connection: { - user: sample.mocks.process.env.SQL_USER, - password: sample.mocks.process.env.SQL_PASSWORD, - database: sample.mocks.process.env.SQL_DATABASE, +describe('gae_flex_mysql_connect', () => { + it('should set up sample in Postgres', () => { + const sample = getSample(); + + assert.ok(sample.mocks.express.calledOnce); + assert.ok(sample.mocks.Knex.calledOnce); + assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ + { + client: 'mysql', + connection: { + user: sample.mocks.process.env.SQL_USER, + password: sample.mocks.process.env.SQL_PASSWORD, + database: sample.mocks.process.env.SQL_DATABASE, + }, }, - }, - ]); + ]); + }); }); -it('should record a visit', async () => { - const sample = getSample(); - const expectedResult = 'Last 10 visits:\nTime: 1234, AddrHash: abcd'; - - await request(sample.app) - .get('/') - .expect(200) - .expect(response => { - assert.strictEqual(response.text, expectedResult); - }); -}); +describe('gae_flex_mysql_app', () => { + it('should record a visit', async () => { + const sample = getSample(); + const expectedResult = 'Last 10 visits:\nTime: 1234, AddrHash: abcd'; + + await request(sample.app) + .get('/') + .expect(200) + .expect(response => { + assert.strictEqual(response.text, expectedResult); + }); + }); -it('should handle insert error', async () => { - const sample = getSample(); - const expectedResult = 'insert_error'; + it('should handle insert error', async () => { + const sample = getSample(); + const expectedResult = 'insert_error'; - sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); + sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); - await request(sample.app) - .get('/') - .expect(500) - .expect(response => { - assert.ok(response.text.includes(expectedResult)); - }); -}); + await request(sample.app) + .get('/') + .expect(500) + .expect(response => { + assert.ok(response.text.includes(expectedResult)); + }); + }); -it('should handle read error', async () => { - const sample = getSample(); - const expectedResult = 'read_error'; + it('should handle read error', async () => { + const sample = getSample(); + const expectedResult = 'read_error'; - sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); + sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); - await request(sample.app) - .get('/') - .expect(500) - .expect(response => { - assert.ok(response.text.includes(expectedResult)); - }); + await request(sample.app) + .get('/') + .expect(500) + .expect(response => { + assert.ok(response.text.includes(expectedResult)); + }); + }); }); diff --git a/appengine/cloudsql_postgresql/test/createTables.test.js b/appengine/cloudsql_postgresql/test/createTables.test.js index f9a764faf6..1eff7bcc4d 100644 --- a/appengine/cloudsql_postgresql/test/createTables.test.js +++ b/appengine/cloudsql_postgresql/test/createTables.test.js @@ -61,73 +61,75 @@ const getSample = () => { beforeEach(tools.stubConsole); afterEach(tools.restoreConsole); -it('should create a table', async () => { - const sample = getSample(); - const expectedResult = `Successfully created 'visits' table.`; - - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, +describe('gae_flex_postgres_create_tables', () => { + it('should create a table', async () => { + const sample = getSample(); + const expectedResult = `Successfully created 'visits' table.`; + + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); + + assert.ok(sample.mocks.prompt.start.calledOnce); + assert.ok(sample.mocks.prompt.get.calledOnce); + assert.deepStrictEqual( + sample.mocks.prompt.get.firstCall.args[0], + exampleConfig + ); + + await new Promise(r => setTimeout(r, 10)); + assert.ok(sample.mocks.Knex.calledOnce); + assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ + { + client: 'pg', + connection: exampleConfig, + }, + ]); + + assert.ok(sample.mocks.knex.schema.createTable.calledOnce); + assert.strictEqual( + sample.mocks.knex.schema.createTable.firstCall.args[0], + 'visits' + ); + + assert.ok(console.log.calledWith(expectedResult)); + assert.ok(sample.mocks.knex.destroy.calledOnce); }); - assert.ok(sample.mocks.prompt.start.calledOnce); - assert.ok(sample.mocks.prompt.get.calledOnce); - assert.deepStrictEqual( - sample.mocks.prompt.get.firstCall.args[0], - exampleConfig - ); - - await new Promise(r => setTimeout(r, 10)); - assert.ok(sample.mocks.Knex.calledOnce); - assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ - { - client: 'pg', - connection: exampleConfig, - }, - ]); - - assert.ok(sample.mocks.knex.schema.createTable.calledOnce); - assert.strictEqual( - sample.mocks.knex.schema.createTable.firstCall.args[0], - 'visits' - ); - - assert.ok(console.log.calledWith(expectedResult)); - assert.ok(sample.mocks.knex.destroy.calledOnce); -}); + it('should handle prompt error', async () => { + const error = new Error('error'); + const sample = getSample(); + sample.mocks.prompt.get = sinon.stub().yields(error); -it('should handle prompt error', async () => { - const error = new Error('error'); - const sample = getSample(); - sample.mocks.prompt.get = sinon.stub().yields(error); + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, + await new Promise(r => setTimeout(r, 10)); + assert.ok(console.error.calledOnce); + assert.ok(console.error.calledWith(error)); + assert.ok(sample.mocks.Knex.notCalled); }); - await new Promise(r => setTimeout(r, 10)); - assert.ok(console.error.calledOnce); - assert.ok(console.error.calledWith(error)); - assert.ok(sample.mocks.Knex.notCalled); -}); - -it('should handle knex creation error', async () => { - const error = new Error('error'); - const sample = getSample(); - sample.mocks.knex.schema.createTable = sinon - .stub() - .returns(Promise.reject(error)); - - proxyquire(SAMPLE_PATH, { - knex: sample.mocks.Knex, - prompt: sample.mocks.prompt, + it('should handle knex creation error', async () => { + const error = new Error('error'); + const sample = getSample(); + sample.mocks.knex.schema.createTable = sinon + .stub() + .returns(Promise.reject(error)); + + proxyquire(SAMPLE_PATH, { + knex: sample.mocks.Knex, + prompt: sample.mocks.prompt, + }); + + await new Promise(r => setTimeout(r, 10)); + assert.ok(console.error.calledOnce); + assert.ok( + console.error.calledWith(`Failed to create 'visits' table:`, error) + ); + assert.ok(sample.mocks.knex.destroy.calledOnce); }); - - await new Promise(r => setTimeout(r, 10)); - assert.ok(console.error.calledOnce); - assert.ok( - console.error.calledWith(`Failed to create 'visits' table:`, error) - ); - assert.ok(sample.mocks.knex.destroy.calledOnce); }); diff --git a/appengine/cloudsql_postgresql/test/server.test.js b/appengine/cloudsql_postgresql/test/server.test.js index b8ac2388a9..80af70b407 100644 --- a/appengine/cloudsql_postgresql/test/server.test.js +++ b/appengine/cloudsql_postgresql/test/server.test.js @@ -77,7 +77,7 @@ const getSample = () => { beforeEach(tools.stubConsole); afterEach(tools.restoreConsole); -it('should set up sample in Postgres', () => { +it('gae_flex_postgres_connect should set up sample in Postgres', () => { const sample = getSample(); assert.strictEqual(sample.mocks.express.calledOnce, true); @@ -94,42 +94,44 @@ it('should set up sample in Postgres', () => { ]); }); -it('should record a visit', async () => { - const sample = getSample(); - const expectedResult = 'Last 10 visits:\nTime: 1234, AddrHash: abcd'; - - await request(sample.app) - .get('/') - .expect(200) - .expect(response => { - assert.strictEqual(response.text, expectedResult); - }); -}); +describe('gae_flex_postgres_app', () => { + it('should record a visit', async () => { + const sample = getSample(); + const expectedResult = 'Last 10 visits:\nTime: 1234, AddrHash: abcd'; + + await request(sample.app) + .get('/') + .expect(200) + .expect(response => { + assert.strictEqual(response.text, expectedResult); + }); + }); -it('should handle insert error', async () => { - const sample = getSample(); - const expectedResult = 'insert_error'; + it('should handle insert error', async () => { + const sample = getSample(); + const expectedResult = 'insert_error'; - sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); + sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); - await request(sample.app) - .get('/') - .expect(500) - .expect(response => { - assert.strictEqual(response.text.includes(expectedResult), true); - }); -}); + await request(sample.app) + .get('/') + .expect(500) + .expect(response => { + assert.strictEqual(response.text.includes(expectedResult), true); + }); + }); -it('should handle read error', async () => { - const sample = getSample(); - const expectedResult = 'read_error'; + it('should handle read error', async () => { + const sample = getSample(); + const expectedResult = 'read_error'; - sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); + sample.mocks.knex.limit.returns(Promise.reject(expectedResult)); - await request(sample.app) - .get('/') - .expect(500) - .expect(response => { - assert.strictEqual(response.text.includes(expectedResult), true); - }); + await request(sample.app) + .get('/') + .expect(500) + .expect(response => { + assert.strictEqual(response.text.includes(expectedResult), true); + }); + }); }); diff --git a/appengine/hello-world/flexible/test/app.test.js b/appengine/hello-world/flexible/test/app.test.js index 3bf7b9c3a8..142fa7ba00 100644 --- a/appengine/hello-world/flexible/test/app.test.js +++ b/appengine/hello-world/flexible/test/app.test.js @@ -2,15 +2,18 @@ const app = require('../app'); const request = require('supertest'); -describe('GET /', () => { - it('should get 200', done => { - request(app) - .get('/') - .expect(200, done); - }), +describe('gae_flex_quickstart', () => { + describe('GET /', () => { + it('should get 200', done => { + request(app) + .get('/') + .expect(200, done); + }); + it('should get Hello World', done => { request(app) .get('/') .expect('Hello, world!', done); }); + }); }); diff --git a/appengine/hello-world/standard/test/app.test.js b/appengine/hello-world/standard/test/app.test.js index 3bf7b9c3a8..6854fc36fa 100644 --- a/appengine/hello-world/standard/test/app.test.js +++ b/appengine/hello-world/standard/test/app.test.js @@ -2,15 +2,18 @@ const app = require('../app'); const request = require('supertest'); -describe('GET /', () => { - it('should get 200', done => { - request(app) - .get('/') - .expect(200, done); - }), +describe('gae_node_request_example', () => { + describe('GET /', () => { + it('should get 200', done => { + request(app) + .get('/') + .expect(200, done); + }); + it('should get Hello World', done => { request(app) .get('/') .expect('Hello, world!', done); }); + }); }); diff --git a/appengine/pubsub/test/app.test.js b/appengine/pubsub/test/app.test.js index 10d359da91..395e640b37 100644 --- a/appengine/pubsub/test/app.test.js +++ b/appengine/pubsub/test/app.test.js @@ -64,72 +64,78 @@ afterEach(() => { sandbox.restore(); }); -it('should send a message to Pub/Sub', async () => { - await requestObj - .post('/') - .type('form') - .send({payload: payload}) - .expect(200) - .expect(response => { - assert(new RegExp(/Message \d* sent/).test(response.text)); - }); +describe('gae_flex_pubsub_index', () => { + it('should send a message to Pub/Sub', async () => { + await requestObj + .post('/') + .type('form') + .send({payload: payload}) + .expect(200) + .expect(response => { + assert(new RegExp(/Message \d* sent/).test(response.text)); + }); + }); + + it('should list sent Pub/Sub messages', async () => { + await requestObj + .get('/') + .expect(200) + .expect(response => { + assert( + new RegExp(/Messages received by this instance/).test(response.text) + ); + }); + }); }); -it('should receive incoming Pub/Sub messages', async () => { - await requestObj - .post('/pubsub/push') - .query({token: process.env.PUBSUB_VERIFICATION_TOKEN}) - .send({ - message: { - data: payload, - }, - }) - .expect(200); +describe('gae_flex_pubsub_push', () => { + it('should receive incoming Pub/Sub messages', async () => { + await requestObj + .post('/pubsub/push') + .query({token: process.env.PUBSUB_VERIFICATION_TOKEN}) + .send({ + message: { + data: payload, + }, + }) + .expect(200); + }); + + it('should check for verification token on incoming Pub/Sub messages', async () => { + await requestObj + .post('/pubsub/push') + .field('payload', payload) + .expect(400); + }); }); -it('should verify incoming Pub/Sub push requests', async () => { - sandbox - .stub(OAuth2Client.prototype, 'getFederatedSignonCertsAsync') - .resolves({ - certs: { - fake_id: publicCert, - }, - }); - - await requestObj - .post('/pubsub/authenticated-push') - .set('Authorization', `Bearer ${createFakeToken()}`) - .query({token: process.env.PUBSUB_VERIFICATION_TOKEN}) - .send({ - message: { - data: Buffer.from(payload).toString('base64'), - }, - }) - .expect(200); - - // Make sure the message is visible on the home page - await requestObj - .get('/') - .expect(200) - .expect(response => { - assert(response.text.includes(payload)); - }); -}); - -it('should check for verification token on incoming Pub/Sub messages', async () => { - await requestObj - .post('/pubsub/push') - .field('payload', payload) - .expect(400); -}); - -it('should list sent Pub/Sub messages', async () => { - await requestObj - .get('/') - .expect(200) - .expect(response => { - assert( - new RegExp(/Messages received by this instance/).test(response.text) - ); - }); +describe('gae_flex_pubsub_auth_push', () => { + it('should verify incoming Pub/Sub push requests', async () => { + sandbox + .stub(OAuth2Client.prototype, 'getFederatedSignonCertsAsync') + .resolves({ + certs: { + fake_id: publicCert, + }, + }); + + await requestObj + .post('/pubsub/authenticated-push') + .set('Authorization', `Bearer ${createFakeToken()}`) + .query({token: process.env.PUBSUB_VERIFICATION_TOKEN}) + .send({ + message: { + data: Buffer.from(payload).toString('base64'), + }, + }) + .expect(200); + + // Make sure the message is visible on the home page + await requestObj + .get('/') + .expect(200) + .expect(response => { + assert(response.text.includes(payload)); + }); + }); }); diff --git a/appengine/sendgrid/test/app.test.js b/appengine/sendgrid/test/app.test.js index a97af9f641..57873dde7d 100644 --- a/appengine/sendgrid/test/app.test.js +++ b/appengine/sendgrid/test/app.test.js @@ -5,22 +5,24 @@ const utils = require('@google-cloud/nodejs-repo-tools'); const cwd = path.join(__dirname, '../'); const request = utils.getRequest({cwd: cwd}); -it('GET /: should show homepage template', async () => { - await request - .get('/') - .expect(200) - .expect(response => { - assert(response.text.includes('Hello World!')); - }); -}); +describe('gae_flex_sendgrid', () => { + it('GET /: should show homepage template', async () => { + await request + .get('/') + .expect(200) + .expect(response => { + assert(response.text.includes('Hello World!')); + }); + }); -it('POST /hello: should send an email', async () => { - await request - .post('/hello?test=true') - .type('form') - .send({email: 'testuser@google.com'}) - .expect(200) - .expect(response => { - assert(response.text.includes('Email sent!')); - }); + it('POST /hello: should send an email', async () => { + await request + .post('/hello?test=true') + .type('form') + .send({email: 'testuser@google.com'}) + .expect(200) + .expect(response => { + assert(response.text.includes('Email sent!')); + }); + }); }); diff --git a/appengine/twilio/test/app.test.js b/appengine/twilio/test/app.test.js index 7c5d8c0d32..fde48cb396 100644 --- a/appengine/twilio/test/app.test.js +++ b/appengine/twilio/test/app.test.js @@ -53,47 +53,53 @@ const getSample = () => { }; }; -it('should send an SMS message', () => { - const {supertest} = getSample(); +describe('gae_flex_twilio_send_sms', () => { + it('should send an SMS message', () => { + const {supertest} = getSample(); - return supertest - .get('/sms/send') - .query({to: 1234}) - .expect(200) - .expect(response => { - assert.strictEqual(response.text, 'Message sent.'); - }); + return supertest + .get('/sms/send') + .query({to: 1234}) + .expect(200) + .expect(response => { + assert.strictEqual(response.text, 'Message sent.'); + }); + }); }); -it('should receive an SMS message', () => { - const {supertest, mocks} = getSample(); +describe('gae_flex_twilio_receive_sms', () => { + it('should receive an SMS message', () => { + const {supertest, mocks} = getSample(); - return supertest - .post('/sms/receive') - .send({From: 'Bob', Body: 'hi'}) - .type('form') - .expect(200) - .expect(() => { - assert( - mocks.twilioMessagingRespMock.message.calledWith( - 'Hello, Bob, you said: hi' - ) - ); - }); + return supertest + .post('/sms/receive') + .send({From: 'Bob', Body: 'hi'}) + .type('form') + .expect(200) + .expect(() => { + assert( + mocks.twilioMessagingRespMock.message.calledWith( + 'Hello, Bob, you said: hi' + ) + ); + }); + }); }); -it('should receive a call', () => { - const {supertest, mocks} = getSample(); +describe('gae_flex_twilio_receive_call', () => { + it('should receive a call', () => { + const {supertest, mocks} = getSample(); - return supertest - .post('/call/receive') - .send() - .expect(200) - .expect(() => { - assert( - mocks.twilioVoiceRespMock.say.calledWith( - 'Hello from Google App Engine.' - ) - ); - }); + return supertest + .post('/call/receive') + .send() + .expect(200) + .expect(() => { + assert( + mocks.twilioVoiceRespMock.say.calledWith( + 'Hello from Google App Engine.' + ) + ); + }); + }); }); diff --git a/appengine/websockets/test/index.test.js b/appengine/websockets/test/index.test.js index f1ab8788c3..18dc5929f0 100644 --- a/appengine/websockets/test/index.test.js +++ b/appengine/websockets/test/index.test.js @@ -32,19 +32,21 @@ after(async () => { await browser.close(); }); -it('should process chat message', async () => { - await browserPage.goto('http://localhost:8080'); +describe('appengine_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 browserPage.evaluate(() => { + document.querySelector('input').value = 'test'; + document.querySelector('button').click(); + }); - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise(resolve => setTimeout(resolve, 100)); - const itemText = await browserPage.evaluate( - () => document.querySelector('li').textContent - ); + const itemText = await browserPage.evaluate( + () => document.querySelector('li').textContent + ); - assert.strictEqual(itemText, 'test'); + assert.strictEqual(itemText, 'test'); + }); });