Skip to content

Commit 4290181

Browse files
Update entityTemplates file to handle all test cases #18
1 parent 8e0c20b commit 4290181

File tree

1 file changed

+60
-238
lines changed

1 file changed

+60
-238
lines changed

tests/DCM/entityTemplates.spec.ts

Lines changed: 60 additions & 238 deletions
Original file line numberDiff line numberDiff line change
@@ -3,282 +3,104 @@ import type { Page } from '@playwright/test';
33

44
import { login, host } from '../shared';
55

6+
const { checkEntityTemplate, createEntityTemplate, editEntityTemplate, deleteEntityTemplate, deleteEditedEntityTemplate } = require('./utils/entityTemplateFunctions');
7+
8+
69
// Annotate entire file as serial.
710
test.describe.configure({ mode: 'serial' });
811

9-
test.describe('Entity Templates', () => {
12+
test.describe('Entity Template', () => {
1013
// Declare page outside of the test hooks so it's accessible by all tests.
1114
let page: Page;
1215

1316
test.beforeAll(async ({ browser }) => {
1417
page = await browser.newPage(); // Create new page
1518
await login(page); // Login
16-
await page.goto(`${host}/dcm/entitytemplates/`); // Go to Entity Templates page
19+
await page.goto(`${host}/dcm/entitytemplates`); // Go to entity template page
1720
});
1821

1922
test.afterAll(async () => {
2023
await page.close(); // Close the page after all tests
2124
});
2225

23-
test.describe('Create new Entity Template', () => {
24-
test('Fill in the essentials', async () => {
25-
// Open the form
26-
await page.locator('button[title=create]').click();
27-
// Fill in the name
28-
await page.locator('#name').fill('Test');
29-
// Choose the entity type
30-
await page.locator('#entityType').selectOption('1');
31-
// Fill in the description
32-
await page.locator('#description').fill('Test description');
33-
// Wait for the requests to finish
34-
await page.waitForLoadState('domcontentloaded');
35-
});
3626

37-
test('Fill in Metadata', async () => {
38-
// Choose the metadata structure
39-
await page.locator('#metadataStructure').selectOption('1');
40-
await page.locator('#metadataStructure').dispatchEvent('change');
41-
42-
// Choose required fields
43-
await page
44-
.locator('#metadataFields-container .svelte-select.multi')
45-
.click();
46-
await page
47-
.locator(
48-
'#metadataFields-container .list-item .item:has-text("Description")'
49-
)
50-
.click();
51-
await page
52-
.locator('#metadataFields-container .svelte-select.multi')
53-
.click();
54-
await page
55-
.locator(
56-
'#metadataFields-container .list-item .item:has-text("ProjectTitle")'
57-
)
58-
.click();
59-
});
6027

61-
test('Fill in Dataset Settings', async () => {
62-
// Choose dataset components to be disabled
63-
await page
64-
.locator('#disabledHooks-container .svelte-select.multi')
65-
.click();
66-
await page
67-
.locator(
68-
'#disabledHooks-container .list-item .item:has-text("File Upload")'
69-
)
70-
.click();
71-
await page
72-
.locator('#disabledHooks-container .svelte-select.multi')
73-
.click();
74-
await page
75-
.locator(
76-
'#disabledHooks-container .list-item .item:has-text("Data Description")'
77-
)
78-
.click();
79-
80-
// Choose allowed file types for file upload
81-
await page
82-
.locator('#allowedFileTypes-container .svelte-select.multi')
83-
.click();
84-
await page
85-
.locator(
86-
'#allowedFileTypes-container .list-item .item:has-text(".avi")'
87-
)
88-
.click();
89-
await page
90-
.locator('#allowedFileTypes-container .svelte-select.multi')
91-
.click();
92-
await page
93-
.locator(
94-
'#allowedFileTypes-container .list-item .item:has-text(".bmp")'
95-
)
96-
.click();
28+
test.describe('Iterations for fields validation', () => {
29+
const entityName = `test_iterate-${+Date.now()}`;
30+
31+
test('Check with entity name and entity type', async () => {
32+
await checkEntityTemplate(page, entityName, "Dataset", "", "", "", "", "")
9733
});
9834

99-
test('Save and verify the created entity template', async () => {
100-
// Click save
101-
await page.locator('button[title=save]').click();
102-
103-
// Verify entity's existence and contents
104-
const card = await page.locator('.card', {
105-
has: page.locator('header h2:has-text("Test")'),
106-
});
107-
await expect(
108-
card.locator('header .badge.variant-filled-surface')
109-
).toHaveText('Basic ABCD');
110-
await expect(
111-
card.locator('header .badge.variant-filled-secondary')
112-
).toHaveText('Dataset');
113-
await expect(card.locator('blockquote')).toHaveText('Test description');
114-
await expect(card.locator('i')).toHaveText(
115-
'Restricted to these file types: .avi, .bmp'
116-
);
35+
36+
37+
test('Check with entity name and Description', async () => {
38+
await checkEntityTemplate(page, entityName, "", "Test Description", "", "", "", "")
11739
});
118-
});
11940

120-
test.describe('Edit the Entity Template', () => {
121-
test('Edit the essentials', async () => {
122-
const card = await page.locator('.card', {
123-
has: page.locator('header h2:has-text("Test")'),
124-
});
41+
test('Check with entity name, entity type and Description', async () => {
42+
await checkEntityTemplate(page, entityName, "Dataset", "Test Description", "", "", "", "")
43+
});
12544

126-
// Click edit
127-
await card.locator('button[title=edit]').click();
45+
test.slow
46+
test('Check with entity name, entity type, description and Metadata', async () => {
47+
await checkEntityTemplate(page, entityName, "Dataset", "Test Description", "1", "", "", "")
48+
await deleteEntityTemplate(page, entityName)
49+
});
12850

129-
// Change the name
130-
await page.locator('#name').fill('Test Edited');
51+
test.slow
52+
test('Check with entity name, entity type, description,Metadata and required field', async () => {
53+
await checkEntityTemplate(page, entityName, "Dataset", "Test Description", "1", "Description", "", "")
54+
await deleteEntityTemplate(page, entityName)
55+
});
13156

132-
// Change the description
133-
await page.locator('#description').fill('Test description edited');
57+
test.slow
58+
test('Check with entity name, entity type, description, Metadata, required field and dataset ', async () => {
59+
await checkEntityTemplate(page, entityName, "Dataset", "Test Description", "1", "Description", "hasDataSet", "")
60+
await deleteEntityTemplate(page, entityName)
13461
});
13562

136-
test('Edit Metadata', async () => {
137-
// Choose the metadata structure
138-
await page.locator('#metadataStructure').selectOption('2');
139-
140-
// Clear the required fields
141-
await expect(
142-
page.locator('#metadataFields-container .multi-item .multi-item-clear')
143-
).toHaveCount(2);
144-
await page
145-
.locator('#metadataFields-container .multi-item .multi-item-clear')
146-
.first()
147-
.click();
148-
await page
149-
.locator('#metadataFields-container .multi-item .multi-item-clear')
150-
.click();
151-
152-
// Choose required fields
153-
await page
154-
.locator('#metadataFields-container .svelte-select.multi')
155-
.click();
156-
await page
157-
.locator(
158-
'#metadataFields-container .list-item .item:has-text("Author")'
159-
)
160-
.click();
161-
await page
162-
.locator('#metadataFields-container .svelte-select.multi')
163-
.click();
164-
await page
165-
.locator('#metadataFields-container .list-item .item:text-is("Title")')
166-
.click();
63+
test.slow
64+
test('Check with entity name, entity type, description, Metadata, required field and file type ', async () => {
65+
await checkEntityTemplate(page, entityName, "Dataset", "Test Description", "1", "Description", "", "hasFileType")
66+
await deleteEntityTemplate(page, entityName)
16767
});
16868

169-
test('Edit Dataset Settings', async () => {
170-
// Clear the dataset components to be disabled
171-
await expect(
172-
page.locator('#disabledHooks-container .multi-item .multi-item-clear')
173-
).toHaveCount(2);
174-
await page
175-
.locator('#disabledHooks-container .multi-item .multi-item-clear')
176-
.first()
177-
.click();
178-
await page
179-
.locator('#disabledHooks-container .multi-item .multi-item-clear')
180-
.click();
181-
182-
// Choose dataset components to be disabled
183-
await page
184-
.locator('#disabledHooks-container .svelte-select.multi')
185-
.click();
186-
await page
187-
.locator(
188-
'#disabledHooks-container .list-item .item:has-text("Metadata")'
189-
)
190-
.click();
191-
await page
192-
.locator('#disabledHooks-container .svelte-select.multi')
193-
.click();
194-
await page
195-
.locator(
196-
'#disabledHooks-container .list-item .item:has-text("Validation")'
197-
)
198-
.click();
199-
200-
// Clear the allowed file types for file upload
201-
await expect(
202-
page.locator(
203-
'#allowedFileTypes-container .multi-item .multi-item-clear'
204-
)
205-
).toHaveCount(2);
206-
await page
207-
.locator('#allowedFileTypes-container .multi-item .multi-item-clear')
208-
.first()
209-
.click();
210-
await page
211-
.locator('#allowedFileTypes-container .multi-item .multi-item-clear')
212-
.click();
213-
214-
// Choose allowed file types for file upload
215-
await page
216-
.locator('#allowedFileTypes-container .svelte-select.multi')
217-
.click();
218-
await page
219-
.locator(
220-
'#allowedFileTypes-container .list-item .item:has-text(".csv")'
221-
)
222-
.click();
223-
await page
224-
.locator('#allowedFileTypes-container .svelte-select.multi')
225-
.click();
226-
await page
227-
.locator(
228-
'#allowedFileTypes-container .list-item .item:has-text(".dbf")'
229-
)
230-
.click();
69+
70+
});
71+
72+
73+
74+
test.describe('Create new entity template', () => {
75+
const entityName = `test_new-${+Date.now()}`;
76+
77+
test('Create entity template', async () => {
78+
await createEntityTemplate(page, entityName);
23179
});
23280

233-
test('Save and verify the edited entity template', async () => {
234-
// Click save
235-
await page.locator('button[title=save]').click();
236-
237-
// Verify entity's existence and contents
238-
const card = await page.locator('.card', {
239-
has: page.locator('header h2:has-text("Test edited")'),
240-
});
241-
await expect(
242-
card.locator('header .badge.variant-filled-surface')
243-
).toHaveText('GBIF');
244-
await expect(
245-
card.locator('header .badge.variant-filled-secondary')
246-
).toHaveText('Dataset');
247-
await expect(card.locator('blockquote')).toHaveText(
248-
'Test description edited'
249-
);
250-
await expect(card.locator('i')).toHaveText(
251-
'Restricted to these file types: .csv, .dbf'
252-
);
81+
test('Delete new entity', async () => {
82+
await deleteEntityTemplate(page, entityName);
25383
});
84+
25485
});
25586

256-
test.describe('Delete the edited Entity Template', () => {
257-
test('Delete and verify', async () => {
258-
const card = await page.locator('.card', {
259-
has: page.locator('header h2:has-text("Test edited")'),
260-
});
87+
test.describe('Edit entity template', () => {
88+
const entityName = `test_edit-${+Date.now()}`;
26189

262-
// Click delete
263-
await card.locator('button[title=delete]').click();
90+
test('Create entity template', async () => {
91+
await createEntityTemplate(page, entityName);
92+
});
26493

265-
// Wait until the modal appears
266-
await page.waitForSelector('.modal');
26794

268-
// Check the modal title
269-
await expect(page.locator('.modal-header')).toHaveText('Please Confirm');
270-
await expect(page.locator('.modal-body')).toHaveText(
271-
'Are you sure you wish to remove?'
272-
);
27395

274-
// Click Confirm
275-
await page
276-
.locator('.modal-footer')
277-
.locator('button.variant-filled')
278-
.click();
96+
test('Edit entity template', async () => {
97+
await editEntityTemplate(page, entityName);
98+
});
27999

280-
// Verify the entity template is deleted
281-
await expect(card).not.toBeVisible();
100+
101+
test('Delete edited entity template', async () => {
102+
await deleteEditedEntityTemplate(page);
282103
});
283104
});
284105
});
106+

0 commit comments

Comments
 (0)