diff --git a/config/init.sql b/config/init.sql index 1be8153b..9f1c9289 100644 --- a/config/init.sql +++ b/config/init.sql @@ -30,6 +30,14 @@ CREATE TABLE IF NOT EXISTS directus_users ( github VARCHAR(255) ); +CREATE TABLE IF NOT EXISTS directus_notifications ( + id CHAR(10), + recipient CHAR(36), + timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + subject VARCHAR(255), + message TEXT +); + INSERT IGNORE INTO adopted_probes ( userId, lastSyncDate, diff --git a/test/tests/unit/adopted-probes.test.ts b/test/tests/unit/adopted-probes.test.ts index f932f577..5da13db6 100644 --- a/test/tests/unit/adopted-probes.test.ts +++ b/test/tests/unit/adopted-probes.test.ts @@ -59,7 +59,7 @@ const defaultConnectedProbe: Probe = { const selectStub = sinon.stub(); const updateStub = sinon.stub(); const deleteStub = sinon.stub(); -const insertStub = sinon.stub(); +const rawStub = sinon.stub(); const whereStub = sinon.stub().returns({ update: updateStub, delete: deleteStub, @@ -70,8 +70,8 @@ const joinStub = sinon.stub().returns({ const sqlStub = sinon.stub().returns({ join: joinStub, where: whereStub, - insert: insertStub, -}); +}) as sinon.SinonStub & {raw: any}; +sqlStub.raw = rawStub; const fetchSocketsStub = sinon.stub().resolves([]); let sandbox: sinon.SinonSandbox; @@ -280,13 +280,13 @@ describe('AdoptedProbes', () => { await adoptedProbes.syncDashboardData(); - expect(insertStub.callCount).to.equal(1); + expect(rawStub.callCount).to.equal(1); - expect(insertStub.args[0]).to.deep.equal([{ + expect(rawStub.args[0]![1]).to.deep.equal({ recipient: '3cff97ae-4a0a-4f34-9f1a-155e6def0a45', subject: 'Adopted probe country change', - message: 'Globalping API detected that your adopted probe with ip: 1.1.1.1 is located at "GB". So its country value changed from "IE" to "GB", and previous custom city value "Dublin" is not applied right now.\n\nIf this change is not right please report in [that issue](https://github.com/jsdelivr/globalping/issues/268).', - }]); + message: 'Globalping API detected that your adopted probe with ip: 1.1.1.1 is located at "GB". So its country value changed from "IE" to "GB", and custom city value "Dublin" is not applied right now.\n\nIf this change is not right please report in [that issue](https://github.com/jsdelivr/globalping/issues/268).', + }); expect(whereStub.callCount).to.equal(1); expect(whereStub.args[0]).to.deep.equal([{ ip: '1.1.1.1' }]);