Skip to content

Commit 9735e2e

Browse files
committed
Fix tests
1 parent f50c241 commit 9735e2e

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

rdmo/projects/tests/e2e/test_frontend_projects.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ def test_projects_page(page: Page):
2222
expect(page.locator("thead")).to_contain_text("Name")
2323
expect(page.locator("tbody")).to_contain_text("Test")
2424

25-
# Assert bottom of page
25+
# Assert "Load more" button
2626
page.locator("body").press("End")
27-
expect(page.get_by_role("button", name="Scroll to top")).to_be_visible()
28-
page.locator("body").press("Home")
27+
load_more = page.get_by_role("button", name="Load more")
28+
expect(load_more).to_be_visible()
29+
30+
with page.expect_response(re.compile(r"/projects/")):
31+
load_more.click()
32+
33+
# Assert the "Scroll to top" button
34+
page.locator("body").press("End")
35+
expect(page.get_by_title("Scroll to top")).to_be_visible()

rdmo/projects/tests/helpers/ordering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ def get_projects_ordered_by_last_changed():
99
last_changed=Coalesce(Greatest(Subquery(
1010
Value.objects.filter(project=OuterRef('pk')).order_by('-updated').values('updated')[:1]
1111
), 'updated'), 'updated')
12-
).order_by('last_changed')
12+
).order_by('-last_changed')

rdmo/projects/tests/test_viewset_project.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ def test_list_multisite(db, client, settings):
159159
visibility.sites.add(Site.objects.get(id=1))
160160

161161
url = reverse(urlnames['list'])
162-
response = client.get(url + '?page=3')
162+
response = client.get(url)
163163
response_data = response.json()
164164

165165
assert response.status_code == 200
166-
assert project.id in [i['id'] for i in response_data['results']]
166+
assert project.id == response_data['results'][0]['id']
167167
assert response_data['count'] == len(view_project_permission_map['site']) + 1
168168

169169

@@ -374,18 +374,24 @@ def test_copy(db, files, client, username, password, project_id):
374374
'title': 'New title',
375375
'description': project.description,
376376
'catalog': project.catalog.id,
377-
'tasks': list(project.tasks.values_list('id', flat=True)), # will be ignored but should not crash
378-
'views': list(project.views.values_list('id', flat=True)), # will be ignored but should not crash
377+
'tasks': [2], # will be ignored but should not crash
378+
'views': [2], # will be ignored but should not crash
379379
}
380380
response = client.post(url, data, content_type='application/json')
381381

382382
if project_id in view_project_permission_map.get(username, []):
383383
assert response.status_code == 201
384384

385385
for key, value in response.json().items():
386-
if key in data:
386+
if key in ['title', 'description', 'catalog']:
387387
assert value == data[key]
388388

389+
# TODO: add checks once rdmo.project.handlers is rebased
390+
# elif key == 'tasks':
391+
# assert value == list(project.tasks.values_list('id', flat=True))
392+
# elif key == 'views':
393+
# assert value == list(project.views.values_list('id', flat=True))
394+
389395
assert Project.objects.count() == project_count + 1
390396
assert Snapshot.objects.count() == snapshot_count + project_snapshots_count
391397
assert Value.objects.count() == value_count + project_values_count

0 commit comments

Comments
 (0)