Skip to content

Commit

Permalink
test: align tests to dimmed disabled version
Browse files Browse the repository at this point in the history
  • Loading branch information
soleksy-splunk committed Dec 3, 2024
1 parent 621584d commit bed3bb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
21 changes: 14 additions & 7 deletions ui/src/components/EntityModal/EntityModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
});

it('Oauth Oauth - disableonEdit = true, oauth field disabled on edit', async () => {
Expand All @@ -82,7 +83,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {

const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Enable field equal false, so field disabled', async () => {
Expand All @@ -102,7 +104,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {

const oauthTextBox = getDisabledBasicField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('if oauth field not disabled with create after disableonEdit true', async () => {
Expand All @@ -120,7 +123,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledBasicField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
});
});

Expand Down Expand Up @@ -163,7 +167,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Enable field equal false, so field disabled', async () => {
Expand All @@ -181,7 +186,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Fully enabled field, enabled: true, disableonEdit: false', async () => {
Expand All @@ -199,7 +205,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
});
});

Expand Down
12 changes: 8 additions & 4 deletions ui/src/components/FormModifications/FormModifications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,22 @@ it('verify modification after text components change', async () => {
expect(parentElement).toHaveTextContent(mods.label);
};

expect(componentInput).toBeDisabled();
expect(componentInput).toHaveAttribute('readonly');
expect(componentInput.getAttribute('aria-disabled')).toBe('true');
verifyAllProps(componentParentElement, componentInput, mods1Field1);

expect(component2Input).toBeDisabled();
expect(component2Input).toHaveAttribute('readonly');
expect(component2Input.getAttribute('aria-disabled')).toBe('true');
verifyAllProps(component2ParentElement, component2Input, mods1Field2);

await userEvent.type(componentMakingModsTextBox1, secondValueToInput);

expect(componentInput).toBeEnabled();
expect(componentInput).not.toHaveAttribute('readonly');
expect(componentInput.getAttribute('aria-disabled')).toBe('false');
verifyAllProps(componentParentElement, componentInput, mods2Field1);

expect(component2Input).toBeEnabled();
expect(component2Input).not.toHaveAttribute('readonly');
expect(component2Input.getAttribute('aria-disabled')).toBe('false');
verifyAllProps(component2ParentElement, component2Input, mods2Field2);
});

Expand Down

0 comments on commit bed3bb7

Please sign in to comment.