Skip to content

Commit

Permalink
add test and make pr comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
asinn134 committed Nov 12, 2024
1 parent c5e8bdd commit fcb8338
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json

from tests.factories import MineFactory, ProjectFactory, ProjectSummaryFactory, PartyFactory
from flask_restx import marshal
from app.api.projects.response_models import PROJECT_SUMMARY_MODEL
from tests.factories import MineFactory, ProjectFactory
from app.api.projects.project.models.project import Project
from datetime import datetime


def test_get_project_by_project_guid(test_client, db_session, auth_headers):
Expand All @@ -28,3 +27,24 @@ def test_get_projects_by_mine_guid(test_client, db_session, auth_headers):

assert get_resp.status_code == 200
assert len(get_data['records']) == batch_size

def test_get_filtered_projects(test_client, db_session, auth_headers):
batch_size = 3
mine = MineFactory(minimal=True, project=0)
ProjectFactory.create_batch(mine=mine, size=batch_size)
mine_guid = mine.mine_guid
specific_mine_name = mine.mine_name
projects = Project.find_by_mine_guid(str(mine_guid))

get_resp = test_client.get(
f'/projects/dashboard?page=1&per_page=10&sort_field=update_timestamp&sort_dir=desc&search={specific_mine_name}',
headers=auth_headers['full_auth_header'])
get_data = json.loads(get_resp.data.decode())

assert get_resp.status_code == 200
assert len(get_data['records']) == batch_size
assert all(project.mine_guid == mine_guid for project in projects)
for i in range(len(get_data['records']) - 1):
assert datetime.strptime(get_data['records'][i]['update_timestamp'], '%Y-%m-%d') >= datetime.strptime(
get_data['records'][i + 1]['update_timestamp'], '%Y-%m-%d')

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { FC } from "react";
import { UpOutlined, DownOutlined } from "@ant-design/icons";
import { Field, reduxForm } from "redux-form";
import { Form } from "@ant-design/compatible";
import "@ant-design/compatible/assets/index.css";
import { Button, Col, Row } from "antd";
import { Button, Col, Row, Form } from "antd";

import * as FORM from "@/constants/forms";
import { renderConfig } from "@/components/common/config";
Expand All @@ -29,7 +27,7 @@ export const MajorProjectsSearchForm: FC<MajorProjectsSearchFormProps> = ({
};

return (
<Form layout="vertical" onSubmit={handleSubmit} onReset={handleSearchFormReset}>
<Form layout="vertical" onReset={handleSearchFormReset}>
<Row gutter={6}>
<Col md={24} xs={24}>
<Field
Expand Down Expand Up @@ -72,7 +70,7 @@ export const MajorProjectsSearchForm: FC<MajorProjectsSearchFormProps> = ({
<Button className="full-mobile" type="secondary" htmlType="reset">
Clear Filters
</Button>
<Button className="full-mobile" type="primary" htmlType="submit">
<Button className="full-mobile" type="primary" htmlType="submit" onClick={handleSubmit}>
Apply Filters
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const MajorProjectSearch: FC<MajorProjectSearchProps> = ({
<Col md={{ span: 12, offset: 6 }} xs={{ span: 20, offset: 2 }}>
<span className="advanced-search__container">
<MajorProjectSearchForm
// @ts-ignore
handleReset={handleReset}
onSubmit={handleSearch}
toggleAdvancedSearch={toggleIsAdvancedSearch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
MAJOR_MINE_APPLICATION_AND_IRT_STATUS_CODES,
PROJECT_DECISION_PACKAGE_STATUS_CODES
} from "@mds/common/constants/enums";
import { formatDate, dateSorter } from "@common/utils/helpers";
import { formatDate, dateSorter } from "@mds/common/redux/utils/helpers";
import CoreTable from "@mds/common/components/common/CoreTable";
import * as router from "@/constants/routes";
import {
Expand All @@ -18,7 +18,7 @@ import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFla
import { Feature } from "@mds/common";
import { IProject } from "@mds/common/interfaces";

interface MajorProjectsSearchFormProps {
interface MajorProjectTableProps {
projects: IProject[];
mineCommodityOptionsHash: any;
handleSearch: (params: any) => void;
Expand Down Expand Up @@ -92,7 +92,7 @@ const handleTableChange = (handleSearch, tableFilters) => (pagination, filters,
handleSearch(params);
};

export const MajorProjectTable: FC<MajorProjectsSearchFormProps> = ({
export const MajorProjectTable: FC<MajorProjectTableProps> = ({
projects,
mineCommodityOptionsHash,
handleSearch,
Expand Down Expand Up @@ -147,8 +147,7 @@ export const MajorProjectTable: FC<MajorProjectsSearchFormProps> = ({
key: "project",
dataIndex: "project",
render: (text, record) => (
// @ts-ignore
<div title="" align="right" data-cy="major-projects-table-open-button">
<div title="" data-cy="major-projects-table-open-button">
<Row gutter={1}>
<Col span={12}>
<Link to={router.EDIT_PROJECT.dynamicRoute(record.key)}>
Expand All @@ -169,8 +168,7 @@ export const MajorProjectTable: FC<MajorProjectsSearchFormProps> = ({
{
title: "",
key: "project_section",
dataIndex: "project_section",
render: (text, record) => {
render: (record) => {
return (
// @ts-ignore
<div title="" align="right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
}

expanded-row-button {
.expanded-row-button {
color: $primary-btn-color;
background-color: $pure-white;
border-color: $primary-btn-color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render } from "@testing-library/react";
import { MajorProjectHomePage } from "@/components/dashboard/majorProjectHomePage/MajorProjectHomePage";
import * as MOCK from "@/tests/mocks/dataMocks";
import * as MOCK from "@mds/common/tests/mocks/dataMocks";
import { ReduxWrapper } from "@/tests/utils/ReduxWrapper";

const dispatchProps = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import MajorProjectSearch from "@/components/dashboard/majorProjectHomePage/MajorProjectSearch";
import * as MOCK from "@/tests/mocks/dataMocks";
import * as MOCK from "@mds/common/tests/mocks/dataMocks";
import { render } from "@testing-library/react";
import { ReduxWrapper } from "@/tests/utils/ReduxWrapper";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import MajorProjectTable from "@/components/dashboard/majorProjectHomePage/MajorProjectTable";
import * as MOCK from "@/tests/mocks/dataMocks";
import * as MOCK from "@mds/common/tests/mocks/dataMocks";
import { render } from "@testing-library/react";
import { ReduxWrapper } from "@/tests/utils/ReduxWrapper";
import { BrowserRouter } from "react-router-dom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports[`MajorProjectHomePage renders properly 1`] = `
class="advanced-search__container"
>
<form
class="ant-legacy-form ant-legacy-form-vertical"
class="ant-form ant-form-vertical"
>
<div
class="ant-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`Major Project Search Component renders properly 1`] = `
class="advanced-search__container"
>
<form
class="ant-legacy-form ant-legacy-form-vertical"
class="ant-form ant-form-vertical"
>
<div
class="ant-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ exports[`MajorProjectTable renders properly 1`] = `
class="ant-table-cell"
>
<div
align="right"
data-cy="major-projects-table-open-button"
title=""
>
Expand Down

0 comments on commit fcb8338

Please sign in to comment.