Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port embed test to playwright #4440

Merged
merged 20 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove old test, add roles and data-test-ids to various elements, cha…
…nge request handling inside EmbedInput
  • Loading branch information
thecalcc committed Feb 16, 2024
commit c74476384926813b93ab75740a1cc83c1a889fbc
14 changes: 9 additions & 5 deletions scripts/core/editor3/components/embeds/EmbedInput.tsx
Original file line number Diff line number Diff line change
@@ -117,8 +117,12 @@ export class EmbedInputComponent extends React.Component<any, any> {
}

getEmbedObject(value)
.then((data) => data.type === 'link' ? $.Deferred().reject() : data)
.then(this.processSuccess, this.processError);
.then((data) => {
this.processSuccess(data);
})
.catch((error) => {
this.processError(error);
});
}

/**
@@ -158,11 +162,11 @@ export class EmbedInputComponent extends React.Component<any, any> {
}}
placeholder={gettext('Enter URL or code to embed')}
/>
<div className="input-controls">
<a className="icn-btn" onClick={this.onSubmit}>
<div data-test-id="embed-controls" className="input-controls">
<a role="button" data-test-id="submit" className="icn-btn" onClick={this.onSubmit}>
<i className="icon-ok" />
</a>
<a className="icn-btn" onClick={this.onCancel}>
<a role="button" data-test-id="cancel" className="icn-btn" onClick={this.onCancel}>
<i className="icon-close-small" />
</a>
</div>
22 changes: 0 additions & 22 deletions scripts/core/editor3/components/tests/embeds.spec.tsx
Original file line number Diff line number Diff line change
@@ -97,26 +97,4 @@ describe('editor3.components.embed-input', () => {
expect(wrapper.state('error')).toBe('this is the error');
expect(wrapper.find('.embed-dialog__error').text()).toBe('this is the error');
}));

it('should call onSubmit and reset error on success', inject(($q, $rootScope) => {
const {options} = mockStore();
const onCancel = jasmine.createSpy();
const onSubmit = jasmine.createSpy();
const wrapper = mount(<EmbedInput embed={onSubmit} hidePopups={onCancel} />, options);

spyOn($, 'ajax').and.returnValue($q.resolve('resolve-value'));

wrapper.setState({error: 'some error'});

const instance: any = wrapper.find('input').instance();

instance.value = 'http://will.fail';
wrapper.simulate('submit');

$rootScope.$apply();

expect(onSubmit).toHaveBeenCalledWith('resolve-value');
expect(onCancel).toHaveBeenCalled();
expect(wrapper.state('error')).toBe('');
}));
});
3 changes: 2 additions & 1 deletion scripts/core/editor3/components/toolbar/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -20,10 +20,11 @@ interface IProps {
export const IconButton: React.FunctionComponent<IProps> = ({onClick, iconName, tooltip, uiTheme}) => (
<div
data-flow={'down'}
data-test-id={tooltip}
thecalcc marked this conversation as resolved.
Show resolved Hide resolved
data-sd-tooltip={tooltip}
className="Editor3-styleButton"
style={uiTheme == null ? undefined : {color: uiTheme.textColor}}
>
<span onClick={onClick}><i className={`icon-${iconName}`} /></span>
<span role="button" onClick={onClick}><i className={`icon-${iconName}`} /></span>
</div>
);
Loading