Skip to content

Commit 98e8012

Browse files
committed
test(e2e): configure tests to run in serial mode and enhance service deletion logic
1 parent fc7ebd9 commit 98e8012

8 files changed

+21
-0
lines changed

e2e/tests/services.crud-all-fields.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { expect } from '@playwright/test';
2727

2828
import { deleteAllServices } from '@/apis/services';
2929

30+
test.describe.configure({ mode: 'serial' });
31+
3032
test.beforeAll(async () => {
3133
await deleteAllServices(e2eReq);
3234
});

e2e/tests/services.crud-required-fields.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { expect } from '@playwright/test';
2727

2828
import { deleteAllServices } from '@/apis/services';
2929

30+
test.describe.configure({ mode: 'serial' });
31+
3032
const serviceName = randomId('test-service');
3133

3234
test.beforeAll(async () => {

e2e/tests/services.list.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { deleteAllServices } from '@/apis/services';
2525
import { API_SERVICES } from '@/config/constant';
2626
import type { APISIXType } from '@/types/schema/apisix';
2727

28+
test.describe.configure({ mode: 'serial' });
29+
2830
test('should navigate to services page', async ({ page }) => {
2931
await test.step('navigate to services page', async () => {
3032
await servicesPom.getServiceNavBtn(page).click();

e2e/tests/services.routes.crud.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { deleteAllRoutes } from '@/apis/routes';
2626
import { deleteAllServices, postServiceReq } from '@/apis/services';
2727
import type { APISIXType } from '@/types/schema/apisix';
2828

29+
test.describe.configure({ mode: 'serial' });
30+
2931
const serviceName = randomId('test-service');
3032
const routeName = randomId('test-route');
3133
const routeUri = '/test-route';

e2e/tests/services.routes.list.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { deleteAllRoutes, postRouteReq } from '@/apis/routes';
2525
import { deleteAllServices, postServiceReq } from '@/apis/services';
2626
import type { APISIXType } from '@/types/schema/apisix';
2727

28+
test.describe.configure({ mode: 'serial' });
29+
2830
const serviceName = randomId('test-service');
2931
const anotherServiceName = randomId('another-service');
3032
const routes: APISIXType['Route'][] = [

e2e/tests/services.stream_routes.crud.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { expect } from '@playwright/test';
2424
import { deleteAllServices, postServiceReq } from '@/apis/services';
2525
import { deleteAllStreamRoutes } from '@/apis/stream_routes';
2626

27+
test.describe.configure({ mode: 'serial' });
28+
2729
const serviceName = randomId('test-service');
2830
const streamRouteServerAddr = '127.0.0.1';
2931
const streamRouteServerPort = 8080;

e2e/tests/services.stream_routes.list.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
postStreamRouteReq,
2828
} from '@/apis/stream_routes';
2929

30+
test.describe.configure({ mode: 'serial' });
31+
3032
const serviceName = randomId('test-service');
3133
const anotherServiceName = randomId('another-service');
3234
const streamRoutes = [

src/apis/services.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import { API_SERVICES, PAGE_SIZE_MAX, PAGE_SIZE_MIN } from '@/config/constant';
2020
import type { APISIXType } from '@/types/schema/apisix';
2121
import type { PageSearchType } from '@/types/schema/pageSearch';
2222

23+
import { deleteAllRoutes } from './routes';
24+
import { deleteAllStreamRoutes } from './stream_routes';
25+
2326
export type ServicePostType = APISIXType['ServicePost'];
2427

2528
export const getServiceListReq = (req: AxiosInstance, params: PageSearchType) =>
@@ -52,6 +55,10 @@ export const postServiceReq = (req: AxiosInstance, data: ServicePostType) =>
5255
);
5356

5457
export const deleteAllServices = async (req: AxiosInstance) => {
58+
// Delete all routes and stream routes first to avoid foreign key constraints
59+
await deleteAllRoutes(req);
60+
await deleteAllStreamRoutes(req);
61+
5562
const totalRes = await getServiceListReq(req, {
5663
page: 1,
5764
page_size: PAGE_SIZE_MIN,

0 commit comments

Comments
 (0)