Skip to content

Commit 6ddc616

Browse files
committed
feat: Add Mermaid diagrams example to use it in E2E tests
1 parent 00be6ce commit 6ddc616

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# may be useful to set it to `true`.
66
ACTIONS_STEP_DEBUG=true
77

8+
# E2E tests
9+
10+
CONFLUENCE_URL=https://confluence.tid.es
11+
CONFLUENCE_PAT=foo-access-token
12+
CONFLUENCE_README_PAGE_ID=foo-readme-page-id
13+
CONFLUENCE_CHANGELOG_PAGE_ID=foo-changelog-page-id
14+
815
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
916
# Hyphens should not be converted to underscores!
1017
INPUT_DOCS-DIR="./docs"

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,19 @@ This action syncs markdown files to Confluence using the [Markdown Confluence Sy
1010
- [Tree operation mode](#tree-operation-mode)
1111
- [Flat operation mode](#flat-operation-mode)
1212
- [Id operation mode](#id-operation-mode)
13+
- [Mermaid diagrams](#mermaid-diagrams)
1314
- [Configuration](#configuration)
1415
- [Inputs](#inputs)
1516
- [Configuration file](#configuration-file)
1617
- [Environment variables](#environment-variables)
1718
- [Contributing](#contributing)
1819
- [License](#license)
1920

20-
21-
```mermaid
22-
graph TD;
23-
A-->B;
24-
A-->C;
25-
B-->D;
26-
C-->D;
27-
E-->F;
28-
```
29-
3021
## Features
3122

3223
* It creates/updates/deletes [Confluence](https://www.atlassian.com/es/software/confluence) pages based on markdown files in a directory.
3324
* Upload images to Confluence and update links in markdown files
34-
* Supports Mermaid diagrams
25+
* Supports [Mermaid diagrams](#mermaid-diagrams)
3526
* Per-page configuration using [frontmatter metadata](https://jekyllrb.com/docs/front-matter/)
3627
* Works great with [Docusaurus](https://docusaurus.io/)
3728
* Three modes of operation:
@@ -151,6 +142,23 @@ confluence_page_id: 123456789
151142
confluence-personal-access-token: ${{ secrets.CONFLUENCE_PAT }}
152143
```
153144

145+
### Mermaid diagrams
146+
147+
Mermaid diagrams are supported in the markdown files. The action will render the diagrams as images and upload them to Confluence.
148+
149+
```markdown
150+
```mermaid
151+
graph TD;
152+
A-->B;
153+
A-->C;
154+
```
155+
156+
```mermaid
157+
graph TD;
158+
A-->B;
159+
A-->C;
160+
```
161+
154162
## Configuration
155163

156164
The action accepts a configuration file in the root of the repository, and it can be also configured using Github action inputs or even environment variables.

test/e2e/specs/check-sync.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
getChangelogPageTitle,
88
getReadmePageTitle,
99
getReadmePageChildren,
10+
getReadmePageBody,
1011
} from "../support/confluence";
1112

1213
describe("check sync", () => {
@@ -21,6 +22,13 @@ describe("check sync", () => {
2122
);
2223
});
2324

25+
it("should have rendered mermaid diagram", async () => {
26+
const pageContent = await getReadmePageBody();
27+
expect(pageContent).toEqual(expect.stringContaining('<img class="confluence-embedded-image"'));
28+
expect(pageContent).toEqual(expect.stringContaining('data-linked-resource-type="attachment"'));
29+
expect(pageContent).toEqual(expect.stringMatching(/data-linked-resource-default-alias="autogenerated-(\S)*\.svg"/));
30+
});
31+
2432
it("should have one child", async () => {
2533
const pageChildren = await getReadmePageChildren();
2634

test/e2e/support/confluence.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function getPageContent(id: string) {
3737
/**
3838
* Returns the confluence content properties of the README page
3939
*/
40-
async function getReadmePageContent() {
40+
export async function getReadmePageContent() {
4141
return getPageContent(README_PAGE_ID);
4242
}
4343

@@ -79,3 +79,11 @@ export async function getReadmePageTitle() {
7979
const content = await getReadmePageContent();
8080
return content.title;
8181
}
82+
83+
/**
84+
* Returns the title of the README page
85+
*/
86+
export async function getReadmePageBody() {
87+
const content = await getReadmePageContent();
88+
return content.body?.view?.value;
89+
}

0 commit comments

Comments
 (0)