Skip to content
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
1 change: 0 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## General Instructions
- Keep it simple.
- Work in small, incremental changes.
- Whenever you run a command in the terminal, pipe the output to a file, output.txt, that you can read from. Make sure to overwrite each time so that it doesn't grow too big. There is a bug in the current version of Copilot that causes it to not read the output of commands correctly. This workaround allows you to read the output from the temporary file instead.
- Ensure changes pass linting checks by running `npm run lint` and waiting for it to complete. Read the linting errors and resolve them manually.
- Ensure changes build successfully by running `npm run build`.
- Do not add new dependencies unless given explicit permission.
Expand Down
22 changes: 22 additions & 0 deletions .github/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,25 @@
- [x] Implement the fix requested in [#209](https://github.com/SenteraLLC/ulabel/issues/209).
- [x] Build the fix and ensure the build succeeds by running `npm run build`.
- [x] Receive confirmation that the fix works as expected.
- [x] Configure Jest to suppress verbose stack traces (added --noStackTrace flag)
- [x] Fix class ID test to check ID is not in existing list (implementation-agnostic)
- [x] Increase max workers from 1 to 2 (reduced test time from 200s+ to ~23s)
- [ ] Fix remaining unit test failures (6 failures, 14 passed)
- Spatial payload tests need DOM mocking
- ID payload tests need DOM mocking
- Note: Some error messages contain minified code context - this is expected when testing against dist/ulabel.js
- [x] Refactor e2e tests to use utility functions
- [x] Create init_utils.js with wait_for_ulabel_init
- [x] Create annotation_utils.js with get_annotation_count, get_annotation_by_index, get_all_annotations
- [x] Create mode_utils.js with switch_to_mode
- [x] Create subtask_utils.js with get_current_subtask_key, switch_to_subtask, get_subtask_count
- [x] Update basic-functionality.spec.js to use new utilities
- [x] All 6 basic functionality tests passing
- [x] Refactor tests/ folder to use snake_case naming convention
- [x] Updated all utility function names to snake_case
- [x] Updated all variable names in e2e tests to snake_case
- [x] Updated all variable names in unit tests to snake_case
- [x] Updated all variable names in setup.js to snake_case
- [x] Updated all variable names in utility files to snake_case
- [x] Verified unit tests pass (14 passed)
- [x] Verified e2e tests pass (6 passed)
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Tests

on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
push:
branches:
- main

jobs:
unit-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Run unit tests
run: npm run build-and-test

e2e-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Build project
run: npm run build

- name: Run E2E tests
run: npm run test:e2e

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
ulabel_local/py-dbapi/dbapi/__pycache__
build
build/*
output.txt
output.txt
test-results/
playwright-report/
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable changes to this project will be documented here.

Nothing yet.

## [0.19.1] - Oct 9th, 2025
- Add automated testing to the repo
- Fix circular webpack builds by forcibly cleaning the `dist/` directory before each build
- Also use `import type... from ".."` instead of just `import` to fix ts not properly resolving imports to js
- Reduced bundle size from ~20 MB -> 1 MB
- Refactor some more `console.warn` and `console.error` instances to use `log_message`
- Remove deprecated `parent_id` field from `ULabelAnnotation`

## [0.19.0] - Aug 19th, 2025

- Add minimal lineage tracking via `last_edited_by` and `last_edited_at` annotation fields
Expand Down
3 changes: 0 additions & 3 deletions api_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ As you can see, each subtask will have a corresponding list of annotation object
// a unique id for this annotation
"id": "<uuidv4 string>",

// (nullable) id of ann that was edited to create this one
"parent_id": "<uuidv4 string>",

// the provided username
"created_by": "<string>",

Expand Down
2 changes: 2 additions & 0 deletions demo/multi-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
console.log(ulabel);
});

// Expose ulabel instance globally for testing
window.ulabel = ulabel;
});
</script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion dist/ulabel.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/ulabel.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ object-assign
and limitations under the License.
***************************************************************************** */

/*! For license information please see ulabel.js.LICENSE.txt */

/**
* splaytree v3.1.2
* Fast Splay tree for Node and browser
Expand Down
2 changes: 1 addition & 1 deletion dist/ulabel.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/ulabel.min.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ object-assign
and limitations under the License.
***************************************************************************** */

/*! For license information please see ulabel.js.LICENSE.txt */

/**
* splaytree v3.1.2
* Fast Splay tree for Node and browser
Expand Down
34 changes: 34 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,38 @@ export default [
},
eslint.configs.recommended,
...tseslint.configs.recommended,
{
// Special configuration for test files - placed last to override other configs
files: ["tests/**/*.{js,mjs,cjs,ts}", "jest.config.js", "playwright.config.js"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
require: "readonly",
module: "readonly",
global: "readonly",
process: "readonly",
describe: "readonly",
test: "readonly",
it: "readonly",
expect: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
jest: "readonly",
},
},
rules: {
// Allow require() imports in tests (needed for CommonJS module loading)
"@typescript-eslint/no-require-imports": "off",
// Allow no-undef for Node.js and Jest globals
"no-undef": "off",
// Allow unused variables in tests (for mocking scenarios)
"@typescript-eslint/no-unused-vars": "warn",
// Allow unused expressions in test setup (for side effects)
"@typescript-eslint/no-unused-expressions": "off",
},
},
];
41 changes: 41 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/tests/setup.js"],
testMatch: [
"<rootDir>/tests/**/*.test.js",
],
testPathIgnorePatterns: [
"<rootDir>/tests/e2e/",
"<rootDir>/tests/utils/",
],
collectCoverageFrom: [
"src/**/*.{js,ts}",
"build/**/*.js",
"!src/version.js",
"!build/version.js",
],
coverageDirectory: "coverage",
coverageReporters: ["text", "lcov", "html"],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
transform: {
"^.+\\.(js|ts)$": "babel-jest",
},
transformIgnorePatterns: [
"node_modules/(?!(uuid)/)",
],
// Optimize memory usage
maxWorkers: 2,
workerIdleMemoryLimit: "512MB",
// Clear cache between runs
clearMocks: true,
resetMocks: true,
restoreMocks: true,
// Reduce noise in error output
verbose: false,
// Suppress stack traces
noStackTrace: true,
// Suppress console output during tests
silent: true,
};
Loading