mirror of
https://github.com/apache/apisix-dashboard.git
synced 2025-12-08 20:12:51 +00:00
* feat(services/routes): filter by `service_id` * feat(services): filter stream_routes by service_id * fix: type * test: routes in services * test: stream_routes in services * Revert "test: stream_routes in services" This reverts commit 77d7803250e0365f85dc0599f9d3fbaf8a1b10f5. * test: stream_routes in services * chore: rm stream_routes pom * feat: add only show routes with service_id case * test: add not show other service route case * feat: add services stream_routes pom * test: stream_routes in services * fix: use exact match * chore: rollback useless change
143 lines
5.3 KiB
TypeScript
143 lines
5.3 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
import { uiGoto } from '@e2e/utils/ui';
|
|
import { expect, type Page } from '@playwright/test';
|
|
|
|
const locator = {
|
|
getServiceNavBtn: (page: Page) =>
|
|
page.getByRole('link', { name: 'Services', exact: true }),
|
|
getAddServiceBtn: (page: Page) =>
|
|
page.getByRole('button', { name: 'Add Service', exact: true }),
|
|
getAddBtn: (page: Page) =>
|
|
page.getByRole('button', { name: 'Add', exact: true }),
|
|
// Service routes locators
|
|
getServiceRoutesTab: (page: Page) =>
|
|
page.getByRole('tab', { name: 'Routes', exact: true }),
|
|
getAddRouteBtn: (page: Page) =>
|
|
page.getByRole('button', { name: 'Add Route', exact: true }),
|
|
// Service stream routes locators
|
|
getServiceStreamRoutesTab: (page: Page) =>
|
|
page.getByRole('tab', { name: 'Stream Routes', exact: true }),
|
|
getAddStreamRouteBtn: (page: Page) =>
|
|
page.getByRole('button', { name: 'Add Stream Route', exact: true }),
|
|
};
|
|
|
|
const assert = {
|
|
isIndexPage: async (page: Page) => {
|
|
await expect(page).toHaveURL((url) => url.pathname.endsWith('/services'));
|
|
const title = page.getByRole('heading', { name: 'Services' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isAddPage: async (page: Page) => {
|
|
await expect(page).toHaveURL((url) =>
|
|
url.pathname.endsWith('/services/add')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Add Service' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isDetailPage: async (page: Page) => {
|
|
await expect(page).toHaveURL((url) =>
|
|
url.pathname.includes('/services/detail')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Service Detail' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
// Service routes assertions
|
|
isServiceRoutesPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/routes')
|
|
);
|
|
// Wait for page to load completely
|
|
await page.waitForLoadState('networkidle');
|
|
const title = page.getByRole('heading', { name: 'Routes' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isServiceRouteAddPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/routes/add')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Add Route' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isServiceRouteDetailPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/routes/detail')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Route Detail' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
// Service stream routes assertions
|
|
isServiceStreamRoutesPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/stream_routes')
|
|
);
|
|
// Wait for page to load completely
|
|
await page.waitForLoadState('networkidle');
|
|
const title = page.getByRole('heading', { name: 'Stream Routes' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isServiceStreamRouteAddPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/stream_routes/add')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Add Stream Route' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
isServiceStreamRouteDetailPage: async (page: Page) => {
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname.includes('/services/detail') &&
|
|
url.pathname.includes('/stream_routes/detail')
|
|
);
|
|
const title = page.getByRole('heading', { name: 'Stream Route Detail' });
|
|
await expect(title).toBeVisible();
|
|
},
|
|
};
|
|
|
|
const goto = {
|
|
toIndex: (page: Page) => uiGoto(page, '/services'),
|
|
toAdd: (page: Page) => uiGoto(page, '/services/add'),
|
|
toServiceRoutes: (page: Page, serviceId: string) =>
|
|
uiGoto(page, '/services/detail/$id/routes', { id: serviceId }),
|
|
toServiceRouteAdd: (page: Page, serviceId: string) =>
|
|
uiGoto(page, '/services/detail/$id/routes/add', {
|
|
id: serviceId,
|
|
}),
|
|
toServiceStreamRoutes: (page: Page, serviceId: string) =>
|
|
uiGoto(page, '/services/detail/$id/stream_routes', { id: serviceId }),
|
|
toServiceStreamRouteAdd: (page: Page, serviceId: string) =>
|
|
uiGoto(page, '/services/detail/$id/stream_routes/add', {
|
|
id: serviceId,
|
|
}),
|
|
};
|
|
|
|
export const servicesPom = {
|
|
...locator,
|
|
...assert,
|
|
...goto,
|
|
};
|