Skip to content

Commit bb5dddb

Browse files
authored
test(e2e): Add E2E tests for consumer and credentials (#3243)
* feat(e2e): add E2E tests for Consumers resource - Add Page Object Model for Consumers (e2e/pom/consumers.ts) - Add list and pagination tests (consumers.list.spec.ts) - Add CRUD tests with required fields (consumers.crud-required-fields.spec.ts) - Add CRUD tests with all fields (consumers.crud-all-fields.spec.ts) - Add deleteAllConsumers() helper function in src/apis/consumers.ts All tests follow the established pattern: - *.list.spec.ts for list page and pagination - *.crud-required-fields.spec.ts for basic CRUD operations - *.crud-all-fields.spec.ts for comprehensive CRUD with all fields Tests cover: - Navigation and page assertions - Form validation - Create, Read, Update, Delete operations - Labels management with tags input - Pagination with table controls and URL params Fixes username validation by using only allowed characters [a-zA-Z0-9_-] * feat: add e2e tests for consumer credentials - Add credentialsPom for page object model - Add comprehensive test suite for credentials CRUD operations - Test credential isolation between consumers - Test empty state handling - Configure serial mode to avoid race conditions All 8 tests passing
1 parent af28b8d commit bb5dddb

File tree

7 files changed

+913
-1
lines changed

7 files changed

+913
-1
lines changed

e2e/pom/consumers.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import { uiGoto } from '@e2e/utils/ui';
18+
import { expect, type Page } from '@playwright/test';
19+
20+
const locator = {
21+
getConsumerNavBtn: (page: Page) =>
22+
page.getByRole('link', { name: 'Consumers', exact: true }),
23+
getAddConsumerBtn: (page: Page) =>
24+
page.getByRole('button', { name: 'Add Consumer', exact: true }),
25+
getAddBtn: (page: Page) =>
26+
page.getByRole('button', { name: 'Add', exact: true }),
27+
};
28+
29+
const assert = {
30+
isIndexPage: async (page: Page) => {
31+
await expect(page).toHaveURL((url) => url.pathname.endsWith('/consumers'));
32+
const title = page.getByRole('heading', { name: 'Consumers' });
33+
await expect(title).toBeVisible();
34+
},
35+
isAddPage: async (page: Page) => {
36+
await expect(page).toHaveURL((url) => url.pathname.endsWith('/consumers/add'));
37+
const title = page.getByRole('heading', { name: 'Add Consumer' });
38+
await expect(title).toBeVisible();
39+
},
40+
isDetailPage: async (page: Page) => {
41+
await expect(page).toHaveURL((url) =>
42+
url.pathname.includes('/consumers/detail')
43+
);
44+
const title = page.getByRole('heading', { name: 'Consumer Detail' });
45+
await expect(title).toBeVisible();
46+
},
47+
};
48+
49+
const goto = {
50+
toIndex: (page: Page) => uiGoto(page, '/consumers'),
51+
toAdd: (page: Page) => uiGoto(page, '/consumers/add'),
52+
};
53+
54+
export const consumersPom = {
55+
...locator,
56+
...assert,
57+
...goto,
58+
};

e2e/pom/credentials.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import { uiGoto } from '@e2e/utils/ui';
18+
import { expect, type Page } from '@playwright/test';
19+
20+
const locator = {
21+
getCredentialsTab: (page: Page) =>
22+
page.getByRole('tab', { name: 'Credentials' }),
23+
getAddCredentialBtn: (page: Page) =>
24+
page.getByRole('button', { name: 'Add Credential', exact: true }),
25+
getAddBtn: (page: Page) =>
26+
page.getByRole('button', { name: 'Add', exact: true }),
27+
};
28+
29+
const assert = {
30+
isCredentialsIndexPage: async (page: Page, username: string) => {
31+
await expect(page).toHaveURL((url) =>
32+
url.pathname.includes(`/consumers/detail/${username}/credentials`)
33+
);
34+
const title = page.getByRole('heading', { name: 'Credentials' });
35+
await expect(title).toBeVisible();
36+
},
37+
isCredentialAddPage: async (page: Page, username: string) => {
38+
await expect(page).toHaveURL((url) =>
39+
url.pathname.endsWith(`/consumers/detail/${username}/credentials/add`)
40+
);
41+
const title = page.getByRole('heading', { name: 'Add Credential' });
42+
await expect(title).toBeVisible();
43+
},
44+
isCredentialDetailPage: async (page: Page) => {
45+
await expect(page).toHaveURL((url) =>
46+
url.pathname.includes('/consumers/detail/') &&
47+
url.pathname.includes('/credentials/detail/')
48+
);
49+
const title = page.getByRole('heading', { name: 'Credential Detail' });
50+
await expect(title).toBeVisible();
51+
},
52+
};
53+
54+
const goto = {
55+
toCredentialsIndex: (page: Page, username: string) =>
56+
uiGoto(page, '/consumers/detail/$username/credentials', { username }),
57+
toCredentialAdd: (page: Page, username: string) =>
58+
uiGoto(page, '/consumers/detail/$username/credentials/add', { username }),
59+
toCredentialDetail: (page: Page, username: string, id: string) =>
60+
uiGoto(page, '/consumers/detail/$username/credentials/detail/$id', {
61+
username,
62+
id,
63+
}),
64+
};
65+
66+
export const credentialsPom = {
67+
...locator,
68+
...assert,
69+
...goto,
70+
};

0 commit comments

Comments
 (0)