mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 19:28:29 +02:00

* Extract bookmark view contexts * Implement basic partial updates for bookmark list and tag cloud * Refactor confirm button JS into web component * Refactor bulk edit JS into web component * Refactor tag autocomplete JS into web component * Refactor bookmark page JS into web component * Refactor global shortcuts JS into web component * Update tests * Add E2E test for partial updates * Add partial updates for archived bookmarks * Add partial updates for shared bookmarks * Cleanup helpers * Improve naming in bulk edit * Refactor shared components into behaviors * Refactor bulk edit components into behaviors * Refactor bookmark list components into behaviors * Update tests * Combine all scripts into bundle * Fix E2E CI
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from django.contrib.staticfiles.testing import LiveServerTestCase
|
|
from playwright.sync_api import BrowserContext, Playwright, Page
|
|
|
|
from bookmarks.tests.helpers import BookmarkFactoryMixin
|
|
|
|
|
|
class LinkdingE2ETestCase(LiveServerTestCase, BookmarkFactoryMixin):
|
|
def setUp(self) -> None:
|
|
self.client.force_login(self.get_or_create_test_user())
|
|
self.cookie = self.client.cookies['sessionid']
|
|
|
|
def setup_browser(self, playwright) -> BrowserContext:
|
|
browser = playwright.chromium.launch(headless=True)
|
|
context = browser.new_context()
|
|
context.add_cookies([{
|
|
'name': 'sessionid',
|
|
'value': self.cookie.value,
|
|
'domain': self.live_server_url.replace('http:', ''),
|
|
'path': '/'
|
|
}])
|
|
return context
|
|
|
|
def open(self, url: str, playwright: Playwright) -> Page:
|
|
browser = self.setup_browser(playwright)
|
|
self.page = browser.new_page()
|
|
self.page.goto(self.live_server_url + url)
|
|
self.page.on('load', self.on_load)
|
|
self.num_loads = 0
|
|
return self.page
|
|
|
|
def on_load(self):
|
|
self.num_loads += 1
|
|
|
|
def assertReloads(self, count: int):
|
|
self.assertEqual(self.num_loads, count)
|
|
|
|
def locate_bookmark(self, title: str):
|
|
bookmark_tags = self.page.locator('li[ld-bookmark-item]')
|
|
return bookmark_tags.filter(has_text=title)
|
|
|
|
def locate_bulk_edit_bar(self):
|
|
return self.page.locator('.bulk-edit-bar')
|
|
|
|
def locate_bulk_edit_toggle(self):
|
|
return self.page.get_by_title('Bulk edit')
|