|
1 | | -import pytest |
2 | 1 | from uuid import uuid4 |
3 | | -from users.tests.factories import UserFactory |
| 2 | + |
| 3 | +import pytest |
| 4 | +from pytest import mark |
| 5 | + |
4 | 6 | from conferences.tests.factories import ConferenceFactory |
5 | | -from submissions.tests.factories import ( |
6 | | - ProposalMaterialFactory, |
7 | | - SubmissionFactory, |
8 | | - SubmissionTagFactory, |
9 | | -) |
10 | 7 | from files_upload.tests.factories import ( |
11 | 8 | FileFactory, |
12 | 9 | ParticipantAvatarFileFactory, |
13 | 10 | ProposalMaterialFileFactory, |
14 | 11 | ) |
15 | | -from pytest import mark |
16 | | - |
17 | 12 | from participants.models import Participant |
18 | 13 | from submissions.models import ProposalMaterial, Submission |
| 14 | +from submissions.tests.factories import ( |
| 15 | + ProposalMaterialFactory, |
| 16 | + SubmissionFactory, |
| 17 | + SubmissionTagFactory, |
| 18 | +) |
| 19 | +from users.tests.factories import UserFactory |
19 | 20 |
|
20 | 21 | pytestmark = mark.django_db |
21 | 22 |
|
@@ -1070,6 +1071,8 @@ def test_can_edit_submission_outside_cfp(graphql_client, user): |
1070 | 1071 | new_duration=new_duration, |
1071 | 1072 | new_type=new_type, |
1072 | 1073 | new_languages=["en"], |
| 1074 | + new_title=submission.title.data, # Keep title unchanged |
| 1075 | + new_abstract=submission.abstract.data, # Keep abstract unchanged |
1073 | 1076 | ) |
1074 | 1077 |
|
1075 | 1078 | assert response["data"]["updateSubmission"]["__typename"] == "Submission" |
@@ -1301,3 +1304,85 @@ def test_update_submission_with_do_not_record_true(graphql_client, user): |
1301 | 1304 |
|
1302 | 1305 | submission.refresh_from_db() |
1303 | 1306 | assert submission.do_not_record is True |
| 1307 | + |
| 1308 | + |
| 1309 | +def test_cannot_update_title_after_cfp_deadline(graphql_client, user): |
| 1310 | + conference = ConferenceFactory( |
| 1311 | + topics=("life", "diy"), |
| 1312 | + languages=("en",), |
| 1313 | + durations=("10", "20"), |
| 1314 | + active_cfp=False, # CFP deadline is in the past |
| 1315 | + audience_levels=("adult", "senior"), |
| 1316 | + submission_types=("talk", "workshop"), |
| 1317 | + ) |
| 1318 | + |
| 1319 | + submission = SubmissionFactory( |
| 1320 | + speaker_id=user.id, |
| 1321 | + custom_topic="life", |
| 1322 | + custom_duration="10m", |
| 1323 | + custom_audience_level="adult", |
| 1324 | + custom_submission_type="talk", |
| 1325 | + languages=["en"], |
| 1326 | + tags=["python", "ml"], |
| 1327 | + conference=conference, |
| 1328 | + ) |
| 1329 | + |
| 1330 | + original_title = submission.title.localize("en") |
| 1331 | + |
| 1332 | + graphql_client.force_login(user) |
| 1333 | + |
| 1334 | + response = _update_submission( |
| 1335 | + graphql_client, |
| 1336 | + submission=submission, |
| 1337 | + new_title={"en": "Updated Title After Deadline"}, |
| 1338 | + ) |
| 1339 | + |
| 1340 | + assert response["data"]["updateSubmission"]["__typename"] == "SendSubmissionErrors" |
| 1341 | + assert response["data"]["updateSubmission"]["errors"]["validationTitle"] == [ |
| 1342 | + "You cannot edit the title after the call for proposals deadline has passed." |
| 1343 | + ] |
| 1344 | + |
| 1345 | + # Verify the title was not updated |
| 1346 | + submission.refresh_from_db() |
| 1347 | + assert submission.title.localize("en") == original_title |
| 1348 | + |
| 1349 | + |
| 1350 | +def test_cannot_update_abstract_after_cfp_deadline(graphql_client, user): |
| 1351 | + conference = ConferenceFactory( |
| 1352 | + topics=("life", "diy"), |
| 1353 | + languages=("en",), |
| 1354 | + durations=("10", "20"), |
| 1355 | + active_cfp=False, # CFP deadline is in the past |
| 1356 | + audience_levels=("adult", "senior"), |
| 1357 | + submission_types=("talk", "workshop"), |
| 1358 | + ) |
| 1359 | + |
| 1360 | + submission = SubmissionFactory( |
| 1361 | + speaker_id=user.id, |
| 1362 | + custom_topic="life", |
| 1363 | + custom_duration="10m", |
| 1364 | + custom_audience_level="adult", |
| 1365 | + custom_submission_type="talk", |
| 1366 | + languages=["en"], |
| 1367 | + tags=["python", "ml"], |
| 1368 | + conference=conference, |
| 1369 | + ) |
| 1370 | + |
| 1371 | + original_abstract = submission.abstract.localize("en") |
| 1372 | + |
| 1373 | + graphql_client.force_login(user) |
| 1374 | + |
| 1375 | + response = _update_submission( |
| 1376 | + graphql_client, |
| 1377 | + submission=submission, |
| 1378 | + new_abstract={"en": "Updated abstract after deadline"}, |
| 1379 | + ) |
| 1380 | + |
| 1381 | + assert response["data"]["updateSubmission"]["__typename"] == "SendSubmissionErrors" |
| 1382 | + assert response["data"]["updateSubmission"]["errors"]["validationAbstract"] == [ |
| 1383 | + "You cannot edit the abstract after the call for proposals deadline has passed." |
| 1384 | + ] |
| 1385 | + |
| 1386 | + # Verify the abstract was not updated |
| 1387 | + submission.refresh_from_db() |
| 1388 | + assert submission.abstract.localize("en") == original_abstract |
0 commit comments