Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figma: People Page Violates The Figma Style Guide #3367

Closed
Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
997e7cb
gg
abhassen44 Dec 30, 2024
c873b7f
hh
abhassen44 Dec 30, 2024
4ba5d8a
Merge branch 'develop-postgres' of https://github.com/PalisadoesFound…
abhassen44 Dec 30, 2024
59dfb45
Merge branch 'develop-postgres' into feat/css
abhassen44 Dec 30, 2024
c28c3d8
refreshed
abhassen44 Dec 30, 2024
a377c16
gg
abhassen44 Jan 14, 2025
e0f3c6c
test
abhassen44 Jan 14, 2025
3a4eb6b
resolving-conflict
abhassen44 Jan 14, 2025
7959fbb
resolving-conflict
abhassen44 Jan 14, 2025
c597c38
resolving-design
abhassen44 Jan 14, 2025
73d0d71
resolving-design
abhassen44 Jan 14, 2025
5ad1953
css
abhassen44 Jan 14, 2025
762b6a4
css
abhassen44 Jan 14, 2025
ba82b69
css
abhassen44 Jan 14, 2025
d7ad796
css
abhassen44 Jan 14, 2025
e5c8b87
css
abhassen44 Jan 14, 2025
ef42c3a
css
abhassen44 Jan 14, 2025
2e2828b
code-rabit-reconfigaring
abhassen44 Jan 14, 2025
0a7f31e
code-rabit-reconfigaring
abhassen44 Jan 14, 2025
929ea91
code-rabit-reconfigaring
abhassen44 Jan 16, 2025
d437249
test
abhassen44 Jan 16, 2025
39a0658
test
abhassen44 Jan 16, 2025
a3cf918
test
abhassen44 Jan 16, 2025
5ce3410
test
abhassen44 Jan 16, 2025
ef2fa18
test
abhassen44 Jan 16, 2025
542195b
test
abhassen44 Jan 16, 2025
19f9288
setting
abhassen44 Jan 18, 2025
6295d17
about
abhassen44 Jan 19, 2025
a077c6c
about
abhassen44 Jan 19, 2025
bb7b6d5
Merge branch 'feat/css' into develop-postgres
abhassen44 Jan 19, 2025
285f738
refactor
abhassen44 Jan 19, 2025
fd6d9de
refactor
abhassen44 Jan 19, 2025
8ac942d
ref
abhassen44 Jan 20, 2025
ec2f700
Merge branch 'develop-postgres' of https://github.com/PalisadoesFound…
abhassen44 Jan 20, 2025
af3b3e6
ref2
abhassen44 Jan 20, 2025
0db1b07
Update src/assets/css/app.css
abhassen44 Jan 20, 2025
1375c83
Update src/style/app.module.css
abhassen44 Jan 20, 2025
17f0922
Update src/screens/OrganizationPeople/AddMember.tsx
abhassen44 Jan 20, 2025
5f24959
Update pre-commit
abhassen44 Jan 20, 2025
3168cfd
ref3
abhassen44 Jan 20, 2025
b6b5be7
Update pre-commit
abhassen44 Jan 20, 2025
0cc5fc6
ref4
abhassen44 Jan 21, 2025
4fbf767
Merge branch 'ref/css2' of https://github.com/abhassen44/talawa-admin…
abhassen44 Jan 21, 2025
eabfd4c
ref4
abhassen44 Jan 21, 2025
c5acd11
Update pre-commit
abhassen44 Jan 21, 2025
02b76b0
Merge branch 'develop-postgres' into ref/css2
abhassen44 Jan 21, 2025
2c5a9e4
ref4
abhassen44 Jan 21, 2025
6487d16
ref4
abhassen44 Jan 21, 2025
fd2d713
Update pre-commit
abhassen44 Jan 21, 2025
0da1df0
ref4
abhassen44 Jan 21, 2025
160abc6
Merge branch 'ref/css2' of https://github.com/abhassen44/talawa-admin…
abhassen44 Jan 21, 2025
76560e6
ref4
abhassen44 Jan 21, 2025
7d4f064
Update pre-commit
abhassen44 Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@
"confirmPassword": "confirmPassword",
"create": "create",
"cancel": "cancel",
"user": "user",
"profile": "profile"
"user": "User",
"profile": "Profile"
},
"organizationTags": {
"title": "Organization Tags",
Expand Down
71 changes: 36 additions & 35 deletions src/assets/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 67 additions & 69 deletions src/components/CheckIn/TableRow.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,13 @@ import { MockedProvider } from '@apollo/react-testing';
import { checkInMutationSuccess, checkInMutationUnsuccess } from './mocks';
import { vi } from 'vitest';

/**
* Test suite for the `TableRow` component, focusing on the CheckIn table functionality.
*/

describe('Testing Table Row for CheckIn Table', () => {
describe('Testing TableRow component', () => {
beforeEach(() => {
vi.clearAllMocks();
});

test('If the user is not checked in, button to check in should be displayed, and the user should be able to check in successfully', async () => {
const props = {
data: {
id: `123`,
name: `John Doe`,
userId: `user123`,
checkIn: null,
eventId: `event123`,
},
refetch: vi.fn(),
};

const { findByText } = render(
const renderWithProviders = (props: any) =>
render(
<BrowserRouter>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MockedProvider addTypename={false} mocks={checkInMutationSuccess}>
Expand All @@ -49,14 +34,26 @@ describe('Testing Table Row for CheckIn Table', () => {
</BrowserRouter>,
);

expect(await findByText('Check In')).toBeInTheDocument();
test('If user is not checked in, "Check In" button should be displayed and work correctly', async () => {
const props = {
data: {
id: '123',
name: 'John Doe',
userId: 'user123',
checkIn: null,
eventId: 'event123',
},
refetch: vi.fn(),
};

fireEvent.click(await findByText('Check In'));
const { findByText } = renderWithProviders(props);

expect(await findByText('Check In')).toBeInTheDocument();
fireEvent.click(await findByText('Check In'));
expect(await findByText('Checked in successfully')).toBeInTheDocument();
});

test('If the user is checked in, the option to download tag should be shown', async () => {
test('If user is already checked in, "Download Tag" button should be available', async () => {
const props = {
data: {
id: '123',
Expand All @@ -71,44 +68,30 @@ describe('Testing Table Row for CheckIn Table', () => {
refetch: vi.fn(),
};

const { findByText } = render(
<BrowserRouter>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MockedProvider addTypename={false} mocks={checkInMutationSuccess}>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<ToastContainer />
<TableRow {...props} />
</I18nextProvider>
</Provider>
</MockedProvider>
</LocalizationProvider>
</BrowserRouter>,
);

// Mock global functions
global.URL.createObjectURL = vi.fn(() => 'mockURL');
global.window.open = vi.fn();

const { findByText } = renderWithProviders(props);

expect(await findByText('Checked In')).toBeInTheDocument();
expect(await findByText('Download Tag')).toBeInTheDocument();

fireEvent.click(await findByText('Download Tag'));

expect(await findByText('Generating pdf...')).toBeInTheDocument();
expect(global.URL.createObjectURL).toHaveBeenCalled();
expect(global.window.open).toHaveBeenCalledWith('mockURL');
expect(await findByText('PDF generated successfully!')).toBeInTheDocument();

// Cleanup mocks
vi.clearAllMocks();
});

test('Upon failing of check in mutation, the appropriate error message should be shown', async () => {
test('Upon check-in mutation failure, an error message should be displayed', async () => {
const props = {
data: {
id: `123`,
name: `John Doe`,
userId: `user123`,
id: '123',
name: 'John Doe',
userId: 'user123',
checkIn: null,
eventId: `event123`,
eventId: 'event123',
},
refetch: vi.fn(),
};
Expand All @@ -128,52 +111,67 @@ describe('Testing Table Row for CheckIn Table', () => {
</BrowserRouter>,
);

expect(await findByText('Check In')).toBeInTheDocument();

fireEvent.click(await findByText('Check In'));

expect(await findByText('Error checking in')).toBeInTheDocument();
expect(await findByText('Oops')).toBeInTheDocument();
});

test('If PDF generation fails, the error message should be shown', async () => {
test('If PDF generation fails, an error message should be displayed', async () => {
const props = {
data: {
id: `123`,
id: '123',
name: '',
userId: `user123`,
userId: 'user123',
checkIn: {
_id: '123',
time: '12:00:00',
},
eventId: `event123`,
eventId: 'event123',
},
refetch: vi.fn(),
};

const { findByText } = render(
<BrowserRouter>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<MockedProvider addTypename={false} mocks={checkInMutationSuccess}>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<ToastContainer />
<TableRow {...props} />
</I18nextProvider>
</Provider>
</MockedProvider>
</LocalizationProvider>
</BrowserRouter>,
);

// Mocking the PDF generation function to throw an error
global.URL.createObjectURL = vi.fn(() => 'mockURL');
// Mock global functions
global.URL.createObjectURL = vi.fn(() => {
throw new Error('Blob creation failed');
});
global.window.open = vi.fn();

const { findByText } = renderWithProviders(props);

fireEvent.click(await findByText('Download Tag'));

expect(
await findByText('Error generating pdf: Invalid or empty name provided'),
await findByText('Error generating pdf: Blob creation failed'),
).toBeInTheDocument();
});

test('Generated PDF should be downloadable with correct content', async () => {
const props = {
data: {
id: '123',
name: 'John Doe',
userId: 'user123',
checkIn: {
_id: '123',
time: '12:00:00',
},
eventId: 'event123',
},
refetch: vi.fn(),
};

// Mock Blob creation and window functions
const mockBlob = new Blob(['mock content'], { type: 'application/pdf' });
global.URL.createObjectURL = vi.fn(() => 'mockURL');
global.window.open = vi.fn();

const { findByText } = renderWithProviders(props);

fireEvent.click(await findByText('Download Tag'));

expect(global.URL.createObjectURL).toHaveBeenCalledWith(mockBlob);
expect(global.window.open).toHaveBeenCalledWith('mockURL');
});
});
10 changes: 5 additions & 5 deletions src/components/CheckIn/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ export const TableRow = ({
}
inputs.push({ name: data.name.trim() });
const pdf = await generate({ template: tagTemplate, inputs });
// istanbul ignore next
const blob = new Blob([pdf.buffer], { type: 'application/pdf' });
// istanbul ignore next

const blob = new Blob([pdf], { type: 'application/pdf' });

const url = URL.createObjectURL(blob);
// istanbul ignore next

window.open(url);
// istanbul ignore next

toast.success('PDF generated successfully!');
} catch (error: unknown) {
const errorMessage =
Expand Down
Loading
Loading