diff --git a/packages/entities/entities-shared/src/components/common/TableTags.cy.ts b/packages/entities/entities-shared/src/components/common/TableTags.cy.ts new file mode 100644 index 0000000000..5226beb1d8 --- /dev/null +++ b/packages/entities/entities-shared/src/components/common/TableTags.cy.ts @@ -0,0 +1,80 @@ +import TableTags from './TableTags.vue' + +const tagsArray = ['tag1', 'tag2', 'tag3'] +const tagsString = JSON.stringify(tagsArray) + +const emptyArray = [] as string[] +const emptyString = '[]' +const nullString = 'null' + +describe('', () => { + it('renders normal array correctly', () => { + cy.mount(TableTags, { + props: { + tags: tagsArray, + }, + }) + + cy.get('.k-truncate').should('exist') + cy.get('.k-badge').should('have.length', tagsArray.length) + }) + + it('renders JSON string correctly', () => { + cy.mount(TableTags, { + props: { + tags: tagsString, + }, + }) + + cy.get('.k-truncate').should('exist') + cy.get('.k-badge').should('have.length', tagsArray.length) + }) + + it('renders empty array correctly', () => { + cy.mount(TableTags, { + props: { + tags: emptyArray, + }, + }) + + cy.get('.k-truncate').should('not.exist') + cy.get('.k-badge').should('not.exist') + cy.get('span').should('have.text', '-') + }) + + it('renders empty string correctly', () => { + cy.mount(TableTags, { + props: { + tags: emptyString, + }, + }) + + cy.get('.k-truncate').should('not.exist') + cy.get('.k-badge').should('not.exist') + cy.get('span').should('have.text', '-') + }) + + it('renders null string correctly', () => { + cy.mount(TableTags, { + props: { + tags: nullString, + }, + }) + + cy.get('.k-truncate').should('not.exist') + cy.get('.k-badge').should('not.exist') + cy.get('span').should('have.text', '-') + }) + + it('renders tag max width correctly', () => { + cy.mount(TableTags, { + props: { + tags: tagsArray, + tagMaxWidth: '100', + }, + }) + + cy.get('.k-truncate').should('exist') + cy.get('.badge-content-wrapper').should('have.css', 'max-width', '100px') + }) +}) diff --git a/packages/entities/entities-shared/src/components/common/TableTags.vue b/packages/entities/entities-shared/src/components/common/TableTags.vue index 3fff7518c5..08f957d83e 100644 --- a/packages/entities/entities-shared/src/components/common/TableTags.vue +++ b/packages/entities/entities-shared/src/components/common/TableTags.vue @@ -3,7 +3,7 @@ {{ tag }} @@ -13,13 +13,13 @@