Skip to content

Commit 2e1957b

Browse files
Pollepsjoepio
authored andcommitted
#780 Update ontology tests for the new behaviour
1 parent 0f224a6 commit 2e1957b

File tree

3 files changed

+66
-11
lines changed

3 files changed

+66
-11
lines changed

browser/data-browser/src/views/OntologyPage/Property/PropertyFormCommon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export function PropertyFormCommon({
8989
);
9090

9191
const disableExtras = !datatypesWithExtraControls.has(datatype ?? '');
92-
const showEnumForm = !classType && datatype === urls.datatypes.resourceArray;
92+
const showEnumForm =
93+
!classType && datatypesWithExtraControls.has(datatype ?? '');
9394

9495
return (
9596
<Column>

browser/data-browser/src/views/OntologyPage/PropertyDatatypePicker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export function PropertyDatatypePicker({
2121
});
2222

2323
const removeAllowsOnlyForNonResourceArray = (type: string) => {
24-
if (type === urls.datatypes.resourceArray) {
24+
if (
25+
type === urls.datatypes.resourceArray ||
26+
type === urls.datatypes.atomicUrl
27+
) {
2528
return;
2629
}
2730

browser/e2e/tests/ontology.spec.ts

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ test.describe('Ontology', async () => {
144144

145145
// arrow-kind class
146146

147+
const arrowKindCard = classCard('arrow-kind');
147148
await expect(
148-
classCard('arrow-kind').locator('input[value="arrow-kind"]'),
149+
arrowKindCard.locator('input[value="arrow-kind"]'),
149150
).toBeVisible();
150151

151-
await classCard('arrow-kind').getByTitle('add required property').click();
152+
// add name property to arrow-kind
153+
await arrowKindCard.getByTitle('add required property').click();
152154

153155
await page.getByPlaceholder('Search for a property').type('name');
154156

@@ -158,13 +160,59 @@ test.describe('Ontology', async () => {
158160

159161
await pickOption(page.getByText('name - The name'));
160162

163+
// add line-type property to arrow-kind
164+
await arrowKindCard.getByTitle('add recommended property').click();
165+
await page.getByPlaceholder('Search for a property').type('line-type');
166+
167+
await expect(page.getByText('Create line-type')).toBeVisible();
168+
169+
await pickOption(page.getByText('Create line-type'));
170+
171+
await page.getByTitle('Configure line-type').click();
172+
173+
await expect(
174+
currentDialog(page).locator('input[value="line-type"]'),
175+
).toBeVisible();
176+
177+
await expect(
178+
currentDialog(page).getByRole('button', { name: 'Enum' }),
179+
).not.toBeVisible();
180+
181+
await currentDialog(page)
182+
.getByLabel('Datatype')
183+
.selectOption('https://atomicdata.dev/datatypes/resourceArray');
184+
185+
await expect(
186+
currentDialog(page).getByRole('tab', { name: 'Enum' }),
187+
).toBeVisible();
188+
189+
// Create two tags: dashed and solid
190+
await currentDialog(page).getByPlaceholder('New tag').fill('dashed');
191+
await currentDialog(page).getByRole('button', { name: 'Add tag' }).click();
192+
193+
await expect(currentDialog(page).getByPlaceholder('New tag')).toHaveValue(
194+
'',
195+
);
196+
197+
await expect(currentDialog(page).getByText('dashed')).toBeVisible();
198+
199+
await currentDialog(page).getByPlaceholder('New tag').fill('solid');
200+
await currentDialog(page).getByRole('button', { name: 'Add tag' }).click();
201+
202+
await expect(currentDialog(page).getByPlaceholder('New tag')).toHaveValue(
203+
'',
204+
);
205+
206+
await expect(currentDialog(page).getByText('solid')).toBeVisible();
207+
208+
await currentDialog(page).getByRole('button', { name: 'close' }).click();
161209
// Create arrow-kind instances
162210

163211
await page.waitForTimeout(REBUILD_INDEX_TIME);
164212

165213
const createInstance = async (name: string) => {
166214
await page.getByRole('button', { name: 'New Instance' }).click();
167-
await page.getByText('Search for a class').click();
215+
await page.getByText('Search for a class').nth(1).click();
168216
await page.getByPlaceholder('Search for a class').type('arrow-kind');
169217

170218
await expect(page.getByText('arrow-kind - Change me')).toBeVisible();
@@ -189,24 +237,27 @@ test.describe('Ontology', async () => {
189237
.getByRole('button', { name: 'add an item to the allows-only list' })
190238
.nth(1)
191239
.click();
192-
await page.getByRole('button', { name: 'Search for a resource' }).click();
240+
await page.getByRole('button', { name: 'Search for a arrow-kind' }).click();
193241
await page
194-
.getByPlaceholder('Search for a resource or ')
242+
.getByPlaceholder('Search for a arrow-kind ')
195243
.type('red arrow with circle');
196244
await pickOption(
197-
page.getByRole('dialog').getByText('Red arrow with circle'),
245+
page.getByRole('dialog').getByText('Red arrow with circle').nth(1),
198246
);
199247

200248
await page
201249
.getByRole('button', { name: 'add an item to the allows-only list' })
202250
.nth(1)
203251
.click();
204-
await page.getByRole('button', { name: 'Search for a resource' }).click();
252+
await page.getByRole('button', { name: 'Search for a arrow-kind' }).click();
205253
await page
206-
.getByPlaceholder('Search for a resource or ')
254+
.getByPlaceholder('Search for a arrow-kind ')
207255
.type('green arrow with black border');
208256
await pickOption(
209-
page.getByRole('dialog').getByText('Green arrow with black border'),
257+
page
258+
.getByRole('dialog')
259+
.getByText('Green arrow with black border')
260+
.nth(1),
210261
);
211262

212263
expect(await page.getByText('Red arrow with circle').count()).toBe(3);

0 commit comments

Comments
 (0)