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', {
|
2023-10-20 17:48:27 +05:30
|
|
|
name: /workspace locked/i,
|
|
|
|
|
});
|
|
|
|
|
expect(workspaceLocked).toBeInTheDocument();
|
|
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
const gotQuestionText = await screen.findByText(/got question?/i);
|
2023-10-20 17:48:27 +05:30
|
|
|
expect(gotQuestionText).toBeInTheDocument();
|
|
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
const contactUsLink = await screen.findByRole('link', {
|
2023-10-20 17:48:27 +05:30
|
|
|
name: /contact us/i,
|
|
|
|
|
});
|
|
|
|
|
expect(contactUsLink).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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(
|
2023-10-20 17:48:27 +05:30
|
|
|
/please contact your administrator for further help/i,
|
|
|
|
|
);
|
|
|
|
|
expect(contactAdminMessage).not.toBeInTheDocument();
|
2023-10-26 18:39:04 +05:30
|
|
|
const updateCreditCardBtn = await screen.findByRole('button', {
|
2023-10-20 17:48:27 +05:30
|
|
|
name: /update credit card/i,
|
|
|
|
|
});
|
|
|
|
|
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', {
|
2023-10-20 17:48:27 +05:30
|
|
|
name: /update credit card/i,
|
|
|
|
|
});
|
|
|
|
|
expect(updateCreditCardBtn).not.toBeInTheDocument();
|
|
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
const contactAdminMessage = await screen.findByText(
|
2023-10-20 17:48:27 +05:30
|
|
|
/please contact your administrator for further help/i,
|
|
|
|
|
);
|
|
|
|
|
expect(contactAdminMessage).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|