From fa3f7bd1c9dce81d19642765ec6d758c7be87a24 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Thu, 14 Dec 2023 10:34:47 +0800 Subject: [PATCH] test(*): fix test cases --- src/pages/plugins/SelectNew.vue | 2 +- .../consumers/03-ConsumerPlugins.spec.ts | 4 ++- .../specs/plugins/01-Plugins.spec.ts | 34 ++++++++++--------- .../specs/routes/02-RoutesPlugins.spec.ts | 2 +- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/pages/plugins/SelectNew.vue b/src/pages/plugins/SelectNew.vue index 61f4fd8..e3feea5 100644 --- a/src/pages/plugins/SelectNew.vue +++ b/src/pages/plugins/SelectNew.vue @@ -43,7 +43,7 @@ const config = reactive({ getCreateRoute: (plugin: string) => ({ name: 'plugin-create', params: { - plugin, + pluginType: plugin, }, query: route.query, }), diff --git a/tests/playwright/specs/consumers/03-ConsumerPlugins.spec.ts b/tests/playwright/specs/consumers/03-ConsumerPlugins.spec.ts index 59218b1..475bd22 100644 --- a/tests/playwright/specs/consumers/03-ConsumerPlugins.spec.ts +++ b/tests/playwright/specs/consumers/03-ConsumerPlugins.spec.ts @@ -3,6 +3,7 @@ import baseTest from '@pw/base-test' import { clearKongResources } from '@pw/commands/clearKongResources' import { clickEntityListAction } from '@pw/commands/clickEntityListAction' import { createKongResource } from '@pw/commands/createKongResource' +import { expandPlugins } from '@pw/commands/expandPlugins' import { switchDetailTab } from '@pw/commands/switchDetailTab' import { withNavigation } from '@pw/commands/withNavigation' import { ConsumerListPage } from '@pw/pages/consumers' @@ -40,9 +41,10 @@ test.describe('consumer plugins', () => { page, async () => await page.locator('.empty-state-content .primary').click() ) + await expandPlugins(page) await withNavigation( page, - async () => await page.locator('a.plugin-card[title="Datadog"]').click() + async () => await page.getByTestId('datadog-card').click() ) await expect(page.locator('.autosuggest #consumer-id')).toBeVisible() await expect(page.locator('.autosuggest #consumer-id')).toHaveValue(new RegExp(`${mockConsumerName}\\s*-\\s*${uuid}`)) diff --git a/tests/playwright/specs/plugins/01-Plugins.spec.ts b/tests/playwright/specs/plugins/01-Plugins.spec.ts index 4c849c9..19a0d26 100644 --- a/tests/playwright/specs/plugins/01-Plugins.spec.ts +++ b/tests/playwright/specs/plugins/01-Plugins.spec.ts @@ -4,6 +4,7 @@ import { autocompleteDeleteModal } from '@pw/commands/autocompleteDeleteModal' import { clearKongResources } from '@pw/commands/clearKongResources' import { clickEntityListAction } from '@pw/commands/clickEntityListAction' import { createKongResource } from '@pw/commands/createKongResource' +import { expandPlugins } from '@pw/commands/expandPlugins' import { fillEntityForm } from '@pw/commands/fillEntityForm' import { switchDetailTab } from '@pw/commands/switchDetailTab' import { waitAndDismissToasts } from '@pw/commands/waitAndDismissToast' @@ -76,9 +77,10 @@ test.describe('plugins', () => { async () => await page.click('.kong-ui-entities-plugins-list [data-testid="new-plugin"]') ) + await expandPlugins(page) await withNavigation( page, - async () => await page.click('a.plugin-card[title="Basic Authentication"]') + async () => await page.getByTestId('basic-auth-card').click() ) await expect(page.locator('.autosuggest #service-id')).toBeVisible() @@ -105,7 +107,7 @@ test.describe('plugins', () => { async () => await page.click('.kong-ui-entities-plugins-list [data-testid="toolbar-add-plugin"]') ) - const pluginIcon = page.locator('.plugin-card [data-testid="Basic Authentication"] img.card-icon') + const pluginIcon = page.locator('.plugin-card-content [data-testid="Basic Authentication"] img.plugin-card-icon') await expect(pluginIcon).toBeVisible() @@ -191,7 +193,7 @@ test.describe('plugins', () => { await withNavigation( page, - async () => await page.click('a.plugin-card[title="Basic Authentication"]') + async () => await page.getByTestId('basic-auth-card').click() ) await expect(page.locator('.autosuggest #route-id')).toBeVisible() @@ -222,7 +224,7 @@ test.describe('plugins', () => { ) await withNavigation( page, - async () => await page.locator('a.plugin-card[title="Datadog"]').click() + async () => await page.getByTestId('datadog-card').click() ) await expect(page.locator('.autosuggest #consumer-id')).toBeVisible() await expect(page.locator('.autosuggest #consumer-id')).toHaveValue(new RegExp(`${mockConsumerName}\\s*-\\s*${uuid}`)) @@ -297,7 +299,7 @@ test.describe('plugins', () => { ) await withNavigation( page, - async () => await page.click('a.plugin-card[title="Basic Authentication"]') + async () => await page.getByTestId('basic-auth-card').click() ) await page.click('.plugin-protocols-select .k-multiselect-trigger') @@ -399,19 +401,19 @@ test.describe('plugins', () => { await withNavigation(page, async () => await page.locator('.kong-ui-entities-plugins-list [data-testid="toolbar-add-plugin"]').click()) await expect(filterInput).toBeVisible() await filterInput.fill('traf') - await expect(page.locator('.plugins-shell h5')).toHaveCount(1) - await expect(page.locator('.plugins-shell h5')).toContainText('Traffic Control') + await expect(page.getByTestId('k-collapse-title')).toHaveCount(1) + await expect(page.getByTestId('k-collapse-title')).toContainText('Traffic Control') await filterInput.fill('bas') - await expect(page.locator('.plugins-shell h5')).toHaveCount(1) - await expect(page.locator('.plugins-shell h5')).toContainText('Authentication') - await expect(page.locator('.plugin-card')).toHaveCount(1) - await expect(page.locator('.plugin-card h4')).toContainText('Basic Authentication') + await expect(page.getByTestId('k-collapse-title')).toHaveCount(1) + await expect(page.getByTestId('k-collapse-title')).toContainText('Authentication') + await expect(page.locator('.plugin-card-content')).toHaveCount(1) + await expect(page.locator('.plugin-card-content .card-title')).toContainText('Basic Authentication') await filterInput.fill('sad') - await expect(page.locator('[data-testid="no-results"]')).toBeVisible() - await expect(page.locator('.plugins-shell h5')).not.toBeVisible() - await expect(page.locator('.plugins-shell > section h4')).toContainText('No results found') + await expect(page.getByTestId('plugins-empty-state')).toBeVisible() + await expect(page.getByTestId('k-collapse-title')).not.toBeVisible() + await expect(page.locator('[data-testid="plugins-empty-state"] .k-empty-state-message')).toContainText('No results found') }) test('for plugin "key-auth", the default array field should have value', async ({ page, pluginListPage }) => { @@ -526,7 +528,7 @@ test.describe('plugins', () => { await pluginListPage.goto() await withNavigation(page, async () => await page.locator('.kong-ui-entities-plugins-list [data-testid="new-plugin"]').click()) - await page.locator('a.plugin-card[title="Basic Authentication"]').click() + await page.getByTestId('basic-auth-card').click() await page.waitForSelector('.entity-form') await expect(page.locator('#service-id')).not.toBeVisible() @@ -573,7 +575,7 @@ test.describe('plugins', () => { // create a scoped plugin await withNavigation(page, async () => await page.locator('.kong-ui-entities-plugins-list [data-testid="new-plugin"]').click()) - await page.locator('a.plugin-card[title="Basic Authentication"]').click() + await page.getByTestId('basic-auth-card').click() await page.waitForSelector('.entity-form') await page.click('.selection-group .Scoped-check') await page.click('#service-id') diff --git a/tests/playwright/specs/routes/02-RoutesPlugins.spec.ts b/tests/playwright/specs/routes/02-RoutesPlugins.spec.ts index 3e8e04a..509dbd8 100644 --- a/tests/playwright/specs/routes/02-RoutesPlugins.spec.ts +++ b/tests/playwright/specs/routes/02-RoutesPlugins.spec.ts @@ -63,7 +63,7 @@ test.describe('routes plugins', () => { await withNavigation( page, - async () => await page.click('a.plugin-card[title="Basic Authentication"]') + async () => await page.getByTestId('basic-auth-card').click() ) await expect(page.locator('.autosuggest #route-id')).toBeVisible()