Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/forms-1331-eve…
Browse files Browse the repository at this point in the history
…nt-stream
  • Loading branch information
usingtechnology committed Aug 22, 2024
2 parents afaca19 + 0d49e8d commit a4a34f0
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 17 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 @@ -749,4 +751,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 @@ -294,7 +294,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

0 comments on commit a4a34f0

Please sign in to comment.