Skip to content

Commit 80c06bf

Browse files
TASK: Add a new e2e test for create tag validation
1 parent c3b045b commit 80c06bf

File tree

4 files changed

+76
-32
lines changed

4 files changed

+76
-32
lines changed

Resources/Private/JavaScript/media-module/tests/tags.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import page from './page-model';
2-
import { SERVER_NAME } from './helpers';
2+
import {ReactSelector} from 'testcafe-react-selectors';
3+
import {SERVER_NAME} from './helpers';
34

45
fixture('Tags').page(SERVER_NAME);
56

7+
const subSection = (name) => console.log('\x1b[33m%s\x1b[0m', ' - ' + name);
8+
69
test('Clicking first tag updates list and only assets should be shown that are assigned to it', async (t) => {
710
await t
811
// Uncollapse the tag list
@@ -19,3 +22,34 @@ test('Clicking first tag updates list and only assets should be shown that are a
1922
.expect(page.assetCount.innerText)
2023
.eql('12 assets');
2124
});
25+
26+
test('Create a new tag and test validation', async (t) => {
27+
subSection('Check existing tag label validation');
28+
await t
29+
.click(page.assetCollections.withText('All'))
30+
.click(page.collectionTree.findReact('AddTagButton'))
31+
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), 'Example tag 1')
32+
.expect(
33+
ReactSelector('CreateTagDialog')
34+
.findReact('TextInput')
35+
.withProps({ validationerrors: ['This input is invalid'] }).exists
36+
)
37+
.ok('Text input should have validation errors')
38+
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: true }).exists)
39+
.ok('Create button should be disabled')
40+
.expect(ReactSelector('CreateTagDialog').find('ul li').textContent)
41+
.eql('A tag with this label already exists')
42+
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), '00')
43+
.expect(ReactSelector('CreateTagDialog').find('ul li').exists)
44+
.notOk('The tooltip should not be visible anymore')
45+
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: false }).exists)
46+
.ok('Create button should be enabled');
47+
48+
subSection('Check emtpy tag label validation');
49+
await t
50+
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), ' ', { replace: true })
51+
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: true }).exists)
52+
.ok('Create button should be disabled')
53+
.expect(ReactSelector('CreateTagDialog').find('ul li').textContent)
54+
.eql('Please provide a tag label');
55+
});

0 commit comments

Comments
 (0)