Skip to content

Commit

Permalink
fix(tests): add FY 2025
Browse files Browse the repository at this point in the history
Adds the fiscal year 2025 to the test database.
  • Loading branch information
jniles committed Jan 1, 2025
1 parent 07c2902 commit e8fdc82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
3 changes: 3 additions & 0 deletions test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ CALL CreateFiscalYear(1, @fiscalYear2022, @superUser, 'Fiscal Year 2023', 12, DA
SET @fiscalYear2024 = 0;
CALL CreateFiscalYear(1, @fiscalYear2024, @superUser, 'Fiscal Year 2024', 12, DATE('2024-01-01'), DATE('2024-12-31'), 'Notes for 2024', @fiscalYear2024);

SET @fiscalYear2025 = 0;
CALL CreateFiscalYear(1, @fiscalYear2025, @superUser, 'Fiscal Year 2025', 12, DATE('2025-01-01'), DATE('2025-12-31'), 'Notes for 2025', @fiscalYear2025);

-- give test permission to all projects
INSERT INTO `project_permission` VALUES (1, 1, 1),(2, 1, 2),(3, 2, 1),(4, 4, 1);

Expand Down
30 changes: 14 additions & 16 deletions test/integration/fiscalYear.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/* global expect, agent */
/* eslint-disable no-unused-expressions */

const moment = require('moment');
const helpers = require('./helpers');

describe('test/integration/fiscalYear Fiscal Year', () => {

// Compute the current year and new FY
const currentYear = (moment(Date.now()).year()).toString();
const newFY = (parseInt(currentYear, 10) + 1);
const currentYear = new Date().getFullYear();
const nextFY = currentYear + 1;

const newFiscalYear = {
label : `A New Fiscal Year ${newFY}`,
start_date : new Date(`${newFY}-01-01 01:00`),
end_date : new Date(`${newFY}-12-31 01:00`),
label : `A New Fiscal Year ${nextFY}`,
start_date : new Date(`${nextFY}-01-01 01:00`),
end_date : new Date(`${nextFY}-12-31 01:00`),
number_of_months : 12,
note : 'Fiscal Year for Integration Test',
closing_account : 111, // 1311 - Résusltat net : Bénéfice *
closing_account : 111, // 1311 - Résultat net : Bénéfice *
};

const responseKeys = [
Expand Down Expand Up @@ -53,19 +51,22 @@ describe('test/integration/fiscalYear Fiscal Year', () => {
it('GET /fiscal returns a list of fiscal_years', () => {
return agent.get('/fiscal')
.then(res => {
helpers.api.listed(res, 2036 - newFY);
// NOTE(@jniles) - the database starts at 2015 for testing FYs.
helpers.api.listed(res, (nextFY - 2015) + 1);
const firstYearPeriods = res.body[0].periods;
expect(firstYearPeriods).to.be.equal(undefined);
})
.catch(helpers.handler);
});

it('GET /fiscal returns a list of fiscal_years with their periods', () => {
return agent.get('/fiscal?includePeriods=1')
return agent.get('/fiscal')
.query({ includePeriods : 1 })
.then(res => {
helpers.api.listed(res, 2036 - newFY);
// NOTE(@jniles) - the database starts at 2015 for testing FYs.
helpers.api.listed(res, (nextFY - 2015) + 1);
const firstYearPeriods = res.body[0].periods;
expect(firstYearPeriods).to.not.be.empty;
expect(firstYearPeriods).to.have.length(14);
})
.catch(helpers.handler);
});
Expand All @@ -74,7 +75,6 @@ describe('test/integration/fiscalYear Fiscal Year', () => {
return agent.get(`/fiscal/${newFiscalYear.id}`)
.then(res => {
expect(res).to.have.status(200);
expect(res).to.be.json;
expect(res.body.id).to.be.equal(newFiscalYear.id);
expect(res.body).to.have.all.keys(responseKeys);
})
Expand All @@ -91,7 +91,7 @@ describe('test/integration/fiscalYear Fiscal Year', () => {
.send(updateData)
.then(res => {
expect(res).to.have.status(200);
expect(res).to.be.json;
expect(res.body.label).to.equal(updateData.label);
})
.catch(helpers.handler);
});
Expand All @@ -103,7 +103,6 @@ describe('test/integration/fiscalYear Fiscal Year', () => {
.send({ params : closingAccount })
.then(res => {
expect(res).to.have.status(200);
expect(res).to.be.json;
expect(res.body.id).to.equal(YEAR_TO_CLOSE);
})
.catch(helpers.handler);
Expand Down Expand Up @@ -138,7 +137,6 @@ describe('test/integration/fiscalYear Fiscal Year', () => {
// matching on the exact MySQL string may differ given different machines
// or database configurations
expect(result).to.have.status(200);
expect(result).to.be.json;
expect(result.body).to.have.all.keys(['start_date']);

const startDate = new Date(result.body.start_date);
Expand Down

0 comments on commit e8fdc82

Please sign in to comment.