Update sidebar on color change

Resolves MS-894 #complete
This commit is contained in:
Ramon Wenger 2024-03-07 10:48:26 +01:00
parent 763b19a2f0
commit 23698a432b
3 changed files with 7 additions and 5 deletions

View File

@ -195,11 +195,11 @@ const createHighlight = (text: string, content = false) => {
cy.getByDataCy('highlight-mark').should('have.length', 1); cy.getByDataCy('highlight-mark').should('have.length', 1);
}; };
const updateHighlight = (text) => { const updateHighlight = (text, color = 'beta') => {
cy.getByDataCy('highlight-beta').click(); cy.getByDataCy(`highlight-${color}`).click();
cy.wait('@UpdateHighlight'); cy.wait('@UpdateHighlight');
cy.getByDataCy('highlight-mark').should('contain', text); cy.getByDataCy('highlight-mark').should('contain', text);
cy.getByDataCy('highlight-mark').should('have.class', 'highlight--beta'); cy.getByDataCy('highlight-mark').should('have.class', `highlight--${color}`);
// //
// we only want to have one of each element and not accidentally create multiple // we only want to have one of each element and not accidentally create multiple
cy.getByDataCy('highlight-popover').should('have.length', 1); // there should only be one popover cy.getByDataCy('highlight-popover').should('have.length', 1); // there should only be one popover
@ -274,7 +274,8 @@ describe('Highlights', () => {
cy.getByDataCy('highlight-popover').should('be.visible'); cy.getByDataCy('highlight-popover').should('be.visible');
cy.getByDataCy('highlight-sidebar').should('be.visible'); cy.getByDataCy('highlight-sidebar').should('be.visible');
// todo: change the color updateHighlight(highlightedText, 'gamma');
cy.getByDataCy('highlight-in-sidebar').should('have.class', 'highlight--gamma');
// todo: write a note // todo: write a note
// todo: click the note icon without first setting a color // todo: click the note icon without first setting a color

View File

@ -16,6 +16,7 @@
></div> ></div>
<div <div
class="highlight-popover__color highlight-popover__color--blue" class="highlight-popover__color highlight-popover__color--blue"
data-cy="highlight-gamma"
@click="$emit('choose-color', 'gamma')" @click="$emit('choose-color', 'gamma')"
></div> ></div>
</section> </section>

View File

@ -316,7 +316,7 @@ const markClickListenerCurry =
// we need to refresh the sidebar // we need to refresh the sidebar
highlightSidebar.open({ highlightSidebar.open({
highlight, highlight: newHighlight,
onUpdateText: onUpdateTextCurry(newHighlight), onUpdateText: onUpdateTextCurry(newHighlight),
}); });
} catch (error) { } catch (error) {