Skip to content

Commit

Permalink
TASK: Add a new e2e test for create tag validation
Browse files Browse the repository at this point in the history
  • Loading branch information
markusguenther committed Nov 2, 2024
1 parent c3b045b commit d259929
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 31 deletions.
34 changes: 34 additions & 0 deletions Resources/Private/JavaScript/media-module/tests/tags.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import page from './page-model';
import { ReactSelector } from 'testcafe-react-selectors';
import { SERVER_NAME } from './helpers';

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

const subSection = (name) => console.log('\x1b[33m%s\x1b[0m', ' - ' + name);

test('Clicking first tag updates list and only assets should be shown that are assigned to it', async (t) => {
await t
// Uncollapse the tag list
Expand All @@ -19,3 +22,34 @@ test('Clicking first tag updates list and only assets should be shown that are a
.expect(page.assetCount.innerText)
.eql('12 assets');
});

test('Create a new tag and test validation', async (t) => {
subSection('Check existing tag label validation');
await t
.click(page.assetCollections.withText('All'))
.click(page.collectionTree.findReact('AddTagButton'))
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), 'Example tag 1')
.expect(
ReactSelector('CreateTagDialog')
.findReact('TextInput')
.withProps({ validationerrors: ['This input is invalid'] }).exists
)
.ok('Text input should have validation errors')
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: true }).exists)
.ok('Create button should be disabled')
.expect(ReactSelector('CreateTagDialog').find('ul li').textContent)
.eql('A tag with this label already exists')
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), '00')
.expect(ReactSelector('CreateTagDialog').find('ul li').exists)
.notOk('The tooltip should not be visible anymore')
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: false }).exists)
.ok('Create button should be enabled');

subSection('Check emtpy tag label validation');
await t
.typeText(ReactSelector('CreateTagDialog').findReact('TextInput'), ' ', { replace: true })
.expect(ReactSelector('CreateTagDialog').findReact('Button').withProps({ disabled: true }).exists)
.ok('Create button should be disabled')
.expect(ReactSelector('CreateTagDialog').find('ul li').textContent)
.eql('Please provide a tag label');
});
Loading

0 comments on commit d259929

Please sign in to comment.