mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	Merge branch 'develop' into renovate/draggabilly-3.x
This commit is contained in:
		
						commit
						67bfd1dde6
					
				
							
								
								
									
										6
									
								
								.github/workflows/playwright.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/playwright.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,9 +1,9 @@ | |||||||
| name: Playwright Tests | name: Playwright Tests | ||||||
| on: | on: | ||||||
|   push: |   push: | ||||||
|     branches: [ main, master ] |     branches: [ develop ] | ||||||
|   pull_request: |   pull_request: | ||||||
|     branches: [ main, master ] |     branches: [ develop ] | ||||||
| jobs: | jobs: | ||||||
|   test: |   test: | ||||||
|     timeout-minutes: 60 |     timeout-minutes: 60 | ||||||
| @ -20,7 +20,7 @@ jobs: | |||||||
|     - name: Run Playwright tests |     - name: Run Playwright tests | ||||||
|       run: npx playwright test |       run: npx playwright test | ||||||
|     - uses: actions/upload-artifact@v4 |     - uses: actions/upload-artifact@v4 | ||||||
|       if: always() |       if: ${{ !cancelled() }} | ||||||
|       with: |       with: | ||||||
|         name: playwright-report |         name: playwright-report | ||||||
|         path: playwright-report/ |         path: playwright-report/ | ||||||
|  | |||||||
							
								
								
									
										59
									
								
								e2e/layout/tab_bar.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								e2e/layout/tab_bar.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | |||||||
|  | import { test, expect } from "@playwright/test"; | ||||||
|  | import App from "../support/app"; | ||||||
|  | 
 | ||||||
|  | const NOTE_TITLE = "Trilium Integration Test DB"; | ||||||
|  | 
 | ||||||
|  | test("Can drag tabs around", async ({ page }) => { | ||||||
|  |     const app = new App(page); | ||||||
|  |     await app.goto(); | ||||||
|  | 
 | ||||||
|  |     // [1]: Trilium Integration Test DB note
 | ||||||
|  |     await app.closeAllTabs(); | ||||||
|  |     await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE); | ||||||
|  |     await expect(app.getActiveTab()).toContainText(NOTE_TITLE); | ||||||
|  | 
 | ||||||
|  |     // [1] [2] [3]
 | ||||||
|  |     await app.addNewTab(); | ||||||
|  |     await app.addNewTab(); | ||||||
|  | 
 | ||||||
|  |     let tab = app.getTab(0); | ||||||
|  | 
 | ||||||
|  |     // Drag the first tab at the end
 | ||||||
|  |     await tab.dragTo(app.getTab(2), { targetPosition: { x: 50, y: 0 }}); | ||||||
|  | 
 | ||||||
|  |     tab = app.getTab(2); | ||||||
|  |     await expect(tab).toContainText(NOTE_TITLE); | ||||||
|  | 
 | ||||||
|  |     // Drag the tab to the left
 | ||||||
|  |     await tab.dragTo(app.getTab(0), { targetPosition: { x: 50, y: 0 }}); | ||||||
|  |     await expect(app.getTab(0)).toContainText(NOTE_TITLE); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test("Can drag tab to new window", async ({ page }) => { | ||||||
|  |     const app = new App(page); | ||||||
|  |     await app.goto(); | ||||||
|  | 
 | ||||||
|  |     await app.closeAllTabs(); | ||||||
|  |     await app.clickNoteOnNoteTreeByTitle(NOTE_TITLE); | ||||||
|  |     const tab = app.getTab(0); | ||||||
|  |     await expect(tab).toContainText(NOTE_TITLE); | ||||||
|  | 
 | ||||||
|  |     const popupPromise = page.waitForEvent("popup"); | ||||||
|  | 
 | ||||||
|  |     const tabPos = await tab.boundingBox(); | ||||||
|  |     if (tabPos) { | ||||||
|  |         const x = tabPos.x + tabPos.width / 2; | ||||||
|  |         const y = tabPos.y + tabPos.height / 2; | ||||||
|  |         await page.mouse.move(x, y); | ||||||
|  |         await page.mouse.down(); | ||||||
|  |         await page.mouse.move(x, y + tabPos.height + 100, { steps: 5 }); | ||||||
|  |         await page.mouse.up(); | ||||||
|  |     } else { | ||||||
|  |         fail("Unable to determine tab position"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Wait for the popup to show
 | ||||||
|  |     const popup = await popupPromise; | ||||||
|  |     const popupApp = new App(popup); | ||||||
|  |     await expect(popupApp.getActiveTab()).toHaveText(NOTE_TITLE); | ||||||
|  | }); | ||||||
							
								
								
									
										45
									
								
								e2e/support/app.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								e2e/support/app.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | |||||||
|  | import { Locator, Page, expect } from "@playwright/test"; | ||||||
|  | 
 | ||||||
|  | export default class App { | ||||||
|  |     readonly page: Page; | ||||||
|  | 
 | ||||||
|  |     readonly tabBar: Locator; | ||||||
|  |     readonly noteTree: Locator; | ||||||
|  | 
 | ||||||
|  |     constructor(page: Page) { | ||||||
|  |         this.page = page; | ||||||
|  |         this.tabBar = page.locator(".tab-row-widget-container"); | ||||||
|  |         this.noteTree = page.locator(".tree-wrapper"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async goto() { | ||||||
|  |         await this.page.goto("/", { waitUntil: "networkidle" }); | ||||||
|  | 
 | ||||||
|  |         // Wait for the page to load.
 | ||||||
|  |         await expect(this.page.locator(".tree")) | ||||||
|  |             .toContainText("Trilium Integration Test"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     getTab(tabIndex: number) { | ||||||
|  |         return this.tabBar.locator(".note-tab-wrapper").nth(tabIndex); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     getActiveTab() { | ||||||
|  |         return this.tabBar.locator(".note-tab[active]"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async closeAllTabs() { | ||||||
|  |         await this.getTab(0).click({ button: "right" }); | ||||||
|  |         await this.page.waitForTimeout(500); // TODO: context menu won't dismiss otherwise
 | ||||||
|  |         await this.page.getByText("Close all tabs").click({ force: true }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async addNewTab() { | ||||||
|  |         await this.page.locator('[data-trigger-command="openNewTab"]').click(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async clickNoteOnNoteTreeByTitle(title: string) { | ||||||
|  |         this.noteTree.getByText(title).click(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -1,85 +1,79 @@ | |||||||
| import { defineConfig, devices } from "@playwright/test"; | import { defineConfig, devices } from '@playwright/test'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Read environment variables from file. |  * Read environment variables from file. | ||||||
|  * https://github.com/motdotla/dotenv
 |  * https://github.com/motdotla/dotenv
 | ||||||
|  */ |  */ | ||||||
| // import dotenv from 'dotenv';
 | // import dotenv from 'dotenv';
 | ||||||
|  | // import path from 'path';
 | ||||||
| // dotenv.config({ path: path.resolve(__dirname, '.env') });
 | // dotenv.config({ path: path.resolve(__dirname, '.env') });
 | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * See https://playwright.dev/docs/test-configuration.
 |  * See https://playwright.dev/docs/test-configuration.
 | ||||||
|  */ |  */ | ||||||
| export default defineConfig({ | export default defineConfig({ | ||||||
|     testDir: "./integration-tests", |   testDir: './e2e', | ||||||
|     /* Run tests in files in parallel */ |   /* Run tests in files in parallel */ | ||||||
|     fullyParallel: true, |   fullyParallel: true, | ||||||
|     /* Fail the build on CI if you accidentally left test.only in the source code. */ |   /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||||||
|     forbidOnly: !!process.env.CI, |   forbidOnly: !!process.env.CI, | ||||||
|     /* Retry on CI only */ |   /* Retry on CI only */ | ||||||
|     retries: process.env.CI ? 2 : 0, |   retries: process.env.CI ? 2 : 0, | ||||||
|     /* Opt out of parallel tests on CI. */ |   /* Opt out of parallel tests on CI. */ | ||||||
|     workers: process.env.CI ? 1 : undefined, |   workers: process.env.CI ? 1 : undefined, | ||||||
|     /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |   /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||||||
|     reporter: "html", |   reporter: 'html', | ||||||
|     /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |   /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||||||
|     use: { |   use: { | ||||||
|         /* Base URL to use in actions like `await page.goto('/')`. */ |     /* Base URL to use in actions like `await page.goto('/')`. */ | ||||||
|         // baseURL: 'http://127.0.0.1:3000',
 |     baseURL: 'http://127.0.0.1:8082', | ||||||
| 
 | 
 | ||||||
|         /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |     /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||||||
|         trace: "on-first-retry" |     trace: 'on-first-retry', | ||||||
|  |   }, | ||||||
|  | 
 | ||||||
|  |   /* Configure projects for major browsers */ | ||||||
|  |   projects: [ | ||||||
|  |     { | ||||||
|  |       name: 'chromium', | ||||||
|  |       use: { ...devices['Desktop Chrome'] }, | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     webServer: { |     { | ||||||
|         command: "npm run integration-mem-db", |       name: 'firefox', | ||||||
|         url: "http://127.0.0.1:8082", |       use: { ...devices['Desktop Firefox'] }, | ||||||
|         reuseExistingServer: true, |  | ||||||
|         stdout: "ignore", |  | ||||||
|         stderr: "pipe" |  | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     /* Configure projects for major browsers */ |     { | ||||||
|     projects: [ |       name: 'webkit', | ||||||
|         { |       use: { ...devices['Desktop Safari'] }, | ||||||
|             name: "setup", |     }, | ||||||
|             testMatch: /.*\.setup\.ts/ |  | ||||||
|         }, |  | ||||||
| 
 | 
 | ||||||
|         { |     /* Test against mobile viewports. */ | ||||||
|             name: "firefox", |     // {
 | ||||||
|             use: { |     //   name: 'Mobile Chrome',
 | ||||||
|                 ...devices["Desktop Firefox"], |     //   use: { ...devices['Pixel 5'] },
 | ||||||
|                 storageState: "playwright/.auth/user.json" |  | ||||||
|             }, |  | ||||||
|             dependencies: ["setup"] |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         /* Test against mobile viewports. */ |  | ||||||
|         // {
 |  | ||||||
|         //   name: 'Mobile Chrome',
 |  | ||||||
|         //   use: { ...devices['Pixel 5'] },
 |  | ||||||
|         // },
 |  | ||||||
|         // {
 |  | ||||||
|         //   name: 'Mobile Safari',
 |  | ||||||
|         //   use: { ...devices['iPhone 12'] },
 |  | ||||||
|         // },
 |  | ||||||
| 
 |  | ||||||
|         /* Test against branded browsers. */ |  | ||||||
|         // {
 |  | ||||||
|         //   name: 'Microsoft Edge',
 |  | ||||||
|         //   use: { ...devices['Desktop Edge'], channel: 'msedge' },
 |  | ||||||
|         // },
 |  | ||||||
|         // {
 |  | ||||||
|         //   name: 'Google Chrome',
 |  | ||||||
|         //   use: { ...devices['Desktop Chrome'], channel: 'chrome' },
 |  | ||||||
|         // },
 |  | ||||||
|     ] |  | ||||||
| 
 |  | ||||||
|     /* Run your local dev server before starting the tests */ |  | ||||||
|     // webServer: {
 |  | ||||||
|     //   command: 'npm run start',
 |  | ||||||
|     //   url: 'http://127.0.0.1:3000',
 |  | ||||||
|     //   reuseExistingServer: !process.env.CI,
 |  | ||||||
|     // },
 |     // },
 | ||||||
|  |     // {
 | ||||||
|  |     //   name: 'Mobile Safari',
 | ||||||
|  |     //   use: { ...devices['iPhone 12'] },
 | ||||||
|  |     // },
 | ||||||
|  | 
 | ||||||
|  |     /* Test against branded browsers. */ | ||||||
|  |     // {
 | ||||||
|  |     //   name: 'Microsoft Edge',
 | ||||||
|  |     //   use: { ...devices['Desktop Edge'], channel: 'msedge' },
 | ||||||
|  |     // },
 | ||||||
|  |     // {
 | ||||||
|  |     //   name: 'Google Chrome',
 | ||||||
|  |     //   use: { ...devices['Desktop Chrome'], channel: 'chrome' },
 | ||||||
|  |     // },
 | ||||||
|  |   ], | ||||||
|  | 
 | ||||||
|  |   /* Run your local dev server before starting the tests */ | ||||||
|  |   // webServer: {
 | ||||||
|  |   //   command: 'npm run start',
 | ||||||
|  |   //   url: 'http://127.0.0.1:3000',
 | ||||||
|  |   //   reuseExistingServer: !process.env.CI,
 | ||||||
|  |   // },
 | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran