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
3 changes: 2 additions & 1 deletion packages/compass-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
"clean": "node -e \"fs.rmSync('lib', { recursive: true, force: true })\" || true",
"precompile": "npm run clean",
"compile": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig-lint.json --noEmit",
"eslint": "eslint-compass",
"prettier": "prettier-compass",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"check": "npm run lint && npm run depcheck",
"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"test": "mocha",
"test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ describe('ContentWithFallback', function () {
);

expect(container.children.length).to.equal(2);
const [contentContainer, contextMenuContainer] = container.children;
const [contentContainer, contextMenuContainer] = Array.from(
container.children
);
expect(contentContainer.children.length).to.equal(0);
expect(contextMenuContainer.getAttribute('data-testid')).to.equal(
'context-menu-container'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import HadronDocument from 'hadron-document';
import Document from './document';

const EditableDoc = ({ doc }) => {
const EditableDoc = ({ doc }: { doc: HadronDocument }) => {
const [editing, setEditing] = useState(false);

return (
Expand Down Expand Up @@ -61,8 +61,11 @@ describe('Document', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('str').uuid}"]`
`[data-id="${doc.get('str')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}
const keyEditor = within(el).getByTestId('hadron-document-key-editor');

userEvent.clear(keyEditor);
Expand All @@ -71,16 +74,19 @@ describe('Document', function () {

expect(screen.getByDisplayValue('new_name')).to.exist;

expect(doc.get('new_name').key).to.eq('str');
expect(doc.get('new_name').currentKey).to.eq('new_name');
expect(doc.get('new_name')?.key).to.eq('str');
expect(doc.get('new_name')?.currentKey).to.eq('new_name');
});

it('should change element string value on edit', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('str').uuid}"]`
`[data-id="${doc.get('str')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

const valueEditor = within(el).getByTestId(
'hadron-document-value-editor'
Expand All @@ -90,16 +96,19 @@ describe('Document', function () {
userEvent.keyboard('bla');
userEvent.tab();

expect(doc.get('str').currentValue).to.eq('bla');
expect(doc.get('str').currentType).to.eq('String');
expect(doc.get('str')?.currentValue).to.eq('bla');
expect(doc.get('str')?.currentType).to.eq('String');
});

it('should change element number value on edit', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('num').uuid}"]`
`[data-id="${doc.get('num')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

const valueEditor = within(el).getByTestId(
'hadron-document-value-editor'
Expand All @@ -109,16 +118,19 @@ describe('Document', function () {
userEvent.keyboard('321');
userEvent.tab();

expect(doc.get('num').currentValue.valueOf()).to.eq(321);
expect(doc.get('num').currentType).to.eq('Int32');
expect(doc.get('num')?.currentValue?.valueOf()).to.eq(321);
expect(doc.get('num')?.currentType).to.eq('Int32');
});

it('should change element date value on edit', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('date').uuid}"]`
`[data-id="${doc.get('date')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

const valueEditor = within(el).getByTestId(
'hadron-document-value-editor'
Expand All @@ -128,26 +140,29 @@ describe('Document', function () {
userEvent.keyboard('2000-01-01');
userEvent.tab();

expect((doc.get('date').currentValue as Date).toISOString()).to.eq(
expect((doc.get('date')?.currentValue as Date).toISOString()).to.eq(
'2000-01-01T00:00:00.000Z'
);
expect(doc.get('date').currentType).to.eq('Date');
expect(doc.get('date')?.currentType).to.eq('Date');
});

it('should change element type on edit', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('num').uuid}"]`
`[data-id="${doc.get('num')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

const typeEditor = within(el).getByTestId('hadron-document-type-editor');

userEvent.selectOptions(typeEditor, 'String');
userEvent.tab();

expect(doc.get('num').currentValue.valueOf()).to.eq('123');
expect(doc.get('num').currentType).to.eq('String');
expect(doc.get('num')?.currentValue?.valueOf()).to.eq('123');
expect(doc.get('num')?.currentType).to.eq('String');
});
});

Expand All @@ -168,8 +183,11 @@ describe('Document', function () {
render(<Document value={doc} editable editing></Document>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('null_value').uuid}"]`
`[data-id="${doc.get('null_value')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

const typeEditor = within(el).getByTestId('hadron-document-type-editor');

Expand All @@ -182,16 +200,19 @@ describe('Document', function () {
userEvent.keyboard('foo bar');
userEvent.tab();

expect(doc.get('null_value').currentValue.valueOf()).to.eq('foo bar');
expect(doc.get('null_value').currentType).to.eq('String');
expect(doc.get('null_value')?.currentValue?.valueOf()).to.eq('foo bar');
expect(doc.get('null_value')?.currentType).to.eq('String');
});

it('should autofocus key editor when double-clicking key', function () {
render(<EditableDoc doc={doc}></EditableDoc>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('str').uuid}"]`
`[data-id="${doc.get('str')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

userEvent.dblClick(within(el).getByTestId('hadron-document-clickable-key'));

Expand All @@ -204,8 +225,11 @@ describe('Document', function () {
render(<EditableDoc doc={doc}></EditableDoc>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('str').uuid}"]`
`[data-id="${doc.get('str')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

userEvent.dblClick(
within(el).getByTestId('hadron-document-clickable-value')
Expand All @@ -220,8 +244,11 @@ describe('Document', function () {
render(<EditableDoc doc={doc}></EditableDoc>);

const el = document.querySelector<HTMLElement>(
`[data-id="${doc.get('null_value').uuid}"]`
`[data-id="${doc.get('null_value')?.uuid}"]`
);
if (!el) {
throw new Error('Could not find element');
}

userEvent.dblClick(
within(el).getByTestId('hadron-document-clickable-value')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import FileInput, {
} from './file-picker-dialog';

describe('FileInput', function () {
let spy;
let spy: sinon.SinonSpy;

beforeEach(function () {
spy = sinon.spy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,31 @@ describe('GuideCueService', function () {

context('marks group as visited', function () {
context('when all the cues of group are added', function () {
const cue1 = {
cueId: 'one',
step: 1,
groupId: 'group-two',
isIntersecting: true,
} as unknown as Cue;
const cue2 = {
cueId: 'two',
step: 2,
groupId: 'group-two',
isIntersecting: true,
};
let cue1: Cue;
let cue2: Cue;

let markCueAsVisited: Sinon.SinonSpy;

beforeEach(function () {
cue1 = {
cueId: 'one',
step: 1,
groupId: 'group-two',
isVisited: false,
isIntersecting: true,
};
cue2 = {
cueId: 'two',
step: 2,
groupId: 'group-two',
isVisited: false,
isIntersecting: true,
};

markCueAsVisited = Sinon.spy(guideCueStorage, 'markCueAsVisited');
guideCueService.addCue(cue1 as any);
guideCueService.addCue(cue2 as any);
guideCueService.markGroupAsVisited(cue1.groupId);
guideCueService.addCue(cue1);
guideCueService.addCue(cue2);
guideCueService.markGroupAsVisited(cue1.groupId!);
});

it('updates isVisited property for all group cues', function () {
Expand Down Expand Up @@ -444,19 +449,21 @@ describe('GuideCueService', function () {
});

context('when all the cues of group are not added', function () {
const cue1 = {
cueId: 'one',
step: 1,
groupId: 'group-two',
isIntersecting: true,
} as unknown as Cue;
let cue1: Cue;

let markCueAsVisited: Sinon.SinonSpy;

beforeEach(function () {
cue1 = {
cueId: 'one',
step: 1,
groupId: 'group-two',
isIntersecting: true,
isVisited: false,
};
markCueAsVisited = Sinon.spy(guideCueStorage, 'markCueAsVisited');
guideCueService.addCue(cue1 as any);
guideCueService.markGroupAsVisited(cue1.groupId);
guideCueService.addCue(cue1);
guideCueService.markGroupAsVisited(cue1.groupId!);
});

it('does not update isVisited property for group cues', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const renderGuideCue = (props: Partial<ComponentProps<typeof GuideCue>>) => {
</Button>
<GuideCue
cueId=""
groupId=""
step={0}
title=""
description=""
trigger={({ ref }) => (
Expand Down
Loading
Loading