8
8
9
9
import { clickRowAction , expect , expectRowVisible , test } from './utils'
10
10
11
- const defaultRules = [ 'allow-internal-inbound' , 'allow-ssh' , 'allow-icmp' , 'allow-rdp' ]
11
+ const defaultRules = [ 'allow-internal-inbound' , 'allow-ssh' , 'allow-icmp' ]
12
12
13
13
test ( 'can create firewall rule' , async ( { page } ) => {
14
14
await page . goto ( '/projects/mock-project/vpcs/mock-vpc' )
@@ -19,7 +19,7 @@ test('can create firewall rule', async ({ page }) => {
19
19
await expect ( page . locator ( `text="${ name } "` ) ) . toBeVisible ( )
20
20
}
21
21
const rows = page . locator ( 'tbody >> tr' )
22
- await expect ( rows ) . toHaveCount ( 4 )
22
+ await expect ( rows ) . toHaveCount ( 3 )
23
23
24
24
const modal = page . getByRole ( 'dialog' , { name : 'Add firewall rule' } )
25
25
await expect ( modal ) . toBeHidden ( )
@@ -100,7 +100,7 @@ test('can create firewall rule', async ({ page }) => {
100
100
const tooltip = page . getByRole ( 'tooltip' , { name : 'Other filters UDP Port 123-' } )
101
101
await expect ( tooltip ) . toBeVisible ( )
102
102
103
- await expect ( rows ) . toHaveCount ( 5 )
103
+ await expect ( rows ) . toHaveCount ( 4 )
104
104
for ( const name of defaultRules ) {
105
105
await expect ( page . locator ( `text="${ name } "` ) ) . toBeVisible ( )
106
106
}
@@ -241,7 +241,7 @@ test('can update firewall rule', async ({ page }) => {
241
241
await page . getByRole ( 'tab' , { name : 'Firewall Rules' } ) . click ( )
242
242
243
243
const rows = page . locator ( 'tbody >> tr' )
244
- await expect ( rows ) . toHaveCount ( 4 )
244
+ await expect ( rows ) . toHaveCount ( 3 )
245
245
246
246
// allow-icmp is the one we're doing to change
247
247
const oldNameCell = page . locator ( 'td >> text="allow-icmp"' )
@@ -298,7 +298,7 @@ test('can update firewall rule', async ({ page }) => {
298
298
await expect ( newNameCell ) . toBeVisible ( )
299
299
await expect ( oldNameCell ) . toBeHidden ( )
300
300
301
- await expect ( rows ) . toHaveCount ( 4 )
301
+ await expect ( rows ) . toHaveCount ( 3 )
302
302
303
303
// new target shows up in target cell
304
304
await expect ( page . locator ( 'text=subnetedit-filter-subnetICMP' ) ) . toBeVisible ( )
@@ -317,28 +317,44 @@ test('create from existing rule', async ({ page }) => {
317
317
const modal = page . getByRole ( 'dialog' , { name : 'Add firewall rule' } )
318
318
await expect ( modal ) . toBeHidden ( )
319
319
320
- await clickRowAction ( page , 'allow-rdp' , 'Clone' )
320
+ await clickRowAction ( page , 'allow-icmp' , 'Clone' )
321
+
322
+ await expect ( page ) . toHaveURL ( url + '-new/allow-icmp' )
323
+ await expect ( modal ) . toBeVisible ( )
324
+ await expect ( modal . getByRole ( 'textbox' , { name : 'Name' , exact : true } ) ) . toHaveValue (
325
+ 'allow-icmp-copy'
326
+ )
327
+
328
+ await expect ( modal . getByRole ( 'checkbox' , { name : 'TCP' } ) ) . not . toBeChecked ( )
329
+ await expect ( modal . getByRole ( 'checkbox' , { name : 'UDP' } ) ) . not . toBeChecked ( )
330
+ await expect ( modal . getByRole ( 'checkbox' , { name : 'ICMP' } ) ) . toBeChecked ( )
331
+
332
+ // no port filters
333
+ const portFilters = modal . getByRole ( 'table' , { name : 'Port filters' } )
334
+ await expect ( portFilters ) . toBeHidden ( )
335
+
336
+ const targets = modal . getByRole ( 'table' , { name : 'Targets' } )
337
+ await expect ( targets . getByRole ( 'row' , { name : 'Name: default, Type: vpc' } ) ) . toBeVisible ( )
338
+
339
+ // close the modal
340
+ await page . keyboard . press ( 'Escape' )
341
+ await expect ( modal ) . toBeHidden ( )
342
+
343
+ // do it again with a different rule
344
+ await clickRowAction ( page , 'allow-ssh' , 'Clone' )
321
345
322
- await expect ( page ) . toHaveURL ( url + '-new/allow-rdp' )
323
346
await expect ( modal ) . toBeVisible ( )
324
347
await expect ( modal . getByRole ( 'textbox' , { name : 'Name' , exact : true } ) ) . toHaveValue (
325
- 'allow-rdp -copy'
348
+ 'allow-ssh -copy'
326
349
)
327
350
351
+ await expect ( portFilters . getByRole ( 'cell' , { name : '22' , exact : true } ) ) . toBeVisible ( )
352
+
328
353
await expect ( modal . getByRole ( 'checkbox' , { name : 'TCP' } ) ) . toBeChecked ( )
329
354
await expect ( modal . getByRole ( 'checkbox' , { name : 'UDP' } ) ) . not . toBeChecked ( )
330
355
await expect ( modal . getByRole ( 'checkbox' , { name : 'ICMP' } ) ) . not . toBeChecked ( )
331
356
332
- await expect (
333
- modal
334
- . getByRole ( 'table' , { name : 'Port filters' } )
335
- . getByRole ( 'cell' , { name : '3389' , exact : true } )
336
- ) . toBeVisible ( )
337
- await expect (
338
- modal
339
- . getByRole ( 'table' , { name : 'Targets' } )
340
- . getByRole ( 'row' , { name : 'Name: default, Type: vpc' } )
341
- ) . toBeVisible ( )
357
+ await expect ( targets . getByRole ( 'row' , { name : 'Name: default, Type: vpc' } ) ) . toBeVisible ( )
342
358
} )
343
359
344
360
const rulePath = '/projects/mock-project/vpcs/mock-vpc/firewall-rules/allow-icmp/edit'
0 commit comments