Skip to content

Commit

Permalink
test(*): form button data-testid changes (#274)
Browse files Browse the repository at this point in the history
* test(*): form button data-testid changes

* test(*): form button data-testid changes

* chore(*): use published versions
  • Loading branch information
Leopoldthecoder authored Aug 22, 2024
1 parent 3214da7 commit 34689ac
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 135 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
},
"dependencies": {
"@kong-ui-public/app-layout": "^4.2.24",
"@kong-ui-public/entities-certificates": "^3.5.2",
"@kong-ui-public/entities-consumer-credentials": "^3.2.33",
"@kong-ui-public/entities-consumers": "^3.4.2",
"@kong-ui-public/entities-data-plane-nodes": "^0.2.32",
"@kong-ui-public/entities-gateway-services": "^3.6.2",
"@kong-ui-public/entities-key-sets": "^3.4.2",
"@kong-ui-public/entities-keys": "^3.4.2",
"@kong-ui-public/entities-plugins": "^8.8.3",
"@kong-ui-public/entities-routes": "^3.2.0",
"@kong-ui-public/entities-shared": "^3.2.0",
"@kong-ui-public/entities-snis": "^3.4.2",
"@kong-ui-public/entities-upstreams-targets": "^3.4.2",
"@kong-ui-public/entities-vaults": "^3.10.2",
"@kong-ui-public/entities-certificates": "^3.5.4",
"@kong-ui-public/entities-consumer-credentials": "^3.2.35",
"@kong-ui-public/entities-consumers": "^3.4.4",
"@kong-ui-public/entities-data-plane-nodes": "^0.2.34",
"@kong-ui-public/entities-gateway-services": "^3.6.5",
"@kong-ui-public/entities-key-sets": "^3.4.4",
"@kong-ui-public/entities-keys": "^3.4.4",
"@kong-ui-public/entities-plugins": "^8.10.3",
"@kong-ui-public/entities-routes": "^3.6.6",
"@kong-ui-public/entities-shared": "^3.7.4",
"@kong-ui-public/entities-snis": "^3.4.4",
"@kong-ui-public/entities-upstreams-targets": "^3.4.4",
"@kong-ui-public/entities-vaults": "^3.10.4",
"@kong-ui-public/forms": "^4.0.2",
"@kong-ui-public/i18n": "^2.2.2",
"@kong-ui-public/misc-widgets": "^2.1.14",
Expand Down
12 changes: 5 additions & 7 deletions tests/playwright/commands/fillEntityForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Params {
method?: 'type' | 'fill';

/**
* If set to true, the helper assumes that a model will show up after performing the `*-submit` action.
* If set to true, the helper assumes that a modal will show up after performing the `*-submit` action.
* And the primary button on the modal will be clicked.
*/
handleModal?: boolean;
Expand Down Expand Up @@ -62,14 +62,12 @@ export const fillEntityForm = async (params: Params) => {
}
}

if (!withAction) {
return
if (withAction === 'submit') {
await page.getByTestId('form-actions').locator('.k-button.primary').click()
} else if (withAction === 'cancel') {
await page.getByTestId('form-actions').locator('.k-button.secondary').click()
}

await page.getByTestId(`form-${withAction}`)
.or(page.getByTestId(`form-footer-action-${withAction}`))
.click()

if (handleModal) {
await page.locator('.modal-container .modal-footer .k-button.primary').click()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test.describe('CA certificates', () => {

test('create a CA certificate - fail', async ({ page }) => {
await page.getByTestId('new-ca-certificate').click()
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('ca_certificate-form-submit')).toBeDisabled()
})

test('create a CA certificate', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test.describe('certificates', () => {
test('create a certificate - fail', async ({ page }) => {
await page.getByTestId('new-certificate').click()
await page.waitForSelector('.k-breadcrumbs', { state: 'hidden' })
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('certificate-form-submit')).toBeDisabled()
})

test('create a certificate', async ({ page }) => {
Expand Down
10 changes: 5 additions & 5 deletions tests/playwright/specs/consumers/01-Consumers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ test.describe('consumers', () => {
await page.waitForSelector('.kong-ui-entities-consumer-form')

// exit from cancel button
await expect(page.locator('[data-testid="form-cancel"]')).toContainText('Cancel')
await withNavigation(page, () => page.click('[data-testid="form-cancel"]'))
await expect(page.locator('[data-testid="consumer-form-cancel"]')).toContainText('Cancel')
await withNavigation(page, () => page.click('[data-testid="consumer-form-cancel"]'))
})

test('consumer create - save button is disabled', async ({ page }) => {
await withNavigation(page, () => page.click('.table-empty-state .primary'))
await page.waitForSelector('.kong-ui-entities-consumer-form')
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('consumer-form-submit')).toBeDisabled()
})

test('consumer create - success', async ({ page }) => {
Expand Down Expand Up @@ -79,7 +79,7 @@ test.describe('consumers', () => {
// enter edit mode then cancel
await withNavigation(page, () => clickEntityListAction(page, 'edit'))
await page.waitForSelector('.kong-ui-entities-consumer-form')
await withNavigation(page, () => page.click('[data-testid="form-cancel"]'))
await withNavigation(page, () => page.click('[data-testid="consumer-form-cancel"]'))
await page.waitForSelector('.kong-ui-entities-consumers-list')

// enter edit mode then modify and save
Expand Down Expand Up @@ -161,7 +161,7 @@ test.describe('consumers', () => {
// enter edit mode then cancel
await withNavigation(page, () => clickEntityListAction(page, 'edit'))
await page.waitForSelector('.kong-ui-entities-consumer-form')
await withNavigation(page, () => page.click('[data-testid="form-cancel"]'))
await withNavigation(page, () => page.click('[data-testid="consumer-form-cancel"]'))
await page.waitForSelector('.kong-ui-entities-consumers-list')

// enter edit mode then modify and save
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test.describe('consumer plugins', () => {
await page.locator('#tags').fill(`${mockTag}${mockTag}`)
await withNavigation(
page,
async () => await page.locator('[data-testid="form-cancel"]').click(),
async () => await page.locator('[data-testid="plugin-form-cancel"]').click(),
)
await expect(page.locator('.k-table .table-wrapper [data-testid="tags"]')).toHaveText(mockTag)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/specs/key-sets/01-KeySets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.describe('keySets', () => {
test('cancel the creation of a key set', async ({ page }) => {
await expect(page.locator('.table-empty-state')).toBeVisible()
await withNavigation(page, () => page.locator('.table-empty-state .primary').click())
await withNavigation(page, () => page.locator('.form-actions [data-testid="form-cancel"]').click())
await withNavigation(page, () => page.locator('.form-actions [data-testid="set-form-cancel"]').click())
await expect(page.locator('.table-empty-state')).toBeVisible()
})

Expand Down
26 changes: 13 additions & 13 deletions tests/playwright/specs/routes-expressions/01-Routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ test.describe('route creation page', () => {
// traditional tab should be active by default
await expect(page.locator('#traditional-tab')).toHaveClass(/active/)
// submit button should be disabled
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('route-form-submit')).toBeDisabled()
// fill in a path
await page.getByTestId('route-form-paths-input-1').fill('/trad/1')
// submit button should be enabled
await expect(page.getByTestId('form-submit')).toBeEnabled()
await expect(page.getByTestId('route-form-submit')).toBeEnabled()

// switch to the expressions tab
await page.locator('#expressions-tab').click()
// submit button should be disabled again
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('route-form-submit')).toBeDisabled()

// switch back to the traditional tab
await page.locator('#traditional-tab').click()
// submit button should be enabled again
await expect(page.getByTestId('form-submit')).toBeEnabled()
await expect(page.getByTestId('route-form-submit')).toBeEnabled()

// switch back to the expressions tab
await page.locator('#expressions-tab').click()
// submit button should be disabled again
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('route-form-submit')).toBeDisabled()

// the editor shows invalid because it is empty
await expect(page.locator('.expression-editor')).toHaveClass(/invalid/)
Expand All @@ -79,21 +79,21 @@ test.describe('route creation page', () => {
// the editor should be no longer invalid
await expect(page.locator('.expression-editor')).not.toHaveClass(/invalid/)
// and the submit button should be enabled
await expect(page.getByTestId('form-submit')).toBeEnabled()
await expect(page.getByTestId('route-form-submit')).toBeEnabled()

// delete the last character
await page.keyboard.press('Backspace')
// the editor should be invalid again
await expect(page.locator('.expression-editor')).toHaveClass(/invalid/)
// but the submit button is still enabled because we let the server handle uncaught errors
await expect(page.getByTestId('form-submit')).toBeEnabled()
await expect(page.getByTestId('route-form-submit')).toBeEnabled()
})

test('view configuration', async ({ page }) => {
await page.getByTestId('form-content').isVisible()

// open the slide out
await page.getByTestId('form-view-configuration').click()
await page.getByTestId('route-form-view-configuration').click()
await page.locator('#yaml-tab').click()
const slideOutTabs = page.getByTestId('form-view-configuration-slideout-tabs')
const configBlock = slideOutTabs.getByTestId('k-code-block').locator('code')
Expand Down Expand Up @@ -146,7 +146,7 @@ test.describe('route creation page', () => {

await page.getByTestId('route-form-name').fill('trad-1')
await page.getByTestId('route-form-paths-input-1').fill('/trad/1')
const submit = page.getByTestId('form-submit')
const submit = page.getByTestId('route-form-submit')

await expect(submit).toBeEnabled()
await submit.click()
Expand All @@ -172,7 +172,7 @@ test.describe('route creation page', () => {
await editor.click()
await page.keyboard.type('http.path == "/expr/1"')

const submit = page.getByTestId('form-submit')
const submit = page.getByTestId('route-form-submit')

await expect(submit).toBeEnabled()
await submit.click()
Expand Down Expand Up @@ -202,7 +202,7 @@ test.describe('route creation page', () => {
// switch back to the traditional tab
await page.locator('#traditional-tab').click()

const submit = page.getByTestId('form-submit')
const submit = page.getByTestId('route-form-submit')

await expect(submit).toBeEnabled()
await submit.click()
Expand Down Expand Up @@ -237,7 +237,7 @@ test.describe('route creation page', () => {
// switch to the expressions tab
await page.locator('#expressions-tab').click()

const submit = page.getByTestId('form-submit')
const submit = page.getByTestId('route-form-submit')

await expect(submit).toBeEnabled()
await submit.click()
Expand Down Expand Up @@ -267,7 +267,7 @@ test.describe('route creation page', () => {
// the editor shows invalid
await expect(page.locator('.expression-editor')).toHaveClass(/invalid/)

const submit = page.getByTestId('form-submit')
const submit = page.getByTestId('route-form-submit')

// we can still submit
await expect(submit).toBeEnabled()
Expand Down
6 changes: 3 additions & 3 deletions tests/playwright/specs/routes/01-Routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test.describe('routes', () => {
await withNavigation(page, () =>
page.locator('.table-empty-state .primary').click(),
)
await page.locator('[data-testid="form-cancel"]').click()
await page.locator('[data-testid="route-form-cancel"]').click()
await expectEmptyEntityList(page, 'routes', 'Configure a New Route')
})

Expand All @@ -94,7 +94,7 @@ test.describe('routes', () => {
page.locator('.table-empty-state .primary').click(),
)

await expect(page.locator('[data-testid="form-submit"]')).toBeDisabled()
await expect(page.locator('[data-testid="route-form-submit"]')).toBeDisabled()
})

test('route create - cannot be submit if only protocol is clicked', async ({ page }) => {
Expand All @@ -103,7 +103,7 @@ test.describe('routes', () => {
)

await page.locator('[data-testid="route-form-protocols"]').fill('http')
await expect(page.locator('[data-testid="form-submit"]')).toBeDisabled()
await expect(page.locator('[data-testid="route-form-submit"]')).toBeDisabled()
})

test('route create - fail with invalid paths', async ({ page }) => {
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright/specs/services/01-Service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe('services', () => {
await withNavigation(page, () =>
page.locator('.table-empty-state .primary').click(),
)
await page.getByTestId('form-cancel').click()
await page.getByTestId('service-form-cancel').click()
await expectEmptyEntityList(page, 'gateway-services', 'Configure a New Gateway Service')
})

Expand All @@ -61,7 +61,7 @@ test.describe('services', () => {
page,
formData: { 'gateway-service-name-input': 'mockbin.service' },
})
await expect(page.getByTestId('form-submit')).toBeDisabled()
await expect(page.getByTestId('service-form-submit')).toBeDisabled()
})

test('service create - successful create', async ({ page }) => {
Expand Down Expand Up @@ -301,7 +301,7 @@ test.describe('services', () => {
await expect(page.getByTestId('gateway-service-tls-verify-checkbox')).not.toBeChecked()
await page.getByTestId('gateway-service-tls-verify-checkbox').click()
await page.getByTestId('gateway-service-tls-verify-false-option').click()
await withNavigation(page, () => page.getByTestId('form-submit').click())
await withNavigation(page, () => page.getByTestId('service-form-submit').click())
await expect(page.locator('[data-testid="tls_verify-property-value"]')).toHaveText('Off')
await waitAndDismissToasts(page)

Expand All @@ -310,7 +310,7 @@ test.describe('services', () => {

await expect(page.getByTestId('gateway-service-tls-verify-false-option')).toBeChecked()
await page.getByTestId('gateway-service-tls-verify-true-option').click()
await withNavigation(page, () => page.getByTestId('form-submit').click())
await withNavigation(page, () => page.getByTestId('service-form-submit').click())
await expect(page.locator('[data-testid="tls_verify-property-value"]')).toHaveText('On')
await waitAndDismissToasts(page)

Expand Down
4 changes: 2 additions & 2 deletions tests/playwright/specs/services/02-ServiceRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test.describe('service routes', () => {
)

await expect(page.locator('.kong-ui-entities-route-form')).toBeVisible()
await page.locator('[data-testid="form-cancel"]').click()
await page.locator('[data-testid="route-form-cancel"]').click()

await expectEmptyEntityList(page, 'routes', 'Configure a New Route')
})
Expand All @@ -69,7 +69,7 @@ test.describe('service routes', () => {
page.locator('.kong-ui-entities-routes-list .table-empty-state .primary').click(),
)

await expect(page.locator('[data-testid="form-submit"]')).toBeDisabled()
await expect(page.locator('[data-testid="route-form-submit"]')).toBeDisabled()
})

test('create an service-associated route via tab', async ({ page }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/specs/services/03-ServicePlugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test.describe('service plugins', () => {
await withNavigation(page, () =>
page
.locator('[data-testid="form-actions"]')
.locator('[data-testid="form-cancel"]')
.locator('[data-testid="plugin-form-cancel"]')
.click(),
)
await page.waitForSelector('.kong-ui-entities-plugins-list')
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/specs/snis/01-SNIs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test.describe('snis', () => {
await page.locator('[data-testid="sni-form-certificate-id"]').fill(certificate.id)
await (await page.waitForSelector(`[data-testid="select-item-${certificate.id}"]`)).click()

await expect(page.locator('[data-testid="form-submit"]')).toBeDisabled()
await expect(page.locator('[data-testid="sni-form-submit"]')).toBeDisabled()
})

test('create an sni', async ({ page }) => {
Expand Down
Loading

0 comments on commit 34689ac

Please sign in to comment.