forked from redhat-developer/rhdh-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcm-catalog-items.test.ts
More file actions
259 lines (214 loc) · 8.47 KB
/
Copy pathdcm-catalog-items.test.ts
File metadata and controls
259 lines (214 loc) · 8.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
* Copyright Red Hat, Inc.
*
* Licensed 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 { test, expect } from '@playwright/test';
import { DcmPage } from './pages/DcmPage';
import { suffix } from './utils/helpers';
import { TIMEOUTS } from './utils/constants';
import * as path from 'node:path';
test.describe('DCM Catalog Items & Instances @dcm', () => {
let dcm: DcmPage;
test.beforeEach(async ({ page }) => {
dcm = new DcmPage(page);
await dcm.loginAsGuest();
await dcm.navigateToDataCenter();
});
// ── Catalog Items ─────────────────────────────────────────────────────
test('FLPATH-4200: Catalog items tab shows Pet Clinic with correct columns', async () => {
await dcm.clickTab('Catalog items');
await dcm.verifyTableVisible();
await dcm.verifyColumnHeader('Display name');
await dcm.verifyColumnHeader('API version');
await dcm.verifyColumnHeader('Service type');
await dcm.verifyColumnHeader('Fields');
await dcm.verifyColumnHeader('Created');
await dcm.verifyCellContent('Pet Clinic');
await dcm.verifyCellContent('three-tier-app-demo');
});
test('FLPATH-4200: Pet Clinic has Edit and Delete actions', async () => {
await dcm.clickTab('Catalog items');
await dcm.verifyTableVisible();
const row = dcm.page.locator('table tbody tr', { hasText: 'Pet Clinic' });
await expect(row.getByRole('button', { name: 'Edit' })).toBeVisible();
await expect(row.getByRole('button', { name: 'Delete' })).toBeVisible();
});
test('FLPATH-4200: Create and delete a catalog item via drawer', async ({
page,
}) => {
const name = `E2E Item ${suffix()}`;
await dcm.clickTab('Catalog items');
await dcm.clickCreateCatalogItem();
await dcm.fillCatalogItemForm({
displayName: name,
apiVersion: 'v1alpha1',
serviceType: 'container',
});
const pathField = page.locator('label:has-text("Path *") + div input');
if ((await pathField.count()) > 0) {
await pathField.first().click();
await pathField.first().fill('config.replicas');
} else {
const altPath = page.getByLabel('Path *');
await altPath.click();
await altPath.fill('config.replicas');
}
await dcm.submitDialog('Create');
await dcm.waitForTableRefresh();
await dcm.verifyCellContent(name);
await dcm.clickDeleteOnRow(name);
await dcm.confirmDelete();
await dcm.waitForDialogClosed();
await dcm.waitForTableRefresh();
await dcm.verifyNoCellContent(name);
});
test('FLPATH-4200: Edit a catalog item', async () => {
await dcm.clickTab('Catalog items');
await dcm.clickEditOnRow('Pet Clinic');
await expect(
dcm.page.getByRole('heading', { name: 'Edit catalog item' }),
).toBeVisible({ timeout: TIMEOUTS.short });
await dcm.cancelDialog();
});
// ── Instances ─────────────────────────────────────────────────────────
test('FLPATH-4200: Instances tab shows correct columns or empty state', async ({
page,
}) => {
await dcm.clickTab('Instances');
const hasTable = await page
.locator('table')
.first()
.isVisible()
.catch(() => false);
if (hasTable) {
await dcm.verifyColumnHeader('Display name');
await dcm.verifyColumnHeader('Catalog item');
await dcm.verifyColumnHeader('Resource ID');
await dcm.verifyColumnHeader('API version');
await dcm.verifyColumnHeader('Created');
}
await expect(
page.getByRole('button', { name: 'Create', exact: true }),
).toBeVisible();
});
test('FLPATH-4200: Create instance dialog opens and form is fillable', async ({
page,
}) => {
await dcm.clickTab('Instances');
await dcm.clickCreateInstance();
await dcm.fillInstanceForm({
displayName: `E2E Instance ${suffix()}`,
catalogItem: 'Pet Clinic',
apiVersion: 'v1alpha1',
});
await expect(page.getByText('Field values')).toBeVisible({
timeout: TIMEOUTS.short,
});
await dcm.submitDialog('Create');
await page.waitForTimeout(TIMEOUTS.networkSettle);
const dialogVisible = await page
.locator('[role="dialog"]')
.isVisible()
.catch(() => false);
if (dialogVisible) {
await expect(page.locator('[role="alert"]').first()).toBeVisible({
timeout: TIMEOUTS.short,
});
await dcm.cancelDialog();
} else {
await dcm.waitForTableRefresh();
const hasInstance = await page
.getByRole('cell', { name: /E2E Instance/ })
.first()
.isVisible()
.catch(() => false);
if (hasInstance) {
const row = page.locator('table tbody tr', {
hasText: /E2E Instance/,
});
await row.getByRole('button', { name: 'Delete instance' }).click();
await dcm.confirmDelete();
await dcm.waitForDialogClosed();
}
}
});
// ── File Import ──────────────────────────────────────────────────────
test('FLPATH-4274: Valid YAML file import populates catalog item form', async ({
page,
}) => {
const fixturePath = path.resolve(
__dirname,
'fixtures/dcm/valid-catalog-item.yaml',
);
await dcm.clickTab('Catalog items');
await dcm.clickCreateCatalogItem();
await dcm.importCatalogItemFile(fixturePath);
const displayName = page.locator(
'label:has-text("Display name *") + div input',
);
await expect(displayName.first()).toHaveValue('E2E Import Test Item');
const apiVersion = page.locator(
'label:has-text("API version *") + div input',
);
await expect(apiVersion.first()).toHaveValue('v1alpha1');
const pathFields = page.locator('label:has-text("Path *") + div input');
await expect(pathFields).toHaveCount(2, { timeout: TIMEOUTS.short });
await expect(pathFields.nth(0)).toHaveValue('config.replicas');
await expect(pathFields.nth(1)).toHaveValue('config.region');
await dcm.submitDialog('Create');
await dcm.waitForTableRefresh();
await dcm.verifyCellContent('E2E Import Test Item');
await dcm.clickDeleteOnRow('E2E Import Test Item');
await dcm.confirmDelete();
await dcm.waitForDialogClosed();
await dcm.waitForTableRefresh();
});
test.skip('FLPATH-4274: Invalid YAML file import should show error feedback — blocked on FLPATH-4274 fix', async ({
page,
}) => {
const fixturePath = path.resolve(
__dirname,
'fixtures/dcm/invalid-catalog-item.yaml',
);
await dcm.clickTab('Catalog items');
await dcm.clickCreateCatalogItem();
const displayNameBefore = await page
.locator('label:has-text("Display name *") + div input')
.first()
.inputValue();
await dcm.importCatalogItemFile(fixturePath);
const displayNameAfter = await page
.locator('label:has-text("Display name *") + div input')
.first()
.inputValue();
expect(displayNameAfter).toBe(displayNameBefore);
// FLPATH-4274: Error feedback MUST be shown for invalid files.
// This will fail until the fix ships, then pass automatically.
const errorFeedback = page
.locator('[class*="MuiAlert"]')
.first()
.or(page.locator('[class*="MuiSnackbar"]').first());
await expect(errorFeedback).toBeVisible({ timeout: TIMEOUTS.short });
await dcm.cancelDialog();
});
// ── Resources ─────────────────────────────────────────────────────────
test('FLPATH-4200: Resources tab shows content or empty state', async ({
page,
}) => {
await dcm.clickTab('Resources');
await expect(
page.locator('table').first().or(page.getByText('No resources found')),
).toBeVisible({ timeout: TIMEOUTS.table });
});
});