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

feat: LEAP-56: Update package scripts to run units e2e and integration tests #5052

Merged
merged 23 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
24fb8f7
Merge branch 'fb-leap-e-1' of https://github.com/HumanSignal/label-st…
juliosgarbi Nov 1, 2023
d5bffe7
Merge branch 'fb-leap-e-1' of https://github.com/HumanSignal/label-st…
juliosgarbi Nov 7, 2023
40ac7e9
Merge branch 'fb-leap-e-1' of https://github.com/HumanSignal/label-st…
juliosgarbi Nov 9, 2023
054d410
feat: LEAP-54: Move editor e2e tests to the new LS monorepo
juliosgarbi Nov 9, 2023
739edfc
feat: LEAP-239: Move ls-frontend-test to monorepo and make cypress te…
juliosgarbi Nov 10, 2023
08d010a
add cypress
juliosgarbi Nov 10, 2023
db9b3a7
move e2e folder to test folder
juliosgarbi Nov 10, 2023
8712793
move integration tests to the folder tests and change its name
juliosgarbi Nov 10, 2023
b7170c8
remove nx cypress and config default cypress
juliosgarbi Nov 15, 2023
4bf4b10
add the frontend-test as a lib
juliosgarbi Nov 15, 2023
a5e90ab
add frontend-test as a lib
juliosgarbi Nov 15, 2023
1d10ad6
fix cypress tests
juliosgarbi Nov 16, 2023
4db6a80
Merge branch 'fb-leap-e-1' of https://github.com/HumanSignal/label-st…
juliosgarbi Nov 16, 2023
c8af624
merge with leap-e-1
juliosgarbi Nov 16, 2023
997a228
remove dev build
juliosgarbi Nov 16, 2023
4f516c3
delete package lock
juliosgarbi Nov 16, 2023
ef77786
feat: LEAP-56: Update package scripts to run units e2e and integratio…
juliosgarbi Nov 17, 2023
27884f0
remove dist folder
juliosgarbi Nov 17, 2023
9efd99d
remove nx cloud
juliosgarbi Nov 17, 2023
64cef8c
Merge branch 'fb-leap-e-1' of https://github.com/HumanSignal/label-st…
juliosgarbi Nov 20, 2023
c6a4db7
merge conflcits
juliosgarbi Nov 20, 2023
a60da61
merge conflicts
juliosgarbi Nov 20, 2023
2182011
clear commands
juliosgarbi Nov 20, 2023
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: 1 addition & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ libs/editor/.env.production.local

# Testing
libs/editor/coverage/
libs/editor/tests/e2e/output/

# codecept screenshots
libs/editor/e2e/output
Expand Down
2 changes: 1 addition & 1 deletion web/apps/labelstudio-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/labelstudio-e2e/cypress.config.ts",
"devServerTarget": "labelstudio:serve:development",
"baseUrl": "http://localhost:8080/",
"testingType": "e2e"
},
"configurations": {
Expand Down
12 changes: 0 additions & 12 deletions web/apps/labelstudio-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
import { getGreeting } from '../support/app.po';

describe('labelstudio', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome labelstudio');
});
});
4 changes: 0 additions & 4 deletions web/apps/labelstudio-e2e/src/fixtures/example.json

This file was deleted.

1 change: 0 additions & 1 deletion web/apps/labelstudio-e2e/src/support/app.po.ts

This file was deleted.

33 changes: 0 additions & 33 deletions web/apps/labelstudio-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,33 +0,0 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
2 changes: 1 addition & 1 deletion web/apps/labelstudio/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"buildTarget": "labelstudio:build"
}
},
"test": {
"unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
Expand Down
2 changes: 0 additions & 2 deletions web/libs/datamanager/.env.build

This file was deleted.

6 changes: 4 additions & 2 deletions web/libs/datamanager/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# API_GATEWAY=http://[ls-hostname]/api/dm
# LS_ACCESS_TOKEN=[your LS token here]
API_GATEWAY=http://[ls-hostname]/api/dm
LS_ACCESS_TOKEN=[your LS token here]
CSS_PREFIX=[prefix for your css classes with trailing dash]
APP_FOLDER=libs/datamanager/
2 changes: 1 addition & 1 deletion web/libs/datamanager/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lintFilePatterns": ["libs/datamanager/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
Expand Down
2 changes: 0 additions & 2 deletions web/libs/editor/.env.build

This file was deleted.

4 changes: 2 additions & 2 deletions web/libs/editor/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
}
}
},
"test": {
"unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/editor/jest.config.ts",
"jestConfig": "libs/editor/jest.config.js",
"passWithNoTests": true
},
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ describe('AnnotationsButton', () => {
const entity = annotationStore.annotations[0];
const view = mount(<AnnotationButton entity={entity} capabilities={{}} annotationStore={annotationStore} />);

expect(view.find('.dm-annotation-button__entity-id').text()).toBe(`#${entity.pk}`);
expect(view.find('.lsf-annotation-button__entity-id').text()).toBe(`#${entity.pk}`);
});
test('Prediction', () => {
const entity = annotationStore.predictions[0];
const view = mount(<AnnotationButton entity={entity} capabilities={{}} annotationStore={annotationStore} />);
expect(view.find('.dm-annotation-button__entity-id').text()).toBe(`#${entity.pk}`);

expect(view.find('.lsf-annotation-button__entity-id').text()).toBe(`#${entity.pk}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jest.mock('react', () => ({

test('AnnotationsCarousel', async () => {
const view = mount(<AnnotationsCarousel annotationStore={annotationStore} store={store} />);
expect(view.find('.dm-annotations-carousel__carosel').children().length).toBe(9);

expect(view.find('.lsf-annotations-carousel__carosel').children().length).toBe(9);
});
10 changes: 5 additions & 5 deletions web/libs/editor/src/components/Filter/__tests__/Filter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Filter', () => {

const dropdown = await filter.getByTestId('dropdown');

expect(dropdown.classList.contains('dm-visible')).toBe(true);
expect(dropdown.classList.contains('lsf-visible')).toBe(true);

const AddButton = await filter.getByText('Add Filter');

Expand All @@ -160,9 +160,9 @@ describe('Filter', () => {

await new Promise((resolve) => setTimeout(resolve, 100));

expect(dropdown.classList.contains('dm-before-appear')).toBe(false);
expect(dropdown.classList.contains('dm-visible')).toBe(false);
expect(dropdown.classList.contains('dm-before-disappear')).toBe(false);
expect(dropdown.classList.contains('lsf-before-appear')).toBe(false);
expect(dropdown.classList.contains('lsf-visible')).toBe(false);
expect(dropdown.classList.contains('lsf-before-disappear')).toBe(false);
});

test('Should show filter length badge', () => {
Expand Down Expand Up @@ -217,6 +217,6 @@ describe('Filter', () => {

fireEvent.click(FilterButton);

expect(FilterButton.classList.contains('dm-filter-button_active')).toBe(true);
expect(FilterButton.classList.contains('lsf-filter-button_active')).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ describe('PanelBase', () => {
</PanelBase>
</div>);

expect(view.find('.dm-panel__title').text()).toBe(panelName);
expect(view.find('.dm-panel__body .dm-details').text()).toBe(sampleContent);
expect(view.find('.lsf-panel__title').text()).toBe(panelName);
expect(view.find('.lsf-panel__body .lsf-details').text()).toBe(sampleContent);
expect(isCurrentlyExpanded).toBe(true);
view.find('.dm-panel__toggle').simulate('click');
view.find('.lsf-panel__toggle').simulate('click');
expect(isCurrentlyExpanded).toBe(false);
});
});
12 changes: 0 additions & 12 deletions web/nx.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": [
"build",
"lint",
"test",
"e2e"
],
"accessToken": "YWU2NWZlYjItYzI2MS00MDcwLThhNzQtMDM0ZDZjMTdjNWZifHJlYWQtd3JpdGU="
}
}
},
"targetDefaults": {
"build": {
Expand Down
43 changes: 26 additions & 17 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
"license": "MIT",
"scripts": {
"ls:watch": "nx run labelstudio:build:development --watch",
"ls:unit": "nx run labelstudio:unit",
"ls:e2e": "nx run labelstudio-e2e:e2e",
"lsf:watch": "nx run editor:build:development --watch",
"lsf:serve": "nx run editor:serve:development",
"lsf:e2e": "cd libs/editor/tests/e2e && npm run test",
"lsf:e2e": "cd libs/editor/tests/e2e && yarn test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a further iteration it would be nice to move this test suite to an app test suite like labelstudio-e2e, and have an editor-e2e. That way we could use the nx project settings and detection for affected and run a single command for testing which would invoke the e2e, integration, or unit layers accordingly to which project has affected files. That way CI does not have to run tests where code has not been changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree with you, I tried to use the nx test suite but as we are using codeceptjs to test e2e I wasn't able to make it works, I would have to change a lot of things on our test suite so unfortunately I believe that for now it's better keep how it is right now!

"lsf:integration": "nx run editor:integration",
"lsf:integration:watch": "nx run editor:integration --watch",
"lsf:unit": "nx run editor:unit",
"dm:watch": "nx run datamanager:build:development --watch",
"dm:unit": "nx run datamanager:unit",
"build": "nx run editor:build:production && nx run datamanager:build:production && nx run labelstudio:build:production",
"test": "nx run labelstudio:test:ci"
"test:unit": "yarn lsf:unit && yarn ls:unit && yarn dm:unit",
"test:e2e": "yarn ls:e2e && yarn lsf:e2e",
"test:integration": "yarn lsf:integration",
"postinstall": "cd libs/editor && bash scripts/postinstall.sh"
},
"private": true,
"dependencies": {
Expand All @@ -23,6 +30,7 @@
"@reecelucas/react-use-hotkeys": "^1.3.1",
"@swc/helpers": "0.5.3",
"@thi.ng/rle-pack": "^3.1.30",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"antd": "^4.3.3",
"babel-plugin-import": "^1.13.0",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand All @@ -34,8 +42,10 @@
"deep-equal": "^2.0.5",
"dotenv-defaults": "^2.0.2",
"emoji-regex": "^7.0.3",
"enzyme": "^3.11.0",
"husky": "^3.1.0",
"insert-after": "^0.1.4",
"jest-fetch-mock": "^3.0.3",
"keymaster": "^1.6.2",
"konva": "^8.1.3",
"lint-staged": "^9.5.0",
Expand Down Expand Up @@ -85,6 +95,8 @@
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.12.13",
"@cypress/code-coverage": "^3.10.0",
"@cypress/webpack-preprocessor": "^5.17.0",
"@nrwl/react": "17.0.3",
"@nx/cypress": "17.0.3",
"@nx/eslint-plugin": "17.0.3",
Expand All @@ -102,7 +114,7 @@
"@swc-node/register": "~1.6.7",
"@swc/cli": "~0.1.62",
"@swc/core": "1.3.96",
"@testing-library/react": "14.0.0",
"@testing-library/react": "^14.1.2",
"@types/chroma-js": "^2.1.3",
"@types/jest": "^29.4.0",
"@types/mini-css-extract-plugin": "^2.5.1",
Expand All @@ -116,11 +128,17 @@
"@typescript-eslint/parser": "5.62.0",
"babel-jest": "^29.4.1",
"babel-loader": "^8.2.2",
"chai": "^4.3.7",
"chroma-js": "^2.1.1",
"codemirror": "^5.59.4",
"css-loader": "^5.0.1",
"css-minimizer-webpack-plugin": "^3.0.2",
"cypress": "^12.11.0",
"cypress-image-snapshot": "^4.0.1",
"cypress-multi-reporters": "^1.6.2",
"cypress-parallel": "^0.12.0",
"cypress-plugin-snapshots": "^1.4.4",
"cypress-terminal-report": "^5.1.1",
"date-fns": "^2.20.1",
"eslint": "8.46.0",
"eslint-config-prettier": "9.0.0",
Expand All @@ -136,8 +154,11 @@
"lodash.clonedeep": "^4.5.0",
"nx": "17.0.3",
"nx-cloud": "16.5.2",
"pixelmatch": "^5.3.0",
"pleasejs": "^0.4.2",
"pngjs": "^7.0.0",
"prettier": "^2.6.2",
"proper-lockfile": "^4.1.2",
"react-codemirror2": "^7.2.1",
"react-icons": "^4.2.0",
"react-refresh": "^0.10.0",
Expand All @@ -150,24 +171,13 @@
"stylus-loader": "^5.0.0",
"truncate-middle": "^1.0.6",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"ts-node": "10.9.1",
"typescript": "4.8.3",
"url-loader": "^4.1.1",
"xpath-range": "^1.1.1",
"@cypress/code-coverage": "^3.10.0",
"@cypress/webpack-preprocessor": "^5.17.0",
"chai": "^4.3.7",
"cypress-image-snapshot": "^4.0.1",
"cypress-multi-reporters": "^1.6.2",
"cypress-parallel": "^0.12.0",
"cypress-plugin-snapshots": "^1.4.4",
"cypress-terminal-report": "^5.1.1",
"pixelmatch": "^5.3.0",
"pngjs": "^7.0.0",
"proper-lockfile": "^4.1.2",
"ts-loader": "^9.4.2",
"webpack": "^5.77.0",
"webpack-cli": "^5.0.1",
"xpath-range": "^1.1.1",
"yargs": "^17.7.1"
},
"babel": {
Expand Down Expand Up @@ -198,4 +208,3 @@
},
"packageManager": "yarn@3.6.0"
}

Loading
Loading