diff --git a/src/components/Views/SchedulingView.vue b/src/components/Views/SchedulingView.vue
index 38b35dd..de870d9 100644
--- a/src/components/Views/SchedulingView.vue
+++ b/src/components/Views/SchedulingView.vue
@@ -107,8 +107,7 @@ const sendObservationRequest = async () => {
method: 'POST',
body: {
'name': 'UserObservation',
- // TO DO: get proposals from user and use the proposal ID here
- 'proposal': 'LCOSchedulerTest',
+ 'proposal': observationData.value.proposal,
'ipp_value': 1.05,
'operator': operatorValue.value,
'observation_type': 'NORMAL',
diff --git a/src/tests/integration/components/beginnerScheduling.test.js b/src/tests/integration/components/beginnerScheduling.test.js
index 3415dd4..fe3fc21 100644
--- a/src/tests/integration/components/beginnerScheduling.test.js
+++ b/src/tests/integration/components/beginnerScheduling.test.js
@@ -5,7 +5,7 @@ import { fetchApiCall } from '../../../utils/api.js'
import { createTestStores } from '../../../utils/testUtils'
import flushPromises from 'flush-promises'
-vi.mock('@/utils/api.js', () => ({
+vi.mock('../../../utils/api.js', () => ({
fetchApiCall: vi.fn()
}))
@@ -18,7 +18,16 @@ describe('BeginnerScheduling.vue', () => {
wrapper = mount(BeginnerScheduling, {
global: {
- plugins: [pinia]
+ plugins: [pinia],
+ stubs: {
+ // Mock ProposalDropdown to control selectedProposal behavior
+ ProposalDropdown: {
+ template: '
',
+ methods: {
+ selectionsComplete: vi.fn()
+ }
+ }
+ }
}
})
})
@@ -41,10 +50,12 @@ describe('BeginnerScheduling.vue', () => {
successCallback(mockResponse)
})
+ // Simulate setting a selected proposal
+ wrapper.vm.selectedProposal = 'TestProposal'
+
// Simulate selecting a date range (which triggers fetchTargets)
const startDate = new Date()
const endDate = new Date()
- // Adds 15 days to the start date
endDate.setDate(startDate.getDate() + 15)
const newDateRange = {
start: startDate,
@@ -52,8 +63,7 @@ describe('BeginnerScheduling.vue', () => {
}
await wrapper.vm.handleDateRangeUpdate(newDateRange)
- // Because the Calendar component is a child of BeginnerScheduling, this test also makes the api call to fetch semester data (which is not tested here)
- expect(fetchApiCall).toHaveBeenCalledTimes(2)
+ expect(fetchApiCall).toHaveBeenCalledTimes(1)
expect(fetchApiCall).toHaveBeenCalledWith({
url: `https://whatsup.lco.global/range/?start=${newDateRange.start.toISOString().split('.')[0]}&end=${newDateRange.end.toISOString().split('.')[0]}&aperture=0m4&mode=full`,
method: 'GET',
@@ -71,4 +81,26 @@ describe('BeginnerScheduling.vue', () => {
expect(wrapper.vm.selectedTargets[0].filters[0].exposure).toBe(300)
expect(wrapper.vm.selectedTargets[0].filters[0].count).toBe(5)
})
+
+ it('emits selectionsComplete with selectedProposal and other values', async () => {
+ // Simulate setting selected values
+ wrapper.vm.targetSelection = { name: 'Target 1' }
+ wrapper.vm.exposureSettings = [{ filter: 'Filter 1', exposureTime: 300 }]
+ wrapper.vm.startDate = '2024-11-18T00:00:00'
+ wrapper.vm.endDate = '2024-11-19T00:00:00'
+ wrapper.vm.selectedProposal = 'TestProposal'
+
+ // Call emitSelections
+ wrapper.vm.emitSelections()
+
+ // Check if the selectionsComplete event was emitted with the correct data
+ expect(wrapper.emitted().selectionsComplete).toBeTruthy()
+ expect(wrapper.emitted().selectionsComplete[0][0]).toEqual({
+ target: { name: 'Target 1' },
+ settings: [{ filter: 'Filter 1', exposureTime: 300 }],
+ startDate: '2024-11-18T00:00:00',
+ endDate: '2024-11-19T00:00:00',
+ proposal: 'TestProposal'
+ })
+ })
})
diff --git a/src/tests/integration/components/schedulingView.test.js b/src/tests/integration/components/schedulingView.test.js
index 939b6a2..a912ad9 100644
--- a/src/tests/integration/components/schedulingView.test.js
+++ b/src/tests/integration/components/schedulingView.test.js
@@ -31,7 +31,8 @@ describe('SchedulingView.vue', () => {
],
startDate: new Date(),
// 1 hour later
- endDate: new Date(new Date().getTime() + 3600 * 1000)
+ endDate: new Date(new Date().getTime() + 3600 * 1000),
+ proposal: 'Test Proposal'
}
const mockRequestList = [
@@ -114,7 +115,7 @@ describe('SchedulingView.vue', () => {
method: 'POST',
body: {
name: 'UserObservation',
- proposal: 'LCOSchedulerTest',
+ proposal: 'Test Proposal',
ipp_value: 1.05,
operator: 'SINGLE',
observation_type: 'NORMAL',