Skip to content

Commit cd8c153

Browse files
authored
refactor(vscode): share open problems view (#5004)
1 parent e53b1ee commit cd8c153

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

vscode/extension/tests/broken_project.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path'
55
import {
66
openLineageView,
77
openServerPage,
8-
runCommand,
8+
openProblemsView,
99
saveFile,
1010
SUSHI_SOURCE_PATH,
1111
} from './utils'
@@ -277,8 +277,7 @@ test('bad model block, then fixed', async ({ page, sharedCodeServer }) => {
277277
// Wait for the error to appear
278278
await page.waitForSelector('text=Error creating context')
279279

280-
// Open the problems view
281-
await runCommand(page, 'View: Focus Problems')
280+
await openProblemsView(page)
282281

283282
// Assert error is present in the problems view
284283
const errorElement = page

vscode/extension/tests/diagnostics.spec.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from './fixtures'
22
import path from 'path'
33
import fs from 'fs-extra'
44
import os from 'os'
5-
import { openServerPage, runCommand, SUSHI_SOURCE_PATH } from './utils'
5+
import { openProblemsView, openServerPage, SUSHI_SOURCE_PATH } from './utils'
66
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
77
import { execAsync } from '../src/utilities/exec'
88
import yaml from 'yaml'
@@ -36,8 +36,7 @@ test('Workspace diagnostics show up in the diagnostics panel', async ({
3636
.locator('a')
3737
.click()
3838

39-
// Open problems panel
40-
await runCommand(page, 'View: Focus Problems')
39+
await openProblemsView(page)
4140

4241
await page.waitForSelector('text=problems')
4342
await page.waitForSelector('text=All models should have an owner')
@@ -82,8 +81,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
8281
// Wait for the error to appear
8382
await page.waitForSelector('text=Error creating context')
8483

85-
// Open the problems view
86-
await runCommand(page, 'View: Focus Problems')
84+
await openProblemsView(page)
8785

8886
// Asser that the error is present in the problems view
8987
await page
@@ -125,8 +123,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
125123
// Wait for the error to appear
126124
await page.waitForSelector('text=Error creating context')
127125

128-
// Open the problems view
129-
await runCommand(page, 'View: Focus Problems')
126+
await openProblemsView(page)
130127

131128
// Asser that the error is present in the problems view
132129
await page
@@ -164,8 +161,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
164161
// Expect the error to appear
165162
await page.waitForSelector('text=Error creating context')
166163

167-
// Open the problems view
168-
await runCommand(page, 'View: Focus Problems')
164+
await openProblemsView(page)
169165

170166
// Assert that the error is present in the problems view
171167
const errorElement = page
@@ -200,8 +196,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
200196
// Expect the error to appear
201197
await page.waitForSelector('text=Error creating context')
202198

203-
// Open the problems view
204-
await runCommand(page, 'View: Focus Problems')
199+
await openProblemsView(page)
205200

206201
// Assert that the error is present in the problems view
207202
const errorElement = page.getByText('Failed to load config file:').first()
@@ -242,8 +237,7 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
242237
// Wait for the error to appear
243238
await page.waitForSelector('text=Error creating context')
244239

245-
// Open the problems view
246-
await runCommand(page, 'View: Focus Problems')
240+
await openProblemsView(page)
247241

248242
// Asser that the error is present in the problems view
249243
await page
@@ -284,8 +278,7 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
284278
// Wait for the error to appear
285279
await page.waitForSelector('text=Error creating context')
286280

287-
// Open the problems view
288-
await runCommand(page, 'View: Focus Problems')
281+
await openProblemsView(page)
289282

290283
// Assert error is present in the problems view
291284
const errorElement = page
@@ -331,8 +324,7 @@ test.describe('Diagnostics for bad audits', () => {
331324
// Wait for the error to appear
332325
await page.waitForSelector('text=Error creating context')
333326

334-
// Open the problems view
335-
await runCommand(page, 'View: Focus Problems')
327+
await openProblemsView(page)
336328

337329
// Assert that the error is present in the problems view
338330
const errorElement = page

vscode/extension/tests/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ export const pipInstall = async (
8787
export const openLineageView = async (page: Page) =>
8888
await runCommand(page, 'Lineage: Focus On View')
8989

90+
/**
91+
* Open the problems/diagnostics view in the given window.
92+
*/
93+
export const openProblemsView = async (page: Page) =>
94+
await runCommand(page, 'View: Focus Problems')
95+
9096
/**
9197
* Restart the SQLMesh servers
9298
*/

0 commit comments

Comments
 (0)