diff --git a/src/routes/settings/costModels/components/addPriceList.test.tsx b/src/routes/settings/costModels/components/addPriceList.test.tsx
index db51486e6..79d93a41f 100644
--- a/src/routes/settings/costModels/components/addPriceList.test.tsx
+++ b/src/routes/settings/costModels/components/addPriceList.test.tsx
@@ -182,7 +182,7 @@ describe('add-a-new-rate', () => {
expect(screen.queryByText(regExp(messages.priceListNumberRate))).toBeNull();
// making sure button is enabled
- const createButton = screen.getByText(regExp(messages.createRate));
+ const createButton = screen.getByRole('button', { name: regExp(messages.createRate)} );
expect(createButton.getAttribute('aria-disabled')).toBe('false');
await user.click(createButton);
expect(submit).toHaveBeenCalled();
@@ -240,7 +240,7 @@ describe('add-a-new-rate', () => {
expect(screen.getByText(regExp(messages.priceListPosNumberRate))).not.toBeNull();
// setting a valid rate - now form is valid and can be submitted
- const createButton = screen.getByText(regExp(messages.createRate));
+ const createButton = screen.getByRole('button', { name: regExp(messages.createRate)} );
expect(createButton.getAttribute('aria-disabled')).toBe('true');
await user.clear(tagRateInput);
diff --git a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx
index 845509e79..43f87e8b3 100644
--- a/src/routes/settings/costModels/costModel/updateRateModel.test.tsx
+++ b/src/routes/settings/costModels/costModel/updateRateModel.test.tsx
@@ -271,7 +271,7 @@ describe('update-rate', () => {
render();
const descInput = screen.getByDisplayValue('openshift-aws-node');
- const saveButton = screen.getByText(regExp(messages.save));
+ const saveButton = screen.getByRole('button', { name: regExp(messages.save)} );
expect(saveButton.getAttribute('disabled')).not.toBeNull();
await user.clear(descInput);
@@ -289,7 +289,7 @@ describe('update-rate', () => {
render();
- const saveButton = screen.getByText(regExp(messages.save));
+ const saveButton = screen.getByRole('button', { name: regExp(messages.save)} );
await user.click(screen.getByLabelText('Select Measurement'));
options = await screen.findAllByRole('option');
@@ -327,7 +327,7 @@ describe('update-rate', () => {
test('regular', async () => {
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
render();
- const saveButton = screen.getByText(regExp(messages.save));
+ const saveButton = screen.getByRole('button', { name: regExp(messages.save)} );
await user.click(screen.getByLabelText(/infrastructure/i));
expect(saveButton.getAttribute('disabled')).toBeNull();
@@ -351,7 +351,7 @@ describe('update-rate', () => {
test('tag', async () => {
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
render();
- const saveButton = screen.getByText(regExp(messages.save));
+ const saveButton = screen.getByRole('button', { name: regExp(messages.save)} );
expect(saveButton.getAttribute('disabled')).not.toBeNull();
await user.type(screen.getByDisplayValue(/^container$/i), '1');
expect(saveButton.getAttribute('disabled')).toBeNull();
diff --git a/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx b/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx
index 15ce3eb02..b7a239e5b 100644
--- a/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx
+++ b/src/routes/settings/costModels/costModelsDetails/dialog.test.tsx
@@ -74,11 +74,11 @@ test('delete dialog open', async () => {
},
};
renderUI(state);
- expect(screen.queryAllByText(regExp(messages.costModelsDelete))).toHaveLength(2);
+ expect(screen.getAllByRole('button', { name: regExp(messages.costModelsDelete)})).toHaveLength(1);
expect(screen.queryAllByText(/This action will delete/i)).toHaveLength(1);
- expect(screen.queryAllByText(/The following sources are assigned to/i)).toHaveLength(0);
- await act(async () => user.click(screen.getAllByText(regExp(messages.costModelsDelete))[1]));
- expect(screen.getAllByText(regExp(messages.costModelsDelete))[1].getAttribute('disabled')).not.toBeNull();
+ expect(screen.queryAllByText(/The following integrations are assigned to/i)).toHaveLength(0);
+ await act(async () => user.click(screen.getAllByRole('button', { name: regExp(messages.costModelsDelete)})[0]));
+ expect(screen.getAllByRole('button', { name: regExp(messages.costModelsDelete)})[0].getAttribute('disabled')).not.toBeNull();
});
test('delete dialog error', async () => {