2023-10-26 18:39:04 +05:30
|
|
|
import { licensesSuccessWorkspaceLockedResponse } from 'mocks-server/__mockdata__/licenses';
|
|
|
|
|
import { server } from 'mocks-server/server';
|
|
|
|
|
import { rest } from 'msw';
|
2023-10-20 17:48:27 +05:30
|
|
|
import { act, render, screen } from 'tests/test-utils';
|
|
|
|
|
|
|
|
|
|
import WorkspaceLocked from '.';
|
|
|
|
|
|
|
|
|
|
describe('WorkspaceLocked', () => {
|
2023-10-26 18:39:04 +05:30
|
|
|
const apiURL = 'http://localhost/api/v2/licenses';
|
|
|
|
|
|
2023-10-20 17:48:27 +05:30
|
|
|
test('Should render the component', async () => {
|
2023-10-26 18:39:04 +05:30
|
|
|
server.use(
|
|
|
|
|
rest.get(apiURL, (req, res, ctx) =>
|
|
|
|
|
res(ctx.status(200), ctx.json(licensesSuccessWorkspaceLockedResponse)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-20 17:48:27 +05:30
|
|
|
act(() => {
|
|
|
|
|
render(<WorkspaceLocked />);
|
|
|
|
|
});
|
2023-10-26 18:39:04 +05:30
|
|
|
|
|
|
|
|
const workspaceLocked = await screen.findByRole('heading', {
|
2024-09-06 14:26:13 +01:00
|
|
|
name: /upgrade to continue/i,
|
2023-10-20 17:48:27 +05:30
|
|
|
});
|
|
|
|
|
expect(workspaceLocked).toBeInTheDocument();
|
|
|
|
|
|
2024-09-06 14:26:13 +01:00
|
|
|
const contactUsBtn = await screen.findByRole('button', {
|
|
|
|
|
name: /Contact Us/i,
|
2023-10-20 17:48:27 +05:30
|
|
|
});
|
2024-09-06 14:26:13 +01:00
|
|
|
expect(contactUsBtn).toBeInTheDocument();
|
2023-10-20 17:48:27 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Render for Admin', async () => {
|
2023-10-26 18:39:04 +05:30
|
|
|
server.use(
|
|
|
|
|
rest.get(apiURL, (req, res, ctx) =>
|
|
|
|
|
res(ctx.status(200), ctx.json(licensesSuccessWorkspaceLockedResponse)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-20 17:48:27 +05:30
|
|
|
render(<WorkspaceLocked />);
|
2023-10-26 18:39:04 +05:30
|
|
|
const contactAdminMessage = await screen.queryByText(
|
2024-09-06 14:26:13 +01:00
|
|
|
/contact your admin to proceed with the upgrade./i,
|
2023-10-20 17:48:27 +05:30
|
|
|
);
|
|
|
|
|
expect(contactAdminMessage).not.toBeInTheDocument();
|
2023-10-26 18:39:04 +05:30
|
|
|
const updateCreditCardBtn = await screen.findByRole('button', {
|
2024-09-06 14:26:13 +01:00
|
|
|
name: /continue my journey/i,
|
2023-10-20 17:48:27 +05:30
|
|
|
});
|
|
|
|
|
expect(updateCreditCardBtn).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Render for non Admin', async () => {
|
2023-10-26 18:39:04 +05:30
|
|
|
server.use(
|
|
|
|
|
rest.get(apiURL, (req, res, ctx) =>
|
|
|
|
|
res(ctx.status(200), ctx.json(licensesSuccessWorkspaceLockedResponse)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-20 17:48:27 +05:30
|
|
|
render(<WorkspaceLocked />, {}, 'VIEWER');
|
2023-10-26 18:39:04 +05:30
|
|
|
const updateCreditCardBtn = await screen.queryByRole('button', {
|
2024-09-06 14:26:13 +01:00
|
|
|
name: /Continue My Journey/i,
|
2023-10-20 17:48:27 +05:30
|
|
|
});
|
|
|
|
|
expect(updateCreditCardBtn).not.toBeInTheDocument();
|
|
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
const contactAdminMessage = await screen.findByText(
|
2024-09-06 14:26:13 +01:00
|
|
|
/contact your admin to proceed with the upgrade./i,
|
2023-10-20 17:48:27 +05:30
|
|
|
);
|
|
|
|
|
expect(contactAdminMessage).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|