Skip to content

Commit

Permalink
Merge branch 'main' into bp-fork-upstream/fix/FORMS-1012-team-member-…
Browse files Browse the repository at this point in the history
…case-insensitive
  • Loading branch information
bhuvan-aot authored Aug 22, 2024
2 parents 502d5d2 + 0790db2 commit 2f248ff
Show file tree
Hide file tree
Showing 59 changed files with 2,222 additions and 620 deletions.
11 changes: 6 additions & 5 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
version: "2"
exclude_patterns:
- components/
- config/
- "**/db/"
- dist/
- features/
- "**/node_modules/"
- script/
- Tests/
- "**/*.d.ts"
- "**/*_test.go"
- "**/db/"
- "**/node_modules/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- Tests/
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
plugins:
csslint:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ jobs:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{ github.workspace }}/**/lcov.info:lcov
${{ github.workspace }}/**/clover.xml:clover
prefix: ${{ github.workplace }}
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ defineExpose({
cols="12"
md="12"
>
<span :lang="locale">
<span :lang="locale" data-test="submission-schedule-text">
{{ $t('trans.formSettings.submissionsOpenDateRange') }}
<b>{{ form.schedule.openSubmissionDateTime }}</b>
{{ $t('trans.formSettings.to') }}
Expand All @@ -567,21 +567,21 @@ defineExpose({
AVAILABLE_DATES[0]['closeDate'] &&
AVAILABLE_DATES[0]['closeDate'].split(' ')[0]
: ''
}}

{{
}}{{
form.schedule.scheduleType === SCHEDULE_TYPE.CLOSINGDATE
? form.schedule.closeSubmissionDateTime
: ''
}}
</b>
</span>

<span :lang="locale">{{
<span :lang="locale" data-test="late-submission-text">{{
form.schedule.allowLateSubmissions.enabled &&
form.schedule.allowLateSubmissions.forNext.intervalType &&
form.schedule.allowLateSubmissions.forNext.term
? $t('trans.formSettings.allowLateSubmissnInterval') +
? ' ' +
$t('trans.formSettings.allowLateSubmissnInterval') +
' ' +
form.schedule.allowLateSubmissions.forNext.term +
' ' +
form.schedule.allowLateSubmissions.forNext.intervalType +
Expand All @@ -599,9 +599,11 @@ defineExpose({
AVAILABLE_DATES[1]
"
:lang="locale"
>{{ $t('trans.formSettings.scheduleRepetition') }}
<b>{{ form.schedule.repeatSubmission.everyTerm }} </b>
<b>{{ form.schedule.repeatSubmission.everyIntervalType }}</b>
>{{ ' ' + $t('trans.formSettings.scheduleRepetition') }}
<b>
{{ form.schedule.repeatSubmission.everyTerm }}
{{ form.schedule.repeatSubmission.everyIntervalType }}
</b>
{{ $t('trans.formSettings.until') }}
<b>{{ form.schedule.repeatSubmission.repeatUntil }}</b
>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function addNewUsers(users, roles) {
notificationStore.addNotification({
text:
`${user.username}@${user.idpCode}` +
' ' +
t('trans.teamManagement.idpMessage'),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ async function modifyPermissions(userId, permissions) {
...NotificationTypes.SUCCESS,
text: permissions.length
? t('trans.manageSubmissionUsers.sentInviteEmailTo') +
' ' +
`${selectedEmail}`
: t('trans.manageSubmissionUsers.sentUninvitedEmailTo') +
' ' +
`${selectedEmail}`,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { setActivePinia } from 'pinia';
import moment from 'moment';
import { beforeEach, describe, expect, it } from 'vitest';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });

import { useFormStore } from '~/store/form';
import FormScheduleSettings from '~/components/designer/settings/FormScheduleSettings.vue';
Expand Down Expand Up @@ -746,4 +748,76 @@ describe('FormScheduleSettings.vue', () => {

expect(wrapper.vm.AVAILABLE_PERIOD_OPTIONS).toEqual(['quarters', 'years']);
});

it('renders submission schedule and late submission text with correct spacing', async () => {
const TODAY = moment().format('YYYY-MM-DD HH:MM:SS');
const wrapper = mount(FormScheduleSettings, {
global: {
plugins: [pinia],
stubs: {
BaseInfoCard: {
name: 'BaseInfoCard',
template: '<div class="base-info-card-stub"><slot /></div>',
},
BasePanel: {
name: 'BasePanel',
template: '<div class="base-panel-stub"><slot /></div>',
},
},
},
});

// Set up the form store with necessary data
const formStore = useFormStore();
formStore.form = {
schedule: {
enabled: true,
openSubmissionDateTime: TODAY,
closeSubmissionDateTime: moment(TODAY).add(2, 'days').format('YYYY-MM-DD HH:MM:SS'),
scheduleType: ScheduleType.CLOSINGDATE,
allowLateSubmissions: {
enabled: true,
forNext: {
term: 2,
intervalType: 'days'
}
}
}
};

await flushPromises();

// Check submission schedule text
const submissionScheduleText = wrapper.find('[data-test="submission-schedule-text"]');
expect(submissionScheduleText.exists()).toBe(true);

const scheduleTextContent = submissionScheduleText.text();
expect(scheduleTextContent).toContain(t('trans.formSettings.submissionsOpenDateRange'));
expect(scheduleTextContent).toContain(TODAY);
expect(scheduleTextContent).toContain(t('trans.formSettings.to'));
expect(scheduleTextContent).toContain(formStore.form.schedule.closeSubmissionDateTime);

// Check that there's exactly one space before and after the "to" text
const toIndex = scheduleTextContent.indexOf(t('trans.formSettings.to'));
expect(scheduleTextContent[toIndex - 1]).toBe(' ');
expect(scheduleTextContent[toIndex + t('trans.formSettings.to').length]).toBe(' ');

// Check late submission text
const lateSubmissionText = wrapper.find('[data-test="late-submission-text"]');
expect(lateSubmissionText.exists()).toBe(true);

const lateTextContent = lateSubmissionText.text();
const expectedLateText = `${t('trans.formSettings.allowLateSubmissnInterval')} 2 days.`;
expect(lateTextContent).toBe(expectedLateText);

// Check that there's exactly one space before and after the term and interval type
const termIndex = lateTextContent.indexOf('2');
expect(lateTextContent[termIndex - 1]).toBe(' ');
expect(lateTextContent[termIndex + 1]).toBe(' ');

const intervalTypeIndex = lateTextContent.indexOf('days');
expect(lateTextContent[intervalTypeIndex - 1]).toBe(' ');
expect(lateTextContent[intervalTypeIndex + 4]).toBe('.');
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ describe('TeamManagement.vue', () => {

expect(addNotificationSpy).toBeCalledTimes(1);
expect(addNotificationSpy).toBeCalledWith({
text: `${IDIR_USER.username}@${IDIR_USER.idpCode}trans.teamManagement.idpMessage`,
text: `${IDIR_USER.username}@${IDIR_USER.idpCode} trans.teamManagement.idpMessage`,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe('ManageSubmissionUsers.vue', () => {
expect(addNotificationSpy).toHaveBeenCalledWith({
color: 'success',
icon: 'mdi:mdi-check-circle',
text: 'trans.manageSubmissionUsers.sentInviteEmailTojohn@email.com',
text: 'trans.manageSubmissionUsers.sentInviteEmailTo john@email.com',
type: 'success',
});
});
Expand Down
46 changes: 23 additions & 23 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"@json2csv/transforms": "^6.1.3",
"api-problem": "^9.0.2",
"aws-sdk": "^2.1376.0",
"axios": "^0.28.1",
"axios-oauth-client": "^1.5.0",
"axios": "^1.7.4",
"axios-oauth-client": "^2.2.0",
"axios-token-interceptor": "^0.2.0",
"bytes": "^3.1.2",
"compression": "^1.7.4",
Expand Down
26 changes: 17 additions & 9 deletions app/src/components/clientConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ const tokenProvider = require('axios-token-interceptor');

const log = require('./log')(module.filename);

// axios-oauth-client removed the "interceptor" in v2.2.0. Replicate it here.

const getMaxAge = (res) => {
return res.expires_in * 1e3;
};

const headerFormatter = (res) => {
return 'Bearer ' + res.access_token;
};

const interceptor = (tokenProvider, authenticate) => {
const getToken = tokenProvider.tokenCache(authenticate, { getMaxAge });

return tokenProvider({ getToken, headerFormatter });
};

class ClientConnection {
constructor({ tokenUrl, clientId, clientSecret }) {
log.verbose(`Constructed with ${tokenUrl}, ${clientId}, clientSecret`, { function: 'constructor' });
Expand All @@ -19,15 +35,7 @@ class ClientConnection {
// Wraps axios-token-interceptor with oauth-specific configuration,
// fetches the token using the desired claim method, and caches
// until the token expires
oauth.interceptor(
tokenProvider,
oauth.client(axios.create(), {
url: this.tokenUrl,
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
})
)
interceptor(tokenProvider, oauth.clientCredentials(axios.create(), tokenUrl, clientId, clientSecret))
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/forms/admin/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = {
},
updateExternalAPI: async (req, res, next) => {
try {
const response = await service.updateExternalAPI(req.params.id, req.body);
const response = await service.updateExternalAPI(req.params.externalApiId, req.body);
res.status(200).json(response);
} catch (error) {
next(error);
Expand Down
Loading

0 comments on commit 2f248ff

Please sign in to comment.