Skip to content

Commit

Permalink
Merge branch 'master' into scripts_newsroom_meetings_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatnema authored Jul 31, 2023
2 parents 41f9a60 + 4d92a68 commit 6fcd3da
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
4 changes: 2 additions & 2 deletions components/editor/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export default function CodeBlock({
{
showCopy && (
<div className="z-10">
<button onClick={onClickCopy} className="absolute bg-code-editor-dark z-50 text-xs text-gray-500 right-2 top-1 cursor-pointer hover:text-gray-300 focus:outline-none" title="Copy to clipboard">
{showIsCopied && <span className="inline-block pl-2 pt-1 mr-2">Copied!</span>}
<button onClick={onClickCopy} className="absolute bg-code-editor-dark z-50 text-xs text-gray-500 right-2 top-1 cursor-pointer hover:text-gray-300 focus:outline-none" title="Copy to clipboard" data-test="copy-button">
{showIsCopied && <span className="inline-block pl-2 pt-1 mr-2" data-testid="clicked-text">Copied!</span>}
<span className="inline-block pt-1"><IconClipboard className="inline-block w-4 h-4 -mt-0.5" /></span>
</button>
</div>
Expand Down
30 changes: 30 additions & 0 deletions cypress/test/editor/CodeBlock.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { mount } from 'cypress/react'
import CodeBlock from '../../../components/editor/CodeBlock'

describe('CodeBlock component', () => {
beforeEach(() => {
mount(
<CodeBlock>
{ `const message = 'Hello, World!';\nconsole.log(message);` }
</CodeBlock>
)
});

it('should render correctly', () => {
cy.get('.bg-code-editor-dark').should('exist')

})
it('should copy code to clipboard when clicking the copy button', () => {
const copiedText = "const message = 'Hello, World!';\r\nconsole.log(message);"

cy.get('[data-test="copy-button"]').click({force:true})
cy.get('[data-testid="clicked-text"]').should('exist');

cy.window().then((win) => {
cy.document().then((doc) => {
cy.wrap(win.navigator.clipboard.readText()).should('eq', copiedText)
})
})
})

})
20 changes: 10 additions & 10 deletions pages/docs/tools/cli/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ npm install -g @asyncapi/cli
$ asyncapi COMMAND
running command...
$ asyncapi (--version)
@asyncapi/cli/0.51.2 linux-x64 node-v18.17.0
@asyncapi/cli/0.51.3 linux-x64 node-v18.17.0
$ asyncapi --help [COMMAND]
USAGE
$ asyncapi COMMAND
Expand Down Expand Up @@ -91,7 +91,7 @@ EXAMPLES
$ asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./asyncapi.yaml --reference-into-components
```

_See code: [src/commands/bundle.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/bundle.ts)_
_See code: [src/commands/bundle.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/bundle.ts)_

## `asyncapi config`

Expand All @@ -105,7 +105,7 @@ DESCRIPTION
CLI config settings
```

_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/config/index.ts)_
_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/config/index.ts)_

## `asyncapi config context`

Expand Down Expand Up @@ -234,7 +234,7 @@ DESCRIPTION
Convert asyncapi documents older to newer versions
```

_See code: [src/commands/convert.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/convert.ts)_
_See code: [src/commands/convert.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/convert.ts)_

## `asyncapi diff OLD NEW`

Expand Down Expand Up @@ -289,7 +289,7 @@ DESCRIPTION
Find diff between two asyncapi files
```

_See code: [src/commands/diff.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/diff.ts)_
_See code: [src/commands/diff.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/diff.ts)_

## `asyncapi generate`

Expand All @@ -303,7 +303,7 @@ DESCRIPTION
Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.
```

_See code: [src/commands/generate/index.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/generate/index.ts)_
_See code: [src/commands/generate/index.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/generate/index.ts)_

## `asyncapi generate fromTemplate ASYNCAPI TEMPLATE`

Expand Down Expand Up @@ -432,7 +432,7 @@ DESCRIPTION
Creates a new asyncapi file
```

_See code: [src/commands/new/index.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/new/index.ts)_
_See code: [src/commands/new/index.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/new/index.ts)_

## `asyncapi new file`

Expand Down Expand Up @@ -520,7 +520,7 @@ EXAMPLES
$ asyncapi optimize ./asyncapi.yaml --optimization=remove-components,reuse-components,move-to-components --output=terminal --no-tty
```

_See code: [src/commands/optimize.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/optimize.ts)_
_See code: [src/commands/optimize.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/optimize.ts)_

## `asyncapi start`

Expand All @@ -534,7 +534,7 @@ DESCRIPTION
Start asyncapi studio
```

_See code: [src/commands/start/index.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/start/index.ts)_
_See code: [src/commands/start/index.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/start/index.ts)_

## `asyncapi start studio`

Expand Down Expand Up @@ -578,5 +578,5 @@ DESCRIPTION
validate asyncapi file
```

_See code: [src/commands/validate.ts](https://github.com/asyncapi/cli/blob/v0.51.2/src/commands/validate.ts)_
_See code: [src/commands/validate.ts](https://github.com/asyncapi/cli/blob/v0.51.3/src/commands/validate.ts)_
<!-- commandsstop -->

0 comments on commit 6fcd3da

Please sign in to comment.