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: improve keywords in builder to allow to edit #117

Merged
merged 25 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fc00c9a
feat: implement auto-save feature
ReidyT Feb 12, 2024
3491d15
feat: update hasChanged to consider empty settings
ReidyT Feb 12, 2024
2dc670d
chore(test): remove save button click in enterSettings to test auto save
ReidyT Feb 12, 2024
514fd11
fix(test): remove only
ReidyT Feb 12, 2024
43b0315
feat: first improvements of the keywords in builder
ReidyT Feb 15, 2024
34d0aed
feat: implement global checkbox to select/unselect all
ReidyT Feb 15, 2024
889b9f6
feat: implement delete row
ReidyT Feb 15, 2024
886d10a
feat: add save/cancel all and improve Table responsivity
ReidyT Feb 15, 2024
ade3281
fix: update onChange in ReadableTextField to avoid erasing edited values
ReidyT Feb 15, 2024
0f6d09a
chore: first refactor of the table
ReidyT Feb 16, 2024
ce31a57
fix: update saveKeyword compare to not allow to save same keywords
ReidyT Feb 16, 2024
a3a4d51
chore: first refactor of the table
ReidyT Feb 16, 2024
0467659
fix: update KeyWords component to propagate pendingkeywords to parent
ReidyT Feb 16, 2024
74ec481
chore: continue to refactor
ReidyT Feb 16, 2024
00f2348
chore(translation): translates the table
ReidyT Feb 16, 2024
6c9bbb4
fix: update chatbot toggle button to take min space
ReidyT Feb 16, 2024
ae026bd
fix(test): update tests to work correctly with the new table
ReidyT Feb 19, 2024
70a19c4
chore(test): write E2E tests for the edit keywords table
ReidyT Feb 19, 2024
3c024fe
fix: disable save buttons when the keyword is empty
ReidyT Feb 19, 2024
56466ce
feat: improve code from code review
ReidyT Feb 27, 2024
e5b0259
feat: move logic of EditableTable in a hook
ReidyT Feb 27, 2024
a25577b
feat: remove EditableTableContext
ReidyT Feb 28, 2024
2ff0565
feat: export only necessary from EditableTable viewModel
ReidyT Feb 28, 2024
a352062
fix: display table filter in the translation
ReidyT Feb 28, 2024
c411386
feat: remove only in tests and use min chars instead of width
ReidyT Mar 1, 2024
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
87 changes: 7 additions & 80 deletions cypress/e2e/builder/enterSettings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ import { Context, PermissionLevel } from '@graasp/sdk';

import { KeywordsData } from '../../../src/config/appSettingTypes';
import {
ADD_KEYWORD_BUTTON_CY,
BUILDER_VIEW_CY,
CHATBOT_CONTAINER_CY,
DELETE_KEYWORD_BUTTON_CY,
ENTER_DEFINITION_FIELD_CY,
ENTER_KEYWORD_FIELD_CY,
INITIAL_CHATBOT_PROMPT_INPUT_FIELD_CY,
INITIAL_PROMPT_INPUT_FIELD_CY,
KEYWORD_LIST_ITEM_CY,
SETTINGS_SAVE_BUTTON_CY,
TEXT_INPUT_FIELD_CY,
TITLE_INPUT_FIELD_CY,
USE_CHATBOT_DATA_CY,
buildDataCy,
buildKeywordNotExistWarningCy,
buildKeywordDefinitionTextInputCy,
buildKeywordTextInputCy,
} from '../../../src/config/selectors';
import {
MOCK_APP_SETTINGS,
Expand Down Expand Up @@ -81,77 +77,6 @@ describe('Enter Settings', () => {
cy.get(buildDataCy(SETTINGS_SAVE_BUTTON_CY)).should('not.be.disabled');
});

it('set keywords', () => {
cy.get(buildDataCy(ENTER_KEYWORD_FIELD_CY))
.should('be.visible')
.type('Lorem');

cy.get(buildDataCy(ENTER_DEFINITION_FIELD_CY))
.should('be.visible')
.type('Latin');

cy.get(buildDataCy(KEYWORD_LIST_ITEM_CY)).should('not.exist');

cy.get(buildDataCy(ADD_KEYWORD_BUTTON_CY))
.should('be.visible')
.should('not.be.disabled')
.click()
.should('be.disabled');
cy.get(buildDataCy(KEYWORD_LIST_ITEM_CY)).should('exist');

cy.get(buildDataCy(DELETE_KEYWORD_BUTTON_CY)).should('be.visible').click();
cy.get(buildDataCy(KEYWORD_LIST_ITEM_CY)).should('not.exist');
});

// Detected incomplete keywords in the text.
// 'wef' was found incomplete in 'wefwef hello'.
// Check that only complete words are detected in text.
it('only detect complete keywords', () => {
const PRBLEMATIC_TEXT = 'wefwef hello';
const PROBLEMATIC_KEYWORDS = ['wef', 'he'];

cy.get(buildDataCy(TEXT_INPUT_FIELD_CY))
.should('be.visible')
.type(PRBLEMATIC_TEXT);

PROBLEMATIC_KEYWORDS.forEach((k) => {
cy.get(buildDataCy(ENTER_KEYWORD_FIELD_CY)).should('be.visible').type(k);

cy.get(buildDataCy(ADD_KEYWORD_BUTTON_CY))
.should('be.visible')
.should('not.be.disabled')
.click()
.should('be.disabled');

cy.get(buildDataCy(buildKeywordNotExistWarningCy(k))).should(
'be.visible',
);
});

cy.get(buildDataCy(SETTINGS_SAVE_BUTTON_CY)).should('be.disabled');
});

it('detect keywords case insensitive', () => {
const TEXT = 'hello this is a Test';
const KEYWORDS = ['Hello', 'test'];

cy.get(buildDataCy(TEXT_INPUT_FIELD_CY)).should('be.visible').type(TEXT);

KEYWORDS.forEach((k) => {
cy.get(buildDataCy(ENTER_KEYWORD_FIELD_CY)).should('be.visible').type(k);

cy.get(buildDataCy(ADD_KEYWORD_BUTTON_CY))
.should('be.visible')
.should('not.be.disabled')
.click()
.should('be.disabled');

cy.get(buildDataCy(buildKeywordNotExistWarningCy(k))).should('not.exist');
});

cy.get(buildDataCy(SETTINGS_SAVE_BUTTON_CY)).should('be.disabled');
});

it('does not use chatbot (by default)', () => {
cy.get(buildDataCy(USE_CHATBOT_DATA_CY)).should('not.be.checked');
cy.get(buildDataCy(CHATBOT_CONTAINER_CY)).should('not.exist');
Expand Down Expand Up @@ -198,12 +123,14 @@ describe('Load Settings', () => {
const list = MOCK_APP_SETTINGS.find(
(appSetting) => appSetting === MOCK_KEYWORDS_SETTING,
).data as KeywordsData;

list.keywords.forEach((elem) => {
cy.get(buildDataCy(KEYWORD_LIST_ITEM_CY)).should(
cy.get(buildDataCy(buildKeywordTextInputCy(elem.word, true))).should(
'contain',
`${elem.word} : ${elem.def}`,
elem.word,
);
cy.get(
buildDataCy(buildKeywordDefinitionTextInputCy(elem.word, true)),
).should('contain', elem.def);
});
});
});
Loading
Loading