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

Fix #84 Logging blank filename #93

Merged
merged 5 commits into from
Jan 3, 2024
Merged

Conversation

chriskyfung
Copy link
Owner

This commit prevents the fetcher.js module to add a new row to the log
sheet even if the file was not successfully saved to Google Drive.

The fix only adding a new row to the log if the return value of the
createViewFileFormula() is not empty. This ensures that the log file
reflects the actual status of the file saving operation.

Fixes: #84

This commit adds a new utility function called `getFileDetails()` in a
new file `utils.js`. This function takes a URL as an argument and
returns an object containing the path, file name, and file extension of
the URL.

For example, `getFileDetails("https://example.com/foo/bar/baz.txt")`
would return `{path: "/foo/bar/", name: "baz", ext: ".txt"}`.

The `fetcher.js` file has been updated to use this function instead
of `String.split()` when fetching data from a URL. This helps resolving
URLs and extracting file information at once.
- Installed jest@29.7.0, @babel/preset-env@7.23.7,
  babel-polyfill@6.26.0, babel-jest@29.7.0 as development dependencies
- Added a test script in `package.json` to run jest with a custom
  configuration file in `jest.config.js`
- Added a Jest extension setting for VS Code
This commit adds a new unit test file called `utils.test.js`
in the `test` folder. This file contains a test suite for
the `getFileDetails()` function in `utils.js`. The test suite uses Jest
as the testing framework and checks the following scenarios:

- The function returns an object with the correct properties
  (path, fileName, fileExtension) for a valid URL
- The function returns the correct file details for a URL with
  query parameters
- The function returns the correct file details for a URL with a
  fragment identifier

The test suite has been run and passed with 100% coverage for
the `getFileDetails()` function.
- Moved `utils.test.js` to `__tests__` folder to separate it from
  non-Jest test files
- Modified the `input` parameter in `rollup.config.js` to prevent Jest
  test (`__tests__/*.test.js`) files from being included in the
  `bundle.js` output
- Added `testMatch` to force Jest to detect test files from `__tests__`
  folder
@chriskyfung chriskyfung self-assigned this Jan 3, 2024
@chriskyfung chriskyfung added bug Something isn't working dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Jan 3, 2024
@chriskyfung chriskyfung added this to the Library v9 milestone Jan 3, 2024
This commit prevents the fetcher.js module to add a new row to the log
sheet even if the file was not successfully saved to Google Drive.

The fix only adding a new row to the log if the return value of the
`createViewFileFormula()` is not empty. This ensures that the log file
reflects the actual status of the file saving operation.

Fixes: #84
@chriskyfung chriskyfung merged commit e9e2924 into dev Jan 3, 2024
1 check passed
@chriskyfung chriskyfung deleted the 84-fix-logging-blank-filename branch January 3, 2024 01:12
@chriskyfung chriskyfung linked an issue Feb 6, 2024 that may be closed by this pull request
@chriskyfung chriskyfung changed the title 84-fix-logging-blank-filename Fix #84 Logging blank filename Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saved filename error
1 participant