Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -42,12 +42,12 @@ jobs:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 16.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install dependencies
Expand All @@ -60,12 +60,12 @@ jobs:
working-directory: hackathon_site/dashboard/frontend

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 16.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install dependencies
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -42,12 +42,12 @@ jobs:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 16.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install dependencies
Expand All @@ -62,12 +62,12 @@ jobs:
working-directory: hackathon_site/dashboard/frontend

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 16.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions hackathon_site/dashboard/frontend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export const teamOrderListSerialization = (
const hardwareItems: Record<number, OrderItemTableRow> = {};
const hardwareRequested: Record<number, number> = {};
const returnedItems: Record<string, ReturnedItem> = {};
order.request.forEach(
(order.request ?? []).forEach(
(hardware) =>
(hardwareRequested[hardware.id] = hardware.requested_quantity)
);
order.items.forEach(({ id, hardware_id, part_returned_health }) => {
(order.items ?? []).forEach(({ id, hardware_id, part_returned_health }) => {
if (part_returned_health && part_returned_health !== "Rejected") {
const returnItemKey = `${hardware_id}-${part_returned_health}`;
if (returnedItems[returnItemKey])
Expand Down Expand Up @@ -92,7 +92,7 @@ export const teamOrderListSerialization = (
const hardwareInTableRow = Object.values(hardwareItems);

// Check if ALL order items have a part_returned_health status (i.e., they are all returned or rejected)
const allItemsReturnedOrRejected = order.items.every(
const allItemsReturnedOrRejected = (order.items ?? []).every(
(item) => item.part_returned_health !== null
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ export const mockHardwareSignOutDates = (

describe("Render cartQuantity", () => {
it(`Renders correctly when it reads the number ${cartQuantity}`, async () => {
const { getByText } = render(
const { getByTestId } = render(
<Provider store={store}>
<CartSummary />
</Provider>
);
await waitFor(() => {
expect(getByText(cartQuantity.toString())).toBeInTheDocument();
expect(getByTestId("cart-quantity-total")).toHaveTextContent(
cartQuantity.toString()
);
});
});
// TODO: fix failing test case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("<PendingTables />", () => {
});
const { getByText, queryByText } = render(<PendingTables />, { store });
expect(getByText(/pending orders/i)).toBeInTheDocument();
expect(queryByText("In progress")).toBeInTheDocument();
expect(queryByText("Submitted")).toBeInTheDocument();
mockPendingOrdersInTable.map(({ id }) => {
expect(getByText(`Order #${id}`)).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export const PendingTables = () => {

const submitCancelOrderModal = async (cancelOrderId: number | null) => {
if (cancelOrderId != null) {
// Close the modal immediately (matching the "Go Back" dismiss path) so it
// never gets stuck open if the order refresh below is slow or fails.
setShowCancelOrderModal(false);

// Refresh orders first to get latest status
await dispatch(getTeamOrders());

Expand All @@ -266,7 +270,6 @@ export const PendingTables = () => {
})
);
}
setShowCancelOrderModal(false);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("<ChipStatus />", () => {

test("Pending status", () => {
const { getByText } = render(<ChipStatus status="Submitted" />);
expect(getByText("In progress")).toBeInTheDocument();
expect(getByText("Submitted")).toBeInTheDocument();
});

test("Error status", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("<ProductOverview />", () => {
// Check if the main section, detailInfoSection, and add to cart section works
expect(getByText("Category")).toBeInTheDocument();
expect(getByText("Datasheet")).toBeInTheDocument();
expect(getByText("Add to cart")).toBeInTheDocument();
expect(getByText(/Add to cart/)).toBeInTheDocument();
});

test("Category label doesn't appear when there are no categories", async () => {
Expand Down Expand Up @@ -170,7 +170,7 @@ describe("<ProductOverview />", () => {
// Check if the main section, detailInfoSection, and add to cart section works
expect(getByText("Category")).toBeInTheDocument();
expect(getByText("Datasheet")).toBeInTheDocument();
expect(getByText("Add to cart")).toBeInTheDocument();
expect(getByText(/Add to cart/)).toBeInTheDocument();
expect(queryByText("Notes")).not.toBeInTheDocument();
});

Expand Down Expand Up @@ -273,14 +273,18 @@ describe("<ProductOverview />", () => {
);

// by default, quantity is 1
const button = getByText("Add to cart");
const button = getByText(/Add to cart/);

await waitFor(() => {
fireEvent.click(button);
});

expect(cartSelectors.selectAll(store.getState())).toEqual([
{ hardware_id: mockHardware[0].id, quantity: 1 },
{
hardware_id: mockHardware[0].id,
quantity: 1,
credits: mockHardware[0].credits,
},
]);
expect(
getByText(`Added 1 ${mockHardware[0].name} item(s) to your cart.`)
Expand Down Expand Up @@ -320,7 +324,7 @@ describe("<ProductOverview />", () => {
);

// by default, quantity is 1
const button = getByText("Add to cart");
const button = getByText(/Add to cart/);

await waitFor(() => {
fireEvent.click(button);
Expand Down Expand Up @@ -402,13 +406,14 @@ describe("<EnhancedAddToCartForm />", () => {
const { getByText, getByLabelText } = render(
<EnhancedAddToCartForm
quantityRemaining={0}
credits={5}
maxPerTeam={null}
hardwareId={1}
name="Arduino"
/>
);

const button = getByText("Add to cart").closest("button");
const button = getByText(/Add to cart/).closest("button");
const select = getByLabelText("Qty");

expect(button).toBeDisabled();
Expand All @@ -419,13 +424,14 @@ describe("<EnhancedAddToCartForm />", () => {
const { getByText, getByLabelText } = render(
<EnhancedAddToCartForm
quantityRemaining={3}
credits={5}
maxPerTeam={0}
hardwareId={1}
name="Arduino"
/>
);

const button = getByText("Add to cart").closest("button");
const button = getByText(/Add to cart/).closest("button");
const select = getByLabelText("Qty");

expect(button).toBeDisabled();
Expand All @@ -436,6 +442,7 @@ describe("<EnhancedAddToCartForm />", () => {
const { queryByText, getByText, getByRole } = render(
<EnhancedAddToCartForm
quantityRemaining={3}
credits={5}
maxPerTeam={2}
hardwareId={1}
name="Arduino"
Expand All @@ -452,6 +459,7 @@ describe("<EnhancedAddToCartForm />", () => {
const { getByText, getByRole } = render(
<EnhancedAddToCartForm
quantityRemaining={3}
credits={5}
maxPerTeam={null}
hardwareId={1}
name="Arduino"
Expand All @@ -468,13 +476,14 @@ describe("<EnhancedAddToCartForm />", () => {
const { getByText } = render(
<EnhancedAddToCartForm
quantityRemaining={3}
credits={5}
maxPerTeam={5}
hardwareId={1}
name="Arduino"
/>
);

const button = getByText("Add to cart").closest("button");
const button = getByText(/Add to cart/).closest("button");
expect(button).toBeDisabled();
});
});
Expand Down
Loading
Loading