Skip to content

Commit 49a0221

Browse files
committed
Fix playwright
1 parent 91ad96b commit 49a0221

File tree

6 files changed

+141
-103
lines changed

6 files changed

+141
-103
lines changed

playwright/tests/bucket-explorer.p.spec.ts

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ test('navigate config bucket', async ({ page, utils }) => {
3333
await page.getByText('config').click()
3434
await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/config%2F/)
3535
await page.getByRole('cell', { name: 'DEFAULT' }).click()
36-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
36+
await expect(page.locator('[data-test="file-path"]')).toContainText(
3737
'/ DEFAULT /',
3838
)
3939
await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/config%2FDEFAULT%2F/)
4040
await page.getByRole('cell', { name: 'targets', exact: true }).click()
41-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
41+
await expect(page.locator('[data-test="file-path"]')).toContainText(
4242
'/ DEFAULT / targets /',
4343
)
4444
await expect(page).toHaveURL(
4545
/.*\/tools\/bucketexplorer\/config%2FDEFAULT%2Ftargets%2F/,
4646
)
4747
await page.getByRole('cell', { name: 'INST', exact: true }).click()
48-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
48+
await expect(page.locator('[data-test="file-path"]')).toContainText(
4949
'/ DEFAULT / targets / INST /',
5050
)
5151
await expect(page).toHaveURL(
@@ -71,14 +71,14 @@ test('navigate config bucket', async ({ page, utils }) => {
7171
)
7272

7373
await page.locator('[data-test="be-nav-back"]').click()
74-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
74+
await expect(page.locator('[data-test="file-path"]')).toContainText(
7575
'/ DEFAULT / targets /',
7676
)
7777
await expect(page).toHaveURL(
7878
/.*\/tools\/bucketexplorer\/config%2FDEFAULT%2Ftargets%2F/,
7979
)
8080
await page.locator('[data-test="be-nav-back"]').click()
81-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
81+
await expect(page.locator('[data-test="file-path"]')).toContainText(
8282
'/ DEFAULT /',
8383
)
8484
await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/config%2FDEFAULT%2F/)
@@ -96,28 +96,28 @@ test('navigate gems volume', async ({ page, utils }) => {
9696
// Note the URL is prefixed with %2F, i.e. '/'
9797
await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/%2Fgems%2F/)
9898
await page.getByRole('cell', { name: 'cosmoscache' }).click()
99-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
99+
await expect(page.locator('[data-test="file-path"]')).toContainText(
100100
'/ cosmoscache /',
101101
)
102102
await expect(page).toHaveURL(
103103
/.*\/tools\/bucketexplorer\/%2Fgems%2Fcosmoscache%2F/,
104104
)
105105

106106
await page.locator('[data-test="search-input"] input').fill('bucket')
107-
await expect(page.locator('tbody > tr')).toHaveCount(1)
107+
await expect(page.locator('tbody > tr')).toHaveCount(2)
108108
// Download the file
109-
await utils.download(page, 'tbody > tr [data-test="download-file"]')
109+
await utils.download(page, 'tbody > tr [data-test="download-file"] >> nth=0')
110110

111111
// Reload and ensure we get to the same place
112112
await page.reload()
113-
await expect(page.locator('[data-test="file-path"]')).toHaveText(
113+
await expect(page.locator('[data-test="file-path"]')).toContainText(
114114
'/ cosmoscache /',
115115
)
116116
await expect(page).toHaveURL(
117117
/.*\/tools\/bucketexplorer\/%2Fgems%2Fcosmoscache%2F/,
118118
)
119119
await page.locator('[data-test="search-input"] input').fill('bucket')
120-
await expect(page.locator('tbody > tr')).toHaveCount(1)
120+
await expect(page.locator('tbody > tr')).toHaveCount(2)
121121
})
122122

123123
test('direct URLs', async ({ page, utils }) => {
@@ -170,7 +170,13 @@ test('upload and delete', async ({ page, utils }) => {
170170
await expect(page.locator('textarea')).toHaveText('')
171171
await page.locator('textarea').fill(`print('hello world')`)
172172
await page.locator('[data-test=script-runner-file]').click()
173-
await page.locator('text=Save File').click()
173+
await page.locator('[data-test=start-button]').click()
174+
await expect(page.locator('[data-test=state] input')).toHaveValue(
175+
'completed',
176+
{
177+
timeout: 30000,
178+
},
179+
)
174180

175181
await page.goto('/tools/bucketexplorer')
176182
await page.getByText('config').click()
@@ -247,9 +253,9 @@ test('navigate logs and tools bucket', async ({ page, utils }) => {
247253
await page.getByText('tools').click()
248254
await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/tools%2F/)
249255
if (process.env.ENTERPRISE === '1') {
250-
await expect(page.locator('tbody > tr')).toHaveCount(20)
256+
await expect(page.locator('tbody > tr')).toHaveCount(23)
251257
} else {
252-
await expect(page.locator('tbody > tr')).toHaveCount(17)
258+
await expect(page.locator('tbody > tr')).toHaveCount(20)
253259
}
254260
})
255261

@@ -259,54 +265,57 @@ test('auto refreshes to update files', async ({
259265
toolPath,
260266
context,
261267
}) => {
262-
const randomDir = 'tmp_' + `${Math.random()}`.substring(2)
263-
// Upload something from the first tab to make sure the tmp dir exists
264-
await page.getByText('config').click()
265-
await expect(page.getByLabel('prepended action')).toBeVisible()
266-
const [fileChooser1] = await Promise.all([
267-
page.waitForEvent('filechooser'),
268-
await page.getByLabel('prepended action').click(),
269-
])
270-
await fileChooser1.setFiles('package.json')
271-
await page
272-
.locator('[data-test="upload-file-path"] input')
273-
.fill(`DEFAULT/${randomDir}/package1.json`)
274-
await page.locator('[data-test="upload-file-submit-btn"]').click()
268+
// Create a file so we have something in __TEMP__
269+
await page.goto('/tools/scriptrunner')
270+
await expect(page.locator('.v-app-bar')).toContainText('Script Runner')
271+
await page.locator('[data-test=script-runner-file]').click()
272+
await page.locator('text=New File').click()
273+
await expect(page.locator('textarea')).toHaveText('')
274+
await page.locator('textarea').fill(`print('hello world')`)
275+
await page.locator('[data-test=start-button]').click()
276+
await expect(page.locator('[data-test=state] input')).toHaveValue(
277+
'completed',
278+
{
279+
timeout: 30000,
280+
},
281+
)
275282

276-
// Open another tab and navigate to the tmp dir
283+
// Open another tab and navigate to the __TEMP__ dir
277284
const pageTwo = await context.newPage()
278285
pageTwo.goto(toolPath)
279286
await pageTwo.getByText('config').click()
280287
await pageTwo.getByRole('cell', { name: 'DEFAULT' }).click()
281-
await pageTwo.getByRole('cell', { name: randomDir }).click()
288+
await pageTwo.getByRole('cell', { name: 'targets_modified' }).click()
289+
await pageTwo.getByRole('cell', { name: '__TEMP__' }).click()
282290

283291
// Set the refresh interval on the second tab to be really slow
284292
await pageTwo.locator('[data-test=bucket-explorer-file]').click()
285293
await pageTwo.locator('[data-test=bucket-explorer-file-options]').click()
286294
await pageTwo
287295
.locator('.v-dialog [data-test=refresh-interval] input')
288296
.fill('1000')
289-
await pageTwo
290-
.locator('.v-dialog [data-test=refresh-interval] input')
291-
.press('Enter')
292-
await pageTwo.locator('.v-dialog').press('Escape')
297+
await pageTwo.getByRole('button', { name: 'Save' }).click()
293298

294299
// Upload a file from the first tab
300+
await page.goto(
301+
'/tools/bucketexplorer/config%2FDEFAULT%2Ftargets_modified%2F__TEMP__%2F',
302+
)
303+
await expect(page.locator('.v-app-bar')).toContainText('Bucket Explorer')
295304
await expect(page.getByLabel('prepended action')).toBeVisible()
296-
const [fileChooser2] = await Promise.all([
305+
const [fileChooser] = await Promise.all([
297306
page.waitForEvent('filechooser'),
298307
await page.getByLabel('prepended action').click(),
299308
])
300-
await fileChooser2.setFiles('package.json')
309+
await fileChooser.setFiles('package.json')
301310
await page
302311
.locator('[data-test="upload-file-path"] input')
303-
.fill(`DEFAULT/${randomDir}/package2.json`)
312+
.fill(`DEFAULT/targets_modified/__TEMP__/refresh_package.json`)
304313
await page.locator('[data-test="upload-file-submit-btn"]').click()
305314

306315
// The second tab shouldn't have refreshed yet, so the file shouldn't be there
307316
await page.locator('tbody> tr').first().waitFor()
308317
await expect(
309-
pageTwo.getByRole('cell', { name: 'package2.json' }),
318+
pageTwo.getByRole('cell', { name: 'refresh_package.json' }),
310319
).not.toBeVisible({ timeout: 10000 })
311320

312321
// Set the refresh interval on the second tab to 1s
@@ -315,24 +324,17 @@ test('auto refreshes to update files', async ({
315324
await pageTwo
316325
.locator('.v-dialog [data-test=refresh-interval] input')
317326
.fill('1')
318-
await pageTwo
319-
.locator('.v-dialog [data-test=refresh-interval] input')
320-
.press('Enter')
321-
await pageTwo.locator('.v-dialog').press('Escape')
327+
await pageTwo.getByRole('button', { name: 'Save' }).click()
322328

323329
// Second tab should auto refresh in 1s and then the file should be there
324330
await page.locator('tbody> tr').first().waitFor()
325331
await expect(
326-
pageTwo.getByRole('cell', { name: 'package2.json' }),
332+
pageTwo.getByRole('cell', { name: 'refresh_package.json' }),
327333
).toBeVisible()
328334

329335
// Cleanup
330336
await page
331-
.locator('tr:has-text("package1.json") [data-test="delete-file"]')
332-
.click()
333-
await page.locator('[data-test="confirm-dialog-delete"]').click()
334-
await page
335-
.locator('tr:has-text("package2.json") [data-test="delete-file"]')
337+
.locator('tr:has-text("refresh_package.json") [data-test="delete-file"]')
336338
.click()
337339
await page.locator('[data-test="confirm-dialog-delete"]').click()
338340
})

playwright/tests/command-sender.p.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,6 @@ test('disables command validation', async ({ page, utils }) => {
707707

708708
await page.locator('[data-test="select-send"]').click()
709709
await expect(page.locator('main')).toContainText(
710-
'cmd("INST TIME_OFFSET with SECONDS 0, IP_ADDRESS \'127.0.0.1\'") sent',
710+
'cmd("INST TIME_OFFSET with SECONDS 0, IP_ADDRESS \'127.0.0.1\'", validate=False) sent',
711711
)
712712
})

playwright/tests/data-extractor.p.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ test('cancels a process', async ({ page, utils }) => {
162162

163163
test('adds an entire target', async ({ page, utils }) => {
164164
await utils.addTargetPacketItem('INST')
165-
await expect(page.getByText('1-20 of 161')).toBeVisible()
165+
await expect(page.getByText('1-20 of 234')).toBeVisible()
166166
})
167167

168168
test('adds an entire packet', async ({ page, utils }) => {
@@ -305,6 +305,7 @@ test('outputs full column names', async ({ page, utils }) => {
305305
// Switch back and verify
306306
await page.locator('[data-test=data-extractor-mode]').click()
307307
await page.locator('text=Normal Columns').click()
308+
await page.locator('[data-test=data-extractor-mode]').click()
308309
// Create a new end time so we get a new filename
309310
start = sub(new Date(), { minutes: 2 })
310311
await page
@@ -319,6 +320,7 @@ test('fills values', async ({ page, utils }) => {
319320
const start = sub(new Date(), { minutes: 1 })
320321
await page.locator('[data-test=data-extractor-mode]').click()
321322
await page.locator('text=Fill Down').click()
323+
await page.locator('[data-test=data-extractor-mode]').click()
322324
await page
323325
.locator('[data-test=start-time] input')
324326
.fill(format(start, 'HH:mm:ss'))

playwright/tests/data-viewer.p.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test.use({
2727

2828
async function addComponent(page, utils, target: string, packet: string) {
2929
await page.locator('[data-test=new-tab]').click()
30+
await utils.sleep(500) // wait for the component selector to be clickable
3031
await utils.selectTargetPacketItem(target, packet)
3132
await page.locator('[data-test=select-send]').click() // add the packet to the list
3233
await page.locator('[data-test=add-component]').click()
@@ -83,7 +84,8 @@ test('saves, opens, and resets the configuration', async ({ page, utils }) => {
8384
await page.getByRole('button', { name: 'Dismiss' }).click({ timeout: 20000 })
8485

8586
// Verify the config
86-
await page.getByRole('tab', { name: 'Test1' }).click()
87+
await expect(page.getByText('Current Time:')).toBeVisible()
88+
await page.getByRole('tab', { name: 'Test2' }).getByRole('button').click()
8789
await expect(page.getByText('COSMOS Packet Raw/Decom')).toBeVisible()
8890
// Verify display setting
8991
await page.locator('[data-test=history-component-open-settings]').click()
@@ -95,8 +97,6 @@ test('saves, opens, and resets the configuration', async ({ page, utils }) => {
9597
await expect(
9698
page.locator('[data-test=display-settings-card]'),
9799
).not.toBeVisible()
98-
await page.getByRole('tab', { name: 'Test2' }).click()
99-
await expect(page.getByText('Current Time:')).toBeVisible()
100100

101101
// Reset this test configuration
102102
await page.locator('[data-test=data-viewer-file]').click()
@@ -192,7 +192,10 @@ test('deletes a component and tab', async ({ page, utils }) => {
192192
await expect(
193193
page.getByRole('tab', { name: 'INST ADCS [ RAW ]' }),
194194
).toBeVisible()
195-
await page.locator('[data-test=delete-component]').click()
195+
await page
196+
.getByRole('tab', { name: 'INST ADCS [ RAW ]' })
197+
.getByRole('button')
198+
.click()
196199
await expect(page.locator('.v-card > .v-card-title').first()).toHaveText(
197200
"You're not viewing any packets",
198201
)
@@ -411,6 +414,7 @@ test('displays event message format', async ({ page, utils }) => {
411414
await page.locator('[data-test="new-tab"]').click()
412415
await page.locator('[data-test="select-component"]').click()
413416
await page.getByText('COSMOS Event Message').click()
417+
await utils.sleep(500) // wait for the packet/item selector to be clickable
414418
await utils.selectTargetPacketItem('INST', 'HEALTH_STATUS', 'CCSDSVER')
415419
await page.locator('button:has-text("Add Item")').click()
416420
await page.locator('[data-test=add-component]').click()
@@ -419,14 +423,11 @@ test('displays event message format', async ({ page, utils }) => {
419423
await expect(page.locator('[data-test=history-component-text-area] textarea'))
420424
// Create regular expression to match the line:
421425
// Time: 2024-10-01T01:15:49.419Z TEMP1: -1.119 C
422-
.toHaveValue(
423-
/\d*/,
424-
)
426+
.toHaveValue(/\d*/)
425427
await expect(page.locator('[data-test=history-component-text-area] textarea'))
426428
// Create regular expression to match the line:
427429
// Time: 2024-10-01T01:15:49.419Z TEMP1: -1.119 C
428-
.not
429-
.toHaveValue(
430+
.not.toHaveValue(
430431
/Time: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\s+CCSDSVER: .*/,
431432
)
432433
})

0 commit comments

Comments
 (0)