@codeguide/core 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/__tests__/services/usage/usage-service.test.ts +442 -83
  2. package/codeguide.ts +3 -0
  3. package/dist/codeguide.d.ts +2 -1
  4. package/dist/codeguide.js +1 -0
  5. package/dist/index.d.ts +4 -3
  6. package/dist/services/base/base-service.d.ts +21 -0
  7. package/dist/services/base/base-service.js +114 -0
  8. package/dist/services/codespace/codespace-service.d.ts +55 -1
  9. package/dist/services/codespace/codespace-service.js +257 -0
  10. package/dist/services/codespace/codespace-types.d.ts +192 -12
  11. package/dist/services/codespace/index.d.ts +1 -1
  12. package/dist/services/index.d.ts +2 -0
  13. package/dist/services/index.js +4 -1
  14. package/dist/services/projects/project-types.d.ts +66 -32
  15. package/dist/services/starter-kits/index.d.ts +2 -0
  16. package/dist/services/starter-kits/index.js +20 -0
  17. package/dist/services/starter-kits/starter-kits-service.d.ts +13 -0
  18. package/dist/services/starter-kits/starter-kits-service.js +27 -0
  19. package/dist/services/starter-kits/starter-kits-types.d.ts +34 -0
  20. package/dist/services/starter-kits/starter-kits-types.js +2 -0
  21. package/dist/services/tasks/task-service.d.ts +2 -1
  22. package/dist/services/tasks/task-service.js +8 -0
  23. package/dist/services/tasks/task-types.d.ts +26 -7
  24. package/dist/services/usage/usage-service.d.ts +5 -2
  25. package/dist/services/usage/usage-service.js +58 -9
  26. package/dist/services/usage/usage-types.d.ts +150 -26
  27. package/docs/.vitepress/README.md +51 -0
  28. package/docs/.vitepress/config.ts +139 -0
  29. package/docs/.vitepress/theme/custom.css +80 -0
  30. package/docs/.vitepress/theme/index.ts +13 -0
  31. package/docs/.vitepress/tsconfig.json +19 -0
  32. package/docs/QUICKSTART.md +77 -0
  33. package/docs/README.md +134 -0
  34. package/docs/README_SETUP.md +46 -0
  35. package/docs/authentication.md +351 -0
  36. package/docs/codeguide-client.md +350 -0
  37. package/docs/codespace-models.md +1004 -0
  38. package/docs/codespace-service.md +444 -0
  39. package/docs/index.md +135 -0
  40. package/docs/package.json +14 -0
  41. package/docs/projects-service.md +688 -0
  42. package/docs/security-keys-service.md +773 -0
  43. package/docs/starter-kits-service.md +249 -0
  44. package/docs/task-service.md +955 -0
  45. package/docs/testsprite_tests/TC001_Homepage_Load_and_Hero_Section_Display.py +70 -0
  46. package/docs/testsprite_tests/TC002_Sidebar_Navigation_ExpandCollapse_Functionality.py +73 -0
  47. package/docs/testsprite_tests/TC003_Full_Text_Local_Search_with_Keyboard_Shortcut.py +90 -0
  48. package/docs/testsprite_tests/TC004_Dark_Mode_Toggle_and_Persistence.py +73 -0
  49. package/docs/testsprite_tests/TC005_Mobile_Responsiveness_and_Touch_Navigation.py +113 -0
  50. package/docs/testsprite_tests/TC006_GitHub_Integration_Edit_this_page_Links.py +73 -0
  51. package/docs/testsprite_tests/TC007_Syntax_Highlighting_and_Code_Copy_Functionality.py +73 -0
  52. package/docs/testsprite_tests/TC008_Auto_Generated_Table_of_Contents_Accuracy.py +73 -0
  53. package/docs/testsprite_tests/TC009_SEO_and_Content_Discoverability_Verification.py +73 -0
  54. package/docs/testsprite_tests/TC010_Accessibility_Compliance_WCAG_AA.py +73 -0
  55. package/docs/testsprite_tests/TC011_Local_Development_Workflow_Build_and_Hot_Reload.py +74 -0
  56. package/docs/testsprite_tests/TC012_Performance_Metrics_Compliance.py +73 -0
  57. package/docs/testsprite_tests/standard_prd.json +122 -0
  58. package/docs/testsprite_tests/testsprite-mcp-test-report.html +2508 -0
  59. package/docs/testsprite_tests/testsprite-mcp-test-report.md +273 -0
  60. package/docs/testsprite_tests/testsprite_frontend_test_plan.json +390 -0
  61. package/docs/usage-service.md +291 -1
  62. package/index.ts +11 -3
  63. package/package.json +16 -2
  64. package/plans/CODESPACE_LOGS_STREAMING_GUIDE.md +320 -0
  65. package/plans/CODESPACE_TASK_LOGS_API_COMPLETE_GUIDE.md +821 -0
  66. package/services/base/base-service.ts +130 -0
  67. package/services/codespace/codespace-service.ts +337 -0
  68. package/services/codespace/codespace-types.ts +262 -13
  69. package/services/codespace/index.ts +16 -1
  70. package/services/index.ts +2 -0
  71. package/services/projects/README.md +107 -34
  72. package/services/projects/project-types.ts +69 -32
  73. package/services/starter-kits/index.ts +2 -0
  74. package/services/starter-kits/starter-kits-service.ts +33 -0
  75. package/services/starter-kits/starter-kits-types.ts +38 -0
  76. package/services/tasks/task-service.ts +10 -0
  77. package/services/tasks/task-types.ts +29 -7
  78. package/services/usage/usage-service.ts +59 -10
  79. package/services/usage/usage-types.ts +178 -27
@@ -0,0 +1,70 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # --> Assertions to verify final state
50
+ frame = context.pages[-1]
51
+ await expect(frame.locator('text=Complete TypeScript SDK for integrating CodeGuide functionality into your applications').first).to_be_visible(timeout=2000)
52
+ await expect(frame.locator('text=Get Started').first).to_be_visible(timeout=2000)
53
+ await expect(frame.locator('text=🔑 Multiple Authentication Methods').first).to_be_visible(timeout=2000)
54
+ await expect(frame.locator('text=📝 Project Management').first).to_be_visible(timeout=2000)
55
+ await expect(frame.locator('text=🤖 Codespace Tasks').first).to_be_visible(timeout=2000)
56
+ await expect(frame.locator('text=🎯 Model Management').first).to_be_visible(timeout=2000)
57
+ await expect(frame.locator('text=🔐 Security Keys').first).to_be_visible(timeout=2000)
58
+ await expect(frame.locator('text=🛡️ TypeScript Support').first).to_be_visible(timeout=2000)
59
+ await asyncio.sleep(5)
60
+
61
+ finally:
62
+ if context:
63
+ await context.close()
64
+ if browser:
65
+ await browser.close()
66
+ if pw:
67
+ await pw.stop()
68
+
69
+ asyncio.run(run_test())
70
+
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Click on a collapsible section in the sidebar to expand it and show nested links
50
+ frame = context.pages[-1]
51
+ # Click on 'Getting Started' collapsible section in the sidebar to expand it
52
+ elem = frame.locator('xpath=html/body/div/div/header/div/div/div/div[2]/div/nav/a[2]').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ try:
59
+ await expect(frame.locator('text=Sidebar Navigation Expanded Successfully').first).to_be_visible(timeout=1000)
60
+ except AssertionError:
61
+ raise AssertionError('Test case failed: The hierarchical sidebar navigation did not expand or collapse correctly, or did not route to the correct documentation pages as expected.')
62
+ await asyncio.sleep(5)
63
+
64
+ finally:
65
+ if context:
66
+ await context.close()
67
+ if browser:
68
+ await browser.close()
69
+ if pw:
70
+ await pw.stop()
71
+
72
+ asyncio.run(run_test())
73
+
@@ -0,0 +1,90 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Try to locate the search input field visually or by other means and input the search query
50
+ frame = context.pages[-1]
51
+ # Click on the 'Search' button or area to focus the search input
52
+ elem = frame.locator('xpath=html/body/div/div/div/div/div[3]/div/div/div[2]/button').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ await expect(frame.locator('text=Search').first).to_be_visible(timeout=30000)
59
+ await frame.keyboard.press('Control+K') # For Windows/Linux
60
+ await expect(frame.locator('input[type="search"]')).to_be_focused(timeout=30000)
61
+ search_query = 'Codespace Service Documentation'
62
+ await frame.locator('input[type="search"]').fill(search_query)
63
+ await frame.wait_for_timeout(1000) # Wait for search results to update
64
+ await expect(frame.locator(f'text={search_query}').first).to_be_visible(timeout=30000)
65
+ await expect(frame.locator(f'text={search_query}').first).to_contain_text(search_query)
66
+ # Check that query terms are highlighted in the search results
67
+ await expect(frame.locator('text=Codespace Service Documentation').first).to_be_visible(timeout=30000)
68
+ # Navigate search results using keyboard arrows
69
+ await frame.keyboard.press('ArrowDown')
70
+ await frame.keyboard.press('ArrowUp')
71
+ # Check that focused search result is visually distinct
72
+ # (Assuming focused element has aria-selected or similar attribute)
73
+ focused_result = frame.locator('aria-selected=true')
74
+ await expect(focused_result).to_be_visible(timeout=30000)
75
+ # Select the focused search result
76
+ await frame.keyboard.press('Enter')
77
+ # Verify navigation to the correct documentation page with highlights
78
+ await expect(frame.locator('text=Codespace Service Documentation').first).to_be_visible(timeout=30000)
79
+ await asyncio.sleep(5)
80
+
81
+ finally:
82
+ if context:
83
+ await context.close()
84
+ if browser:
85
+ await browser.close()
86
+ if pw:
87
+ await pw.stop()
88
+
89
+ asyncio.run(run_test())
90
+
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Click the dark mode toggle button to enable dark mode
50
+ frame = context.pages[-1]
51
+ # Click the dark mode toggle button to enable dark mode
52
+ elem = frame.locator('xpath=html/body/div/div/div/div/div[3]/div/div/ul[2]/li/strong/a').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ try:
59
+ await expect(frame.locator('text=Dark Mode Enabled Successfully')).to_be_visible(timeout=1000)
60
+ except AssertionError:
61
+ raise AssertionError('Test case failed: The dark mode toggle did not work as expected. The site did not switch to dark mode appearance immediately or persist user choice across sessions.')
62
+ await asyncio.sleep(5)
63
+
64
+ finally:
65
+ if context:
66
+ await context.close()
67
+ if browser:
68
+ await browser.close()
69
+ if pw:
70
+ await pw.stop()
71
+
72
+ asyncio.run(run_test())
73
+
@@ -0,0 +1,113 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
50
+ await page.goto('http://localhost:5174/', timeout=10000)
51
+ await asyncio.sleep(3)
52
+
53
+
54
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
55
+ await page.goto('http://localhost:5174/', timeout=10000)
56
+ await asyncio.sleep(3)
57
+
58
+
59
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
60
+ await page.goto('http://localhost:5174/', timeout=10000)
61
+ await asyncio.sleep(3)
62
+
63
+
64
+ await page.mouse.wheel(0, 100)
65
+
66
+
67
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
68
+ await page.goto('http://localhost:5174/', timeout=10000)
69
+ await asyncio.sleep(3)
70
+
71
+
72
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
73
+ await page.goto('http://localhost:5174/', timeout=10000)
74
+ await asyncio.sleep(3)
75
+
76
+
77
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
78
+ await page.goto('http://localhost:5174/', timeout=10000)
79
+ await asyncio.sleep(3)
80
+
81
+
82
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
83
+ await page.goto('http://localhost:5174/', timeout=10000)
84
+ await asyncio.sleep(3)
85
+
86
+
87
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
88
+ await page.goto('http://localhost:5174/', timeout=10000)
89
+ await asyncio.sleep(3)
90
+
91
+
92
+ # -> Resize viewport to 320px width and check layout for horizontal scrolling and responsiveness.
93
+ await page.goto('http://localhost:5174/', timeout=10000)
94
+ await asyncio.sleep(3)
95
+
96
+
97
+ # --> Assertions to verify final state
98
+ try:
99
+ await expect(page.locator('text=Mobile Navigation Menu Opened Successfully').first).to_be_visible(timeout=1000)
100
+ except AssertionError:
101
+ raise AssertionError('Test plan execution failed: The mobile navigation menu did not open smoothly or sections could not be expanded/collapsed as expected.')
102
+ await asyncio.sleep(5)
103
+
104
+ finally:
105
+ if context:
106
+ await context.close()
107
+ if browser:
108
+ await browser.close()
109
+ if pw:
110
+ await pw.stop()
111
+
112
+ asyncio.run(run_test())
113
+
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Navigate to a specific documentation page (e.g., 'Getting Started') to locate and verify 'Edit this page' link.
50
+ frame = context.pages[-1]
51
+ # Click on 'Getting Started' link to navigate to a documentation page where 'Edit this page' link might be present.
52
+ elem = frame.locator('xpath=html/body/div/div/div/div/div[3]/div/div/ul/li/strong/a').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ try:
59
+ await expect(frame.locator('text=Edit this page link is broken or incorrect').first).to_be_visible(timeout=1000)
60
+ except AssertionError:
61
+ raise AssertionError("Test case failed: The 'Edit this page' link does not correctly direct to the corresponding markdown file on GitHub repository as per the test plan.")
62
+ await asyncio.sleep(5)
63
+
64
+ finally:
65
+ if context:
66
+ await context.close()
67
+ if browser:
68
+ await browser.close()
69
+ if pw:
70
+ await pw.stop()
71
+
72
+ asyncio.run(run_test())
73
+
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Click the copy-to-clipboard button on the first TypeScript code block to test copy functionality
50
+ frame = context.pages[-1]
51
+ # Click the copy-to-clipboard button on the first TypeScript code block
52
+ elem = frame.locator('xpath=html/body/div/div/div/div/div[3]/div/div/div[2]/button').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ try:
59
+ await expect(frame.locator('text=Syntax highlighting failed for TypeScript and JavaScript code samples').first).to_be_visible(timeout=1000)
60
+ except AssertionError:
61
+ raise AssertionError('Test case failed: Syntax highlighting, line numbers, or copy-to-clipboard functionality did not work as expected for TypeScript and JavaScript code samples.')
62
+ await asyncio.sleep(5)
63
+
64
+ finally:
65
+ if context:
66
+ await context.close()
67
+ if browser:
68
+ await browser.close()
69
+ if pw:
70
+ await pw.stop()
71
+
72
+ asyncio.run(run_test())
73
+
@@ -0,0 +1,73 @@
1
+ import asyncio
2
+ from playwright import async_api
3
+ from playwright.async_api import expect
4
+
5
+ async def run_test():
6
+ pw = None
7
+ browser = None
8
+ context = None
9
+
10
+ try:
11
+ # Start a Playwright session in asynchronous mode
12
+ pw = await async_api.async_playwright().start()
13
+
14
+ # Launch a Chromium browser in headless mode with custom arguments
15
+ browser = await pw.chromium.launch(
16
+ headless=True,
17
+ args=[
18
+ "--window-size=1280,720", # Set the browser window size
19
+ "--disable-dev-shm-usage", # Avoid using /dev/shm which can cause issues in containers
20
+ "--ipc=host", # Use host-level IPC for better stability
21
+ "--single-process" # Run the browser in a single process mode
22
+ ],
23
+ )
24
+
25
+ # Create a new browser context (like an incognito window)
26
+ context = await browser.new_context()
27
+ context.set_default_timeout(5000)
28
+
29
+ # Open a new page in the browser context
30
+ page = await context.new_page()
31
+
32
+ # Navigate to your target URL and wait until the network request is committed
33
+ await page.goto("http://localhost:5174", wait_until="commit", timeout=10000)
34
+
35
+ # Wait for the main page to reach DOMContentLoaded state (optional for stability)
36
+ try:
37
+ await page.wait_for_load_state("domcontentloaded", timeout=3000)
38
+ except async_api.Error:
39
+ pass
40
+
41
+ # Iterate through all iframes and wait for them to load as well
42
+ for frame in page.frames:
43
+ try:
44
+ await frame.wait_for_load_state("domcontentloaded", timeout=3000)
45
+ except async_api.Error:
46
+ pass
47
+
48
+ # Interact with the page elements to simulate user flow
49
+ # -> Click on a table of contents entry to verify navigation to the correct section
50
+ frame = context.pages[-1]
51
+ # Click 'Quick Start' in the table of contents to verify navigation
52
+ elem = frame.locator('xpath=html/body/div/div/div/div/div[3]/div/div/h2/a').nth(0)
53
+ await page.wait_for_timeout(3000); await elem.click(timeout=5000)
54
+
55
+
56
+ # --> Assertions to verify final state
57
+ frame = context.pages[-1]
58
+ try:
59
+ await expect(frame.locator('text=Table of Contents Not Found').first).to_be_visible(timeout=1000)
60
+ except AssertionError:
61
+ raise AssertionError('Test case failed: The table of contents is not auto-generated correctly or navigation links do not work as expected.')
62
+ await asyncio.sleep(5)
63
+
64
+ finally:
65
+ if context:
66
+ await context.close()
67
+ if browser:
68
+ await browser.close()
69
+ if pw:
70
+ await pw.stop()
71
+
72
+ asyncio.run(run_test())
73
+