Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-form): hide scoped plugin's scope change #297

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pages/plugins/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:config="config"
:plugin-type="pluginType"
:plugin-id="pluginId"
:hide-scope-selection="hideScopeSelection"
@error:fetch-schema="onFetchSchemaError"
@update="onSave"
/>
Expand Down Expand Up @@ -66,6 +67,8 @@ const entityScope = computed(() => {
return null
})

const hideScopeSelection = computed(() => !!entityScope.value)

const redirectPath = useURLFromRouteQuery('redirect')

const cancelRoute = computed(() => {
Expand Down
5 changes: 2 additions & 3 deletions tests/playwright/specs/consumers/03-ConsumerPlugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test.describe('consumer plugins', () => {

test('install a plugin from the Plugins tab', async ({ page }) => {
await withNavigation(page, async () => await clickEntityListAction(page, 'view'))
const uuid = await page.locator('.copy-container').innerText()

await switchDetailTab(page, 'plugins')
await withNavigation(
Expand All @@ -45,8 +44,8 @@ test.describe('consumer plugins', () => {
page,
async () => await page.getByTestId('datadog-card').click(),
)
await expect(page.locator('.autosuggest input#consumer-id')).toBeVisible()
await expect(page.locator('.autosuggest input#consumer-id')).toHaveValue(new RegExp(`${mockConsumerName}\\s*-\\s*${uuid}`))
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)
await withNavigation(
page,
async () => await page.locator('[data-testid="form-actions"] .primary').click(),
Expand Down
24 changes: 6 additions & 18 deletions tests/playwright/specs/plugins/01-Plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ test.describe('plugins', () => {

await serviceListPage.goto()
await withNavigation(page, async () => await clickEntityListAction(page, 'view'))
const uuid = (await page
.locator('[data-testid="id-property-value"]')
.locator('.copy-container')
.innerText() ?? '').trim()

await switchDetailTab(page, 'plugins')

Expand All @@ -86,8 +82,8 @@ test.describe('plugins', () => {
async () => await page.getByTestId('basic-auth-card').click(),
)

await expect(page.locator('.autosuggest input#service-id')).toBeVisible()
await expect(page.locator('.autosuggest input#service-id')).toHaveValue(new RegExp(`${mockServiceName}\\s*-\\s*${uuid}`))
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)

await expandAdvancedFields(page)
await page.locator('#config-anonymous').type('anon')
Expand Down Expand Up @@ -186,10 +182,6 @@ test.describe('plugins', () => {

await routeListPage.goto()
await withNavigation(page, async () => await clickEntityListAction(page, 'view'))
const uuid = (await page
.locator('[data-testid="id-property-value"]')
.locator('.copy-container')
.innerText() ?? '').trim()

await switchDetailTab(page, 'plugins')

Expand All @@ -203,8 +195,8 @@ test.describe('plugins', () => {
async () => await page.getByTestId('basic-auth-card').click(),
)

await expect(page.locator('.autosuggest input#route-id')).toBeVisible()
await expect(page.locator('.autosuggest input#route-id')).toHaveValue(new RegExp(`${mockRouteName}\\s*-\\s*${uuid}`))
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)

await withNavigation(
page,
Expand All @@ -222,10 +214,6 @@ test.describe('plugins', () => {
await consumerListPage.goto()

await withNavigation(page, async () => await clickEntityListAction(page, 'view'))
const uuid = (await page
.locator('[data-testid="id-property-value"]')
.locator('.copy-container')
.innerText() ?? '').trim()

await switchDetailTab(page, 'plugins')
await withNavigation(
Expand All @@ -236,8 +224,8 @@ test.describe('plugins', () => {
page,
async () => await page.getByTestId('datadog-card').click(),
)
await expect(page.locator('.autosuggest input#consumer-id')).toBeVisible()
await expect(page.locator('.autosuggest input#consumer-id')).toHaveValue(new RegExp(`${mockConsumerName}\\s*-\\s*${uuid}`))
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)
await withNavigation(
page,
async () => await page.locator('[data-testid="form-actions"] .primary').click(),
Expand Down
9 changes: 2 additions & 7 deletions tests/playwright/specs/routes/02-RoutesPlugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ test.describe('routes plugins', () => {
test(`install a plugin for the route "${mockRouteName} from the plugins tab"`, async ({ page }) => {
await withNavigation(page, async () => await clickEntityListAction(page, 'view'))

const uuid = (await page
.locator('[data-testid="id-property-value"]')
.locator('.copy-container')
.innerText() ?? '').trim()

await switchDetailTab(page, 'plugins')

await withNavigation(
Expand All @@ -69,8 +64,8 @@ test.describe('routes plugins', () => {
async () => await page.getByTestId('basic-auth-card').click(),
)

await expect(page.locator('.autosuggest input#route-id')).toBeVisible()
await expect(page.locator('.autosuggest input#route-id')).toHaveValue(new RegExp(`${mockRouteName}\\s*-\\s*${uuid}`))
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)

await withNavigation(
page,
Expand Down
21 changes: 8 additions & 13 deletions tests/playwright/specs/services/03-ServicePlugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { withNavigation } from '@pw/commands/withNavigation'
import { PluginListPage } from '@pw/pages/plugins'
import { ServiceListPage } from '@pw/pages/services'

let testService: { id: string; name: string; url: string } | undefined

const test = baseTest().extend<{
pluginListPage: PluginListPage
serviceListPage: ServiceListPage
Expand All @@ -27,10 +25,10 @@ test.describe('service plugins', () => {
await clearKongResources('/routes')
await clearKongResources('/services')

testService = (await createKongResource('/services', {
await createKongResource('/services', {
name: 'testService',
url: 'http://example.com:8080/test',
}))?.data
})
})

test.afterAll(async () => {
Expand All @@ -39,15 +37,6 @@ test.describe('service plugins', () => {
await clearKongResources('/services')
})

test('service plugin has service id prefilled', async ({ page }) => {
await page.goto(`/services/${testService?.id}/plugins`)
await withNavigation(page, () =>
page.click('.kong-ui-entities-plugins-list [data-testid="new-plugin"]'),
)
await page.getByTestId('hmac-auth-card').click()
await expect(page.locator('.autosuggest input#service-id')).toHaveValue(new RegExp(`${testService?.name}\\s*-\\s*${testService?.id}`))
})

test('create an service-associated plugin via tab', async ({ page, serviceListPage }) => {
await serviceListPage.goto()
await withNavigation(page, () => clickEntityListAction(page, 'view'))
Expand All @@ -60,6 +49,8 @@ test.describe('service plugins', () => {
page.getByTestId('basic-auth-card').click(),
)

await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)
await fillEntityForm({ page })
await withNavigation(page, () => page.getByTestId('form-actions').locator('.k-button.primary').click())
await waitAndDismissToasts(page)
Expand All @@ -85,6 +76,10 @@ test.describe('service plugins', () => {
test("edit action should bring the user to the plugin's edit page", async ({ page }) => {
await withNavigation(page, () => clickEntityListAction(page, 'edit'))
await page.waitForSelector('.kong-ui-entities-plugin-form-container')

// The scope selction should be hidden in UI
await page.waitForSelector('.vue-form-generator')
await expect(page.locator('.selection-group')).toHaveCount(0)
})

test('cancel button on the edit page should bring the user back to the plugin tab', async ({ page }) => {
Expand Down
Loading