Skip to content

Commit

Permalink
Merge pull request #179 from KevinBatdorf/update-shiki-2
Browse files Browse the repository at this point in the history
Add new languages and more
  • Loading branch information
KevinBatdorf committed Apr 30, 2023
2 parents 6dc9c4a + 6c73b50 commit b5e49fe
Show file tree
Hide file tree
Showing 18 changed files with 3,633 additions and 2,300 deletions.
3 changes: 2 additions & 1 deletion cypress/e2e/copy-button.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ context('Copy button', () => {
.invoke('html')
.should('contain', 'Copy');

cy.get('[data-cy="copy-button"]').uncheck().should('not.be.checked');
cy.get('[data-cy="copy-button"]').uncheck();
cy.get('[data-cy="copy-button"]').should('not.be.checked');

cy.getPostContent('.wp-block[class$="code-block-pro"]')
.invoke('html')
Expand Down
36 changes: 21 additions & 15 deletions cypress/e2e/lines.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ context('Line numbers', () => {
'cbp-has-line-numbers',
);

cy.get('[data-cy="show-line-numbers"]').check().should('be.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');
cy.getPostContent('.wp-block[class$="code-block-pro"]').should(
'have.class',
'cbp-has-line-numbers',
);

cy.get('[data-cy="show-line-numbers"]')
.uncheck()
.should('not.be.checked');
cy.get('[data-cy="show-line-numbers"]').uncheck();
cy.get('[data-cy="show-line-numbers"]').should('not.be.checked');
cy.getPostContent('.wp-block[class$="code-block-pro"]').should(
'not.have.class',
'cbp-has-line-numbers',
Expand All @@ -48,11 +48,11 @@ context('Line numbers', () => {
'--cbp-line-number-start',
);

cy.get('[data-cy="show-line-numbers"]')
.uncheck()
.should('exist')
.should('be.not.checked');
cy.get('[data-cy="show-line-numbers"]').check().should('be.checked');
cy.get('[data-cy="show-line-numbers"]').uncheck();
cy.get('[data-cy="show-line-numbers"]').should('exist');
cy.get('[data-cy="show-line-numbers"]').should('be.not.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');

cy.get('#code-block-pro-line-number-start').type('5');
cy.getPostContent('.wp-block[class$="code-block-pro"]')
Expand All @@ -65,14 +65,16 @@ context('Line numbers', () => {
context('Line highlights', () => {
it('Line numbers can be highlighted', () => {
cy.openSideBarPanel('Line Settings');
cy.get('[data-cy="show-line-numbers"]').check().should('be.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');
cy.addCode('line 1\nline 2\nline 3\nline 4\nline 5');

cy.get('.wp-block[class$="code-block-pro"] .cbp-line-highlight').should(
'not.exist',
);

cy.get('[data-cy="enable-highlighting"]').check().should('be.checked');
cy.get('[data-cy="enable-highlighting"]').check();
cy.get('[data-cy="enable-highlighting"]').should('be.checked');
cy.get('#code-block-pro-show-highlighted-lines').type('2');

cy.get('.wp-block[class$="code-block-pro"] .cbp-line-highlight').should(
Expand All @@ -81,7 +83,8 @@ context('Line highlights', () => {
);

// check ranges too
cy.get('#code-block-pro-show-highlighted-lines').clear().type('[2,4]');
cy.get('#code-block-pro-show-highlighted-lines').clear();
cy.get('#code-block-pro-show-highlighted-lines').type('[2,4]');

cy.getPostContent(
'.wp-block[class$="code-block-pro"] .cbp-line-highlight',
Expand All @@ -92,7 +95,8 @@ context('Line highlights', () => {
context('Line blurring', () => {
it('Line numbers can be blurred', () => {
cy.openSideBarPanel('Line Settings');
cy.get('[data-cy="show-line-numbers"]').check().should('be.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');
cy.addCode('line 1\nline 2\nline 3\nline 4\nline 5');

cy.get('.wp-block[class$="code-block-pro"] .cbp-no-blur').should(
Expand All @@ -103,7 +107,8 @@ context('Line blurring', () => {
'cbp-blur-enabled',
);

cy.get('[data-cy="enable-blur"]').check().should('be.checked');
cy.get('[data-cy="enable-blur"]').check();
cy.get('[data-cy="enable-blur"]').should('be.checked');
cy.get('#code-block-pro-show-blurred-lines').type('2');

cy.get('.wp-block[class$="code-block-pro"] .cbp-no-blur').should(
Expand All @@ -116,7 +121,8 @@ context('Line blurring', () => {
);

// check ranges too
cy.get('#code-block-pro-show-blurred-lines').clear().type('[2,4]');
cy.get('#code-block-pro-show-blurred-lines').clear();
cy.get('#code-block-pro-show-blurred-lines').type('[2,4]');

cy.getPostContent(
'.wp-block[class$="code-block-pro"] .cbp-no-blur',
Expand Down
24 changes: 12 additions & 12 deletions cypress/e2e/padding.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ context('Line numbers', () => {

cy.addCode('line 1\nline 2\nline 3');

cy.get('[data-cy="disable-padding"').check().should('be.checked');
cy.get('[data-cy="disable-padding"').check();
cy.get('[data-cy="disable-padding"').should('be.checked');

cy.getPostContent('.wp-block[class$="code-block-pro"] pre').should(
'have.css',
Expand All @@ -71,11 +72,10 @@ context('Line numbers', () => {
cy.addCode('line 1\nline 2\nline 3');

cy.openSideBarPanel('Line Settings');
cy.get('[data-cy="show-line-numbers"]')
.should('exist')
.should('be.not.checked')
.check()
.should('be.checked');
cy.get('[data-cy="show-line-numbers"]').should('exist');
cy.get('[data-cy="show-line-numbers"]').should('be.not.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');

cy.getPostContent('.wp-block[class$="code-block-pro"]')
.invoke('html')
Expand All @@ -92,15 +92,15 @@ context('Line numbers', () => {
});

it('Line numbers enabled, padding disabled', () => {
cy.get('[data-cy="disable-padding"').check().should('be.checked');
cy.get('[data-cy="disable-padding"').check();
cy.get('[data-cy="disable-padding"').should('be.checked');
cy.addCode('line 1\nline 2\nline 3');

cy.openSideBarPanel('Line Settings');
cy.get('[data-cy="show-line-numbers"]')
.should('exist')
.should('be.not.checked')
.check()
.should('be.checked');
cy.get('[data-cy="show-line-numbers"]').should('exist');
cy.get('[data-cy="show-line-numbers"]').should('be.not.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');

cy.getPostContent('.wp-block[class$="code-block-pro"]')
.invoke('html')
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/permissions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ context('Permissions', () => {
'cbp-has-line-numbers',
);

cy.get('[data-cy="show-line-numbers"]').check().should('be.checked');
cy.get('[data-cy="show-line-numbers"]').check();
cy.get('[data-cy="show-line-numbers"]').should('be.checked');
cy.getPostContent('.wp-block[class$="code-block-pro"]').should(
'not.have.class', // changed here
'cbp-has-line-numbers',
Expand Down
38 changes: 24 additions & 14 deletions cypress/e2e/styling.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ context('Styling', () => {
'aria-checked',
'false',
);
cy.get('[data-cy="font-size-select"] [aria-label="Normal"]')
.click()
.should('have.attr', 'aria-checked', 'true');
cy.get('[data-cy="font-size-select"] [aria-label="Normal"]').click();
cy.get('[data-cy="font-size-select"] [aria-label="Normal"]').should(
'have.attr',
'aria-checked',
'true',
);

cy.getPostContent('.wp-block[class$="code-block-pro"]')
.invoke('attr', 'style')
Expand All @@ -52,9 +55,12 @@ context('Styling', () => {
cy.get(
'[data-cy="font-line-height-select"] [aria-label="Normal"]',
).should('have.attr', 'aria-checked', 'false');
cy.get('[data-cy="font-line-height-select"] [aria-label="Normal"]')
.click()
.should('have.attr', 'aria-checked', 'true');
cy.get(
'[data-cy="font-line-height-select"] [aria-label="Normal"]',
).click();
cy.get(
'[data-cy="font-line-height-select"] [aria-label="Normal"]',
).should('have.attr', 'aria-checked', 'true');

cy.getPostContent('.wp-block[class$="code-block-pro"]')
.invoke('attr', 'style')
Expand All @@ -69,9 +75,11 @@ context('Styling', () => {
.invoke('attr', 'style')
.should('not.contain', 'font-family');

cy.get('#code-block-pro-font-family')
.select('Fira Code')
.should('have.value', 'Code-Pro-Fira-Code');
cy.get('#code-block-pro-font-family').select('Fira Code');
cy.get('#code-block-pro-font-family').should(
'have.value',
'Code-Pro-Fira-Code',
);

cy.previewCurrentPage();

Expand All @@ -88,11 +96,13 @@ context('Styling', () => {

cy.openSideBarPanel('Styling');

cy.get('#code-block-pro-font-family')
.select('JetBrains Mono')
.should('have.value', 'Code-Pro-JetBrains-Mono')
.select('System Default')
.should('have.value', '');
cy.get('#code-block-pro-font-family').select('JetBrains Mono');
cy.get('#code-block-pro-font-family').should(
'have.value',
'Code-Pro-JetBrains-Mono',
);
cy.get('#code-block-pro-font-family').select('System Default');
cy.get('#code-block-pro-font-family').should('have.value', '');

cy.previewCurrentPage();

Expand Down
5 changes: 2 additions & 3 deletions cypress/support/features/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ export const addCode = (code, opts) => {
cy.get('.wp-block[class$="code-block-pro"] textarea')
.should('have.focus')
.type(code, opts);
cy.get('.wp-block[class$="code-block-pro"] textarea')
.clear()
.type(code, opts);
cy.get('.wp-block[class$="code-block-pro"] textarea').clear();
cy.get('.wp-block[class$="code-block-pro"] textarea').type(code, opts);
cy.get('.wp-block[class$="code-block-pro"] textarea').should(
'have.value',
code,
Expand Down
9 changes: 4 additions & 5 deletions cypress/support/features/height.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export const setHeightDesign = (height) => {
export const enableMaxHeight = () => {
cy.openBlockSettingsSideBar();
cy.openSideBarPanel('Max Height');
cy.get('[data-cy="enable-max-height"]')
.should('exist')
.should('not.be.checked')
.check()
.should('be.checked');
cy.get('[data-cy="enable-max-height"]').should('exist');
cy.get('[data-cy="enable-max-height"]').should('not.be.checked');
cy.get('[data-cy="enable-max-height"]').check();
cy.get('[data-cy="enable-max-height"]').should('be.checked');
};
1 change: 1 addition & 0 deletions cypress/support/features/language.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const setLanguage = (language) => {
cy.openBlockSettingsSideBar();
cy.openSideBarPanel('Language');
cy.get('[data-cy-cbp="language-select"]').select(language);
cy.get('[data-cy-cbp="language-select"]')
.invoke('val')
Expand Down
Loading

0 comments on commit b5e49fe

Please sign in to comment.