update selectors in tests to match id changes

This commit is contained in:
Keith J. Grant
2021-07-22 09:55:01 -07:00
parent e32471adbd
commit 55a9a4ca46
5 changed files with 13 additions and 12 deletions

View File

@@ -98,7 +98,7 @@ describe('<ApplicationAdd/>', () => {
wrapper.update(); wrapper.update();
expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#name').prop('value')).toBe('new foo');
expect(wrapper.find('input#description').prop('value')).toBe('new bar'); expect(wrapper.find('input#description').prop('value')).toBe('new bar');
expect(wrapper.find('input#organization-input').prop('value')).toBe( expect(wrapper.find('input#organization').prop('value')).toBe(
'organization' 'organization'
); );
expect( expect(
@@ -180,7 +180,7 @@ describe('<ApplicationAdd/>', () => {
}); });
}); });
waitForElement(wrapper, 'FormSubmitError', (el) => el.length > 0); waitForElement(wrapper, 'FormSubmitError', el => el.length > 0);
}); });
test('should render content error on failed read options request', async () => { test('should render content error on failed read options request', async () => {
ApplicationsAPI.readOptions.mockRejectedValue( ApplicationsAPI.readOptions.mockRejectedValue(

View File

@@ -88,6 +88,7 @@ describe('<ApplicationEdit/>', () => {
}); });
expect(wrapper.find('ApplicationEdit').length).toBe(1); expect(wrapper.find('ApplicationEdit').length).toBe(1);
}); });
test('should cancel form properly', async () => { test('should cancel form properly', async () => {
const history = createMemoryHistory({ const history = createMemoryHistory({
initialEntries: ['/applications/1/edit'], initialEntries: ['/applications/1/edit'],
@@ -110,6 +111,7 @@ describe('<ApplicationEdit/>', () => {
expect(history.location.pathname).toBe('/applications/1/details'); expect(history.location.pathname).toBe('/applications/1/details');
}); });
}); });
test('should throw error on submit', async () => { test('should throw error on submit', async () => {
const error = { const error = {
response: { response: {
@@ -147,6 +149,7 @@ describe('<ApplicationEdit/>', () => {
wrapper.update(); wrapper.update();
expect(wrapper.find('FormSubmitError').length).toBe(1); expect(wrapper.find('FormSubmitError').length).toBe(1);
}); });
test('expect values to be updated and submitted properly', async () => { test('expect values to be updated and submitted properly', async () => {
const history = createMemoryHistory({ const history = createMemoryHistory({
initialEntries: ['/applications/1/edit'], initialEntries: ['/applications/1/edit'],
@@ -188,7 +191,7 @@ describe('<ApplicationEdit/>', () => {
wrapper.update(); wrapper.update();
expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#name').prop('value')).toBe('new foo');
expect(wrapper.find('input#description').prop('value')).toBe('new bar'); expect(wrapper.find('input#description').prop('value')).toBe('new bar');
expect(wrapper.find('input#organization-input').prop('value')).toBe( expect(wrapper.find('input#organization').prop('value')).toBe(
'organization' 'organization'
); );
expect( expect(

View File

@@ -107,7 +107,7 @@ describe('<ApplicationForm', () => {
wrapper.update(); wrapper.update();
expect(wrapper.find('input#name').prop('value')).toBe('new foo'); expect(wrapper.find('input#name').prop('value')).toBe('new foo');
expect(wrapper.find('input#description').prop('value')).toBe('new bar'); expect(wrapper.find('input#description').prop('value')).toBe('new bar');
expect(wrapper.find('input#organization-input').prop('value')).toBe( expect(wrapper.find('input#organization').prop('value')).toBe(
'organization' 'organization'
); );
expect( expect(

View File

@@ -274,7 +274,7 @@ describe('<JobTemplateEdit />', () => {
data: { actions: { GET: {}, POST: {} } }, data: { actions: { GET: {}, POST: {} } },
}); });
useDebounce.mockImplementation((fn) => fn); useDebounce.mockImplementation(fn => fn);
}); });
afterEach(() => { afterEach(() => {
@@ -321,7 +321,7 @@ describe('<JobTemplateEdit />', () => {
{ id: 5, name: 'Maple' }, { id: 5, name: 'Maple' },
{ id: 6, name: 'Tree' }, { id: 6, name: 'Tree' },
]; ];
await waitForElement(wrapper, 'LabelSelect', (el) => el.length > 0); await waitForElement(wrapper, 'LabelSelect', el => el.length > 0);
act(() => { act(() => {
wrapper.find('LabelSelect').invoke('onChange')(labels); wrapper.find('LabelSelect').invoke('onChange')(labels);
wrapper.update(); wrapper.update();
@@ -339,9 +339,7 @@ describe('<JobTemplateEdit />', () => {
name: 'Other Inventory', name: 'Other Inventory',
}); });
wrapper.find('TextInput#execution-environments-input').invoke('onChange')( wrapper.find('TextInput#execution-environments').invoke('onChange')('');
''
);
}); });
wrapper.update(); wrapper.update();
@@ -384,7 +382,7 @@ describe('<JobTemplateEdit />', () => {
cancelButton = await waitForElement( cancelButton = await waitForElement(
wrapper, wrapper,
'button[aria-label="Cancel"]', 'button[aria-label="Cancel"]',
(e) => e.length === 1 e => e.length === 1
); );
}); });
await act(async () => { await act(async () => {

View File

@@ -58,7 +58,7 @@ describe('<WebhookSubForm />', () => {
}); });
test('should render initial values properly', () => { test('should render initial values properly', () => {
waitForElement(wrapper, 'Lookup__ChipHolder', (el) => el.lenth > 0); waitForElement(wrapper, 'Lookup__ChipHolder', el => el.lenth > 0);
expect(wrapper.find('AnsibleSelect').prop('value')).toBe('github'); expect(wrapper.find('AnsibleSelect').prop('value')).toBe('github');
expect( expect(
wrapper.find('TextInputBase[aria-label="Webhook URL"]').prop('value') wrapper.find('TextInputBase[aria-label="Webhook URL"]').prop('value')
@@ -68,7 +68,7 @@ describe('<WebhookSubForm />', () => {
.find('TextInputBase[aria-label="workflow job template webhook key"]') .find('TextInputBase[aria-label="workflow job template webhook key"]')
.prop('value') .prop('value')
).toBe('webhook key'); ).toBe('webhook key');
expect(wrapper.find('input#credential-input').prop('value')).toBe( expect(wrapper.find('input#credential').prop('value')).toBe(
'Github credential' 'Github credential'
); );
}); });