Skip to content

Commit 21582b2

Browse files
committed
Fix tests issues
1 parent b159a9b commit 21582b2

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

src/models/project.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module.exports = function defineProject(sequelize, DataTypes) {
3434
details: { type: DataTypes.JSON },
3535
challengeEligibility: DataTypes.JSON,
3636
cancelReason: DataTypes.STRING,
37-
version: DataTypes.STRING(15),
3837
templateId: DataTypes.BIGINT,
3938
deletedAt: { type: DataTypes.DATE, allowNull: true },
4039
createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },

src/routes/projectUpgrade/create.spec.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ describe('Project upgrade', () => {
2727
billingAccountId: 1,
2828
name: 'test1',
2929
description: 'test project1',
30+
icon: 'http://example.com/icon1.ico',
31+
question: 'question 1',
32+
info: 'info 1',
33+
aliases: [],
3034
status: 'draft',
3135
details: {
3236
name: 'a specific name',
@@ -50,6 +54,10 @@ describe('Project upgrade', () => {
5054
name: 'template 1',
5155
key: project.type,
5256
category: 'category 1',
57+
icon: 'http://example.com/icon1.ico',
58+
question: 'question 1',
59+
info: 'info 1',
60+
aliases: [],
5361
scope: {
5462
scope1: {
5563
subScope1A: 1,
@@ -239,7 +247,9 @@ describe('Project upgrade', () => {
239247
const commonTest = async (testCompleted, completedOnDate, additionalPhaseName) => {
240248
const migratedProject = await models.Project.find({ id: project.id });
241249
expect(migratedProject.version).to.equal('v3');
242-
const newProjectPhases = await models.ProjectPhase.findAll({ projectId: project.id });
250+
const newProjectPhases = await models.ProjectPhase.findAll({
251+
where: { projectId: project.id },
252+
});
243253
for (const newProjectPhase of newProjectPhases) {
244254
expect(newProjectPhase).to.exist;
245255
expect(newProjectPhase.name).to.be.oneOf(['phase 1', 'phase 2'].concat(additionalPhaseName || []));
@@ -255,7 +265,9 @@ describe('Project upgrade', () => {
255265
expect(newProjectPhase.progress).to.equal(0);
256266
expect(newProjectPhase.endDate).to.equal(null);
257267
}
258-
const newPhaseProducts = await models.PhaseProduct.findAll({ phaseId: newProjectPhase.id });
268+
const newPhaseProducts = await models.PhaseProduct.findAll({ where:
269+
{ phaseId: newProjectPhase.id },
270+
});
259271
for (const newPhaseProduct of newPhaseProducts) {
260272
expect(newPhaseProduct).to.exist;
261273
expect(newPhaseProduct.projectId).to.equal(project.id);
@@ -278,9 +290,9 @@ describe('Project upgrade', () => {
278290
}
279291
}
280292

281-
server.services.pubsub.publish.calledWith('project.phase.added').should.be.true;
282-
server.services.pubsub.publish.calledWith('project.phase.product.added').should.be.true;
283-
server.services.pubsub.publish.calledWith('project.updated').should.be.true;
293+
expect(server.services.pubsub.publish.calledWith('project.phase.added')).to.be.true;
294+
expect(server.services.pubsub.publish.calledWith('project.phase.product.added')).to.be.true;
295+
expect(server.services.pubsub.publish.calledWith('project.updated')).to.be.true;
284296
};
285297

286298
it('should migrate a non completed project to the expected state', async () => {

src/tests/seed.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ models.sequelize.sync({ force: true })
264264
name: 'template 1',
265265
key: 'generic',
266266
category: 'category 1',
267+
icon: 'http://example.com/icon1.ico',
268+
question: 'question 1',
269+
info: 'info 1',
270+
aliases: [],
267271
scope: {
268272
scope1: {
269273
subScope1A: 1,
@@ -307,6 +311,8 @@ models.sequelize.sync({ force: true })
307311
name: 'name 1',
308312
productKey: 'productKey 1',
309313
icon: 'http://example.com/icon1.ico',
314+
question: 'question 1',
315+
info: 'info 1',
310316
brief: 'brief 1',
311317
details: 'details 1',
312318
aliases: {
@@ -338,10 +344,12 @@ models.sequelize.sync({ force: true })
338344
{
339345
name: 'template 2',
340346
productKey: 'productKey 2',
341-
icon: 'http://example.com/icon2.ico',
347+
icon: 'http://example.com/icon1.ico',
348+
question: 'question 1',
349+
info: 'info 1',
342350
brief: 'brief 2',
343351
details: 'details 2',
344-
aliases: {},
352+
aliases: [],
345353
template: {},
346354
createdBy: 3,
347355
updatedBy: 4,
@@ -350,6 +358,8 @@ models.sequelize.sync({ force: true })
350358
name: 'Generic work',
351359
productKey: 'generic_work',
352360
icon: 'http://example.com/icon1.ico',
361+
question: 'question 1',
362+
info: 'info 1',
353363
brief: 'brief 1',
354364
details: 'details 1',
355365
aliases: {
@@ -375,6 +385,8 @@ models.sequelize.sync({ force: true })
375385
name: 'Website product',
376386
productKey: 'website_development',
377387
icon: 'http://example.com/icon1.ico',
388+
question: 'question 1',
389+
info: 'info 1',
378390
brief: 'brief 1',
379391
details: 'details 1',
380392
aliases: {

0 commit comments

Comments
 (0)