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

Chore: Setup report package development configurations #756

Merged
merged 5 commits into from
Jul 11, 2024
Merged
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
4 changes: 3 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"cli:build": "cross-env NODE_ENV=production npm run build -w @google-psat/cli",
"cli:start": "npm install && npm run cli:dev",
"cli": "node packages/cli/dist/main.js",
"report:dev": "npm run dev -w @google-psat/report",
"cli-dashboard:dev": "npm run dev -w @google-psat/cli-dashboard",
"cli-dashboard:prebuild": "npm run build:remove -w @google-psat/cli-dashboard",
"cli-dashboard:build": "npm run cli-dashboard:prebuild && cross-env NODE_ENV=production npm run build -w @google-psat/cli-dashboard",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://github.com/GoogleChromeLabs/ps-analysis-tool#readme",
"scripts": {
"dev": "webpack --config ../../dashboard.webpack.config.cjs --watch",
"dev": "webpack --config ../../dashboard.webpack.config.cjs --watch",
"build": "webpack --config ../../dashboard.webpack.config.cjs",
"build:remove": "rimraf dist",
"publish:local": "npm publish --registry=http://localhost:4873",
Expand Down
8 changes: 5 additions & 3 deletions packages/report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@
"access": "public"
},
"scripts": {
"dev": "webpack serve --config ./webpack.config.cjs --open",
"publish:local": "npm publish --registry=http://localhost:4873",
"publish:remote": "npm publish --access=public --registry=https://registry.npmjs.org",
"unpublish:local": "npm unpublish --registry=http://localhost:4873 --force",
"unpublish:remote": "npm unpublish --registry=https://registry.npmjs.org --force"
},
"homepage": "https://github.com/GoogleChromeLabs/ps-analysis-tool#readme",
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@google-psat/common": "*",
"@google-psat/design-system": "*",
"@google-psat/i18n": "*",
"@google-psat/library-detection": "*",
"@google-psat/i18n": "*"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.22.15",
"@babel/preset-env": "^7.22.15",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.22.15",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@types/file-saver": "^2.0.5",
"babel-loader": "^9.1.3",
"webpack": "^5.88.2",
Expand Down
11,367 changes: 11,367 additions & 0 deletions packages/report/src/dummyData/PSAT_DATA.js

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions packages/report/src/stateProviders/data/dataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,24 @@ const Provider = ({ children }: PropsWithChildren) => {
);

useEffect(() => {
//@ts-ignore custom data attached to window breaks types
const _data = window.PSAT_DATA;
(async () => {
if (process.env.NODE_ENV === 'development') {
const module = await import('../../dummyData/PSAT_DATA.js');
window.PSAT_DATA = module.default;
}

I18n.initMessages(_data.translations);
//@ts-ignore custom data attached to window breaks types
const _data = window.PSAT_DATA;

setData(_data);
if (_data?.libraryMatches) {
setLibraryMatches(_data.libraryMatches);
}
setShowLoader(false);
setIsDataLoaded(true);
I18n.initMessages(_data.translations);

setData(_data);
if (_data?.libraryMatches) {
setLibraryMatches(_data.libraryMatches);
}
setShowLoader(false);
setIsDataLoaded(true);
})();
}, [setLibraryMatches, setShowLoader]);

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/report/src/tests/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import '@testing-library/jest-dom';
* Internal dependencies.
*/
import App from '../app';
import data from './data.mock';
import data from '../dummyData/PSAT_DATA';
import { useData } from '../stateProviders/data';

jest.mock('../stateProviders/data', () => ({
Expand Down Expand Up @@ -74,6 +74,6 @@ describe('Report View', () => {
it('Should add chrome API mocks ', async () => {
mockUseDataStore.mockReturnValue(data);
render(<App />);
expect(await screen.findByText('Total cookies')).toBeInTheDocument();
expect(await screen.findByText('Total Cookies')).toBeInTheDocument();
});
});
Loading
Loading