Skip to content

Commit

Permalink
Merge pull request #227 from zimmerman-team/feat/DX-1708
Browse files Browse the repository at this point in the history
feat: fill incomplete table with empty cells
  • Loading branch information
Psami-wondah authored Sep 12, 2024
2 parents 36ce2e6 + 564f781 commit 3a80e59
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
9 changes: 9 additions & 0 deletions cypress/e2e/1-dx/2-datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ describe("Testing connecting data on DX", () => {
cy.restoreLocalStorageCache();
// cy.setGoogleAccessToken();

cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();
cy.intercept(`${apiUrl}/external-sources/search?q=*`).as("getDefaultData");
cy.get('[data-cy="home-connect-dataset-button"]').click();
cy.wait("@planData");
});

it("Can filter results by source in the federated search", () => {
Expand Down Expand Up @@ -212,7 +217,11 @@ describe("Edit, Delete and Duplicate Dataset", () => {

beforeEach(() => {
cy.restoreLocalStorageCache();
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");
cy.get('[data-cy="cookie-btn"]').click();

cy.intercept("GET", `${apiUrl}/datasets?filter=*`).as("fetchDatasets");
Expand Down
12 changes: 12 additions & 0 deletions cypress/e2e/1-dx/3-charts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ describe("Testing create chart on DX", () => {

beforeEach(() => {
cy.restoreLocalStorageCache();
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();

cy.intercept("GET", `${apiUrl}/datasets?**`).as("getDatasets");
Expand Down Expand Up @@ -186,8 +190,12 @@ describe("Testing Ai chart creation", () => {

beforeEach(() => {
cy.restoreLocalStorageCache();
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();
cy.intercept("GET", `${apiUrl}/datasets?**`).as("getDatasets");
cy.get('[data-cy="home-create-chart-button"]').click();
Expand Down Expand Up @@ -271,8 +279,12 @@ describe("Edit, duplicate and delete chart", () => {
const apiUrl = Cypress.env("api_url");
beforeEach(() => {
cy.restoreLocalStorageCache();
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();

cy.intercept("GET", `${apiUrl}/charts*`).as("fetchCharts");
Expand Down
8 changes: 8 additions & 0 deletions cypress/e2e/1-dx/4-reports.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ describe("Testing reports on DX", () => {
cy.restoreLocalStorageCache();

// Navigating to dx home page
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();
});

Expand Down Expand Up @@ -176,8 +180,12 @@ describe("Edit, duplicate and delete report", () => {

beforeEach(() => {
cy.restoreLocalStorageCache();
cy.intercept("GET", `${apiUrl}/users/plan-data`).as("planData");

cy.visit("/");

cy.wait("@planData");

cy.get('[data-cy="cookie-btn"]').click();

cy.intercept(`${apiUrl}/reports?filter=*`).as("fetchReports");
Expand Down
36 changes: 26 additions & 10 deletions src/app/components/Table/Preview-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,24 @@ interface PreviewTableProps {
observerTarget: React.MutableRefObject<null>;
loading: boolean;
}

type IdatasStats = {
name: string;
type: "bar" | "percentage" | "unique";
data: { name: string; value: number }[];
};
export default function PreviewTable(props: PreviewTableProps) {
const [toolboxDisplay, setToolboxDisplay] = React.useState(false);
let columns: string[] = [];
let dataStats: IdatasStats[] = [];
if (props.columns.length > 0 && props.dataStats.length > 0) {
if (props.columns.length < 5) {
columns = [...props.columns, ...Array(5).fill("")];
dataStats = [...props.dataStats, ...Array(5).fill("")];
} else {
columns = [...props.columns, ...Array(2).fill("")];
dataStats = [...props.dataStats, ...Array(2).fill("")];
}
}

return (
<>
Expand Down Expand Up @@ -88,7 +103,7 @@ export default function PreviewTable(props: PreviewTableProps) {
padding: 0rem 0.4rem;
`}
>
{props.columns.map((val, index) => {
{columns.map((val, index) => {
return (
<TableCell key={val}>
<div
Expand All @@ -98,6 +113,7 @@ export default function PreviewTable(props: PreviewTableProps) {
justify-content: space-between;
align-items: center;
gap: 1rem;
width: ${val ? "auto" : "192px"};
`}
>
<div
Expand All @@ -107,9 +123,9 @@ export default function PreviewTable(props: PreviewTableProps) {
border-radius: 50%;
padding: 3px;
justify-content: center;
display: flex;
align-items: center;
background: #ffffff;
display: ${val ? "flex" : "none"};
`}
>
{props.dataTypes?.[val] === "string" ? "Aa" : "#"}
Expand All @@ -127,25 +143,25 @@ export default function PreviewTable(props: PreviewTableProps) {
>
<b>{val}</b>
</p>
<IconButton>
<SortIcon />
</IconButton>
{val && (
<IconButton>
<SortIcon />
</IconButton>
)}
</div>
</TableCell>
);
})}
</TableRow>
<TableRow>
{props.dataStats?.map((val) => (
{dataStats?.map((val) => (
<TableCell
key={val.name}
css={`
color: #000;
font-size: 12px;
// cursor: pointer;
background: #f4f4f4;
`}
// onClick={handleToolBoxDisplay}
>
{val.name !== "ID" && (
<div
Expand All @@ -168,7 +184,7 @@ export default function PreviewTable(props: PreviewTableProps) {
background: #fff;
`}
>
{props.columns.map((val, cellIndex) => (
{columns.map((val, cellIndex) => (
<TableCell key={val}>
<p
title={data?.[val] as string}
Expand Down
20 changes: 20 additions & 0 deletions src/app/utils/setMediaQueryForTest 2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import mediaQuery from "css-mediaquery";

function createMatchMedia(width: number) {
return (query: string) => ({
matches: mediaQuery.match(query, {
width,
}),
addListener: () => {},
removeListener: () => {},
media: "",
onchange: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false,
});
}
export function setMediaQueryForTest(width: number) {
window.matchMedia = createMatchMedia(width);
}

0 comments on commit 3a80e59

Please sign in to comment.