| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  | /** | 
					
						
							|  |  |  |  |  * Copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-19 02:28:28 +08:00
										 |  |  |  | import { test, expect, retries, dumpTestTree } from './ui-mode-fixtures'; | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-19 02:28:28 +08:00
										 |  |  |  | test.describe.configure({ mode: 'parallel', retries }); | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | const basicTestTree = { | 
					
						
							|  |  |  |  |   'a.test.ts': `
 | 
					
						
							|  |  |  |  |     import { test } from '@playwright/test'; | 
					
						
							|  |  |  |  |     test('first', () => {}); | 
					
						
							|  |  |  |  |     test('second', () => {}); | 
					
						
							|  |  |  |  |   `,
 | 
					
						
							|  |  |  |  |   'b.test.ts': `
 | 
					
						
							|  |  |  |  |     import { test } from '@playwright/test'; | 
					
						
							|  |  |  |  |     test('third', () => {}); | 
					
						
							|  |  |  |  |   `,
 | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | test('should show selected test in sources', async ({ runUITest }) => { | 
					
						
							| 
									
										
										
										
											2023-03-30 04:57:19 +08:00
										 |  |  |  |   const { page } = await runUITest(basicTestTree); | 
					
						
							| 
									
										
										
										
											2023-04-29 05:18:46 +08:00
										 |  |  |  |   await expect.poll(dumpTestTree(page)).toBe(`
 | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  |     ▼ ◯ a.test.ts | 
					
						
							|  |  |  |  |         ◯ first | 
					
						
							|  |  |  |  |         ◯ second | 
					
						
							|  |  |  |  |     ▼ ◯ b.test.ts | 
					
						
							|  |  |  |  |         ◯ third | 
					
						
							|  |  |  |  |   `);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await page.getByTestId('test-tree').getByText('first').click(); | 
					
						
							| 
									
										
										
										
											2023-03-20 03:04:19 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.getByTestId('source-code').locator('.source-tab-file-name') | 
					
						
							|  |  |  |  |   ).toHaveText('a.test.ts'); | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror .source-line-running'), | 
					
						
							|  |  |  |  |   ).toHaveText(`3    test('first', () => {});`); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await page.getByTestId('test-tree').getByText('second').click(); | 
					
						
							| 
									
										
										
										
											2023-03-20 03:04:19 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.getByTestId('source-code').locator('.source-tab-file-name') | 
					
						
							|  |  |  |  |   ).toHaveText('a.test.ts'); | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror .source-line-running'), | 
					
						
							|  |  |  |  |   ).toHaveText(`4    test('second', () => {});`); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await page.getByTestId('test-tree').getByText('third').click(); | 
					
						
							| 
									
										
										
										
											2023-03-20 03:04:19 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.getByTestId('source-code').locator('.source-tab-file-name') | 
					
						
							|  |  |  |  |   ).toHaveText('b.test.ts'); | 
					
						
							| 
									
										
										
										
											2023-03-18 12:34:40 +08:00
										 |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror .source-line-running'), | 
					
						
							|  |  |  |  |   ).toHaveText(`3    test('third', () => {});`); | 
					
						
							|  |  |  |  | }); | 
					
						
							| 
									
										
										
										
											2023-05-09 09:51:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-13 05:23:22 +08:00
										 |  |  |  | test('should show top-level errors in file', async ({ runUITest }) => { | 
					
						
							| 
									
										
										
										
											2023-05-09 09:51:27 +08:00
										 |  |  |  |   const { page } = await runUITest({ | 
					
						
							|  |  |  |  |     'a.test.ts': `
 | 
					
						
							|  |  |  |  |       import { test } from '@playwright/test'; | 
					
						
							|  |  |  |  |       const a = 1; | 
					
						
							|  |  |  |  |       a = 2; | 
					
						
							|  |  |  |  |       test('first', () => {}); | 
					
						
							|  |  |  |  |       test('second', () => {}); | 
					
						
							|  |  |  |  |     `,
 | 
					
						
							|  |  |  |  |     'b.test.ts': `
 | 
					
						
							|  |  |  |  |       import { test } from '@playwright/test'; | 
					
						
							|  |  |  |  |       test('third', () => {}); | 
					
						
							|  |  |  |  |     `,
 | 
					
						
							|  |  |  |  |   }); | 
					
						
							|  |  |  |  |   await expect.poll(dumpTestTree(page)).toBe(`
 | 
					
						
							|  |  |  |  |       ◯ a.test.ts | 
					
						
							|  |  |  |  |     ▼ ◯ b.test.ts | 
					
						
							|  |  |  |  |         ◯ third | 
					
						
							|  |  |  |  |   `);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await page.getByTestId('test-tree').getByText('a.test.ts').click(); | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.getByTestId('source-code').locator('.source-tab-file-name') | 
					
						
							|  |  |  |  |   ).toHaveText('a.test.ts'); | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror .source-line-running'), | 
					
						
							|  |  |  |  |   ).toHaveText(`4      a = 2;`); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror-linewidget') | 
					
						
							|  |  |  |  |   ).toHaveText([ | 
					
						
							|  |  |  |  |     '            ', | 
					
						
							| 
									
										
										
										
											2023-11-16 10:27:32 +08:00
										 |  |  |  |     'TypeError: Assignment to constant variable.' | 
					
						
							| 
									
										
										
										
											2023-05-09 09:51:27 +08:00
										 |  |  |  |   ]); | 
					
						
							|  |  |  |  | }); | 
					
						
							| 
									
										
										
										
											2023-05-13 05:23:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | test('should show syntax errors in file', async ({ runUITest }) => { | 
					
						
							|  |  |  |  |   const { page } = await runUITest({ | 
					
						
							|  |  |  |  |     'a.test.ts': `
 | 
					
						
							|  |  |  |  |       import { test } from '@playwright/test'& | 
					
						
							|  |  |  |  |       test('first', () => {}); | 
					
						
							|  |  |  |  |       test('second', () => {}); | 
					
						
							|  |  |  |  |     `,
 | 
					
						
							|  |  |  |  |   }); | 
					
						
							|  |  |  |  |   await expect.poll(dumpTestTree(page)).toBe(`
 | 
					
						
							|  |  |  |  |       ◯ a.test.ts | 
					
						
							|  |  |  |  |   `);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await page.getByTestId('test-tree').getByText('a.test.ts').click(); | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.getByTestId('source-code').locator('.source-tab-file-name') | 
					
						
							|  |  |  |  |   ).toHaveText('a.test.ts'); | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror .source-line-running'), | 
					
						
							|  |  |  |  |   ).toHaveText(`2      import { test } from '@playwright/test'&`); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   await expect( | 
					
						
							|  |  |  |  |       page.locator('.CodeMirror-linewidget') | 
					
						
							|  |  |  |  |   ).toHaveText([ | 
					
						
							|  |  |  |  |     '                                              ', | 
					
						
							|  |  |  |  |     /Missing semicolon./ | 
					
						
							|  |  |  |  |   ]); | 
					
						
							|  |  |  |  | }); |