Skip to content

Commit 764f44c

Browse files
committed
fix: playwright tests
1 parent 53b1020 commit 764f44c

19 files changed

Lines changed: 253 additions & 83 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Lineage
2-
Lineage is an Obsidian plugin that allows you to edit markdown files within a [gingko-like](https://gingkowriter.com/) interface.
2+
Lineage is an Obsidian plugin that allows you to edit markdown files in a [gingko-like](https://gingkowriter.com/) interface.
33

44
![](https://raw.githubusercontent.com/ycnmhd/obsidian-lineage/docs/docs/media/screenshot.png)
55

66
## Usage
7-
To open a file, use the file context menu or the command palette.
7+
To open a file, use the file context menu or the command palette.
88
To export a file, use the view context menu.

e2e/tests/file-and-folder-menu.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createNewFolder } from '../helpers/interactions/obsidian-ui/create-new-
77
import { getTextsOfColumns } from '../helpers/getters/lineage-view/card/get-texts-of-columns';
88
import { text } from '../helpers/general/text';
99

10-
export const MI_NEW_LINEAGE_FILE = 'New lineage document';
10+
export const MI_NEW_LINEAGE_FILE = 'New document';
1111

1212
test('should create file from context menu', async () => {
1313
await closeThisTabGroup();

e2e/tests/text-area.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ test.describe('text should be saved', () => {
4444
// move card before saving
4545
await moveCardUsingHotkey('right');
4646

47+
await saveCardUsingHotkey();
4748
expect(await getTextsOfColumns()).toEqual([[n1], [n2]]);
4849
});
4950

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"id": "lineage",
33
"name": "Lineage",
4-
"version": "0.5.4",
4+
"version": "0.6.0",
55
"minAppVersion": "0.15.0",
6-
"description": "A writing interface that combines structure and content. Inspired by Gingko Writer.",
6+
"description": "A keyboard-centric hierarchical writing interface. Inspired by Gingko Writer.",
77
"author": "ycnmhd",
88
"isDesktopOnly": false
99
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lineage",
3-
"version": "0.5.4",
3+
"version": "0.6.0",
44
"description": "",
55
"scripts": {
66
"dev": "node esbuild.config.mjs",

src/lib/data-conversion/helpers/correct-headings.spec.ts

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from 'vitest';
22
import { correctHeadings } from 'src/lib/data-conversion/helpers/correct-headings';
3+
import { ginkgo_academic_paper } from 'src/lib/data-conversion/test-data/ginkgo_acedemic_paper';
34

45
// some tests are inspired from https://github.com/platers/obsidian-linter/blob/952bba9d7b6a4f084d68ffdd469bd89e785206b2/__tests__/header-increment.test.ts#L1
56
describe('correctHeadings', () => {
@@ -235,4 +236,191 @@ This is another paragraph.
235236
`;
236237
expect(correctHeadings(markdown)).toBe(expected);
237238
});
239+
240+
test('case: gingko academic paper', () => {
241+
const output = `# Title: **Statement** of your core result or finding.
242+
Try to make your title an assertive statement, such as:
243+
- "Changes in cytoplasmic volume are sufficient to drive spindle scaling."
244+
245+
and not
246+
- "High-performance silicon photoanodes passivated with ultrathin nickel films for water oxidation"
247+
248+
Rule of thumb: if your title would look weird with a period at the end, it is probably a poor title.
249+
250+
Don't do [this](http://www.phdcomics.com/comics/archive/phd053106s.gif).
251+
252+
# Abstract
253+
Try to tell a *story* here, no matter what your field. You are writing for human beings, not computers. What's the area, what's the problem you are trying to understand. How? What have you found?
254+
255+
(You are *summarizing* your core results, not *cramming* them into this tiny space).
256+
257+
---
258+
## target: 84-151 words
259+
## current: 43 ![](https://dl.dropboxusercontent.com/s/6k720i6vkig7siq/cross_circle.png)
260+
261+
<!-- URL for checkmark: https://dl.dropboxusercontent.com/s/elo7ckzspvxvx0t/checkmark.gif -->
262+
263+
## (This is a word count footer. We don't have automatic word counts yet, so I use is [this Chrome extension](https://chrome.google.com/webstore/detail/word-count/pnngehidikgomgfjbpffonkeimgbpjlh))
264+
265+
## Introduction - "The Setup"
266+
### [In field X, we still don't understand Y & Z.]
267+
268+
Write a summary of *the question(s) you are trying to answer*.
269+
What is the state of the world before your research came along?
270+
Also, answer the harsh but important question: *Who cares*?
271+
272+
In writing this, you can start general, but make sure clearly define the "before" state of the world's knowledge for the *specific area* this paper is addressing.
273+
274+
### Intro - Assertive Statement 1
275+
276+
Here you can expand on your introduction. To guide your writing, title this card with assertive statements:
277+
Instead of "Problem Description", be direct: "The problem is that X doesn't do Y."
278+
279+
# Introduction
280+
281+
[You can write your actual paper here in this column. Then choosing "Export column 5" to Word or Markdown will help you move it to your final platform.]
282+
283+
You can keep notes & comments here.
284+
285+
...
286+
287+
...
288+
289+
## Intro - Assertive Statement 2
290+
291+
...
292+
293+
...
294+
295+
## Intro - Assertive Statement 3
296+
297+
...
298+
299+
...
300+
301+
## Materials & Methods - "The Characters"
302+
### [We have here method A, B, and our new method C.]
303+
You have established the core question(s) of your research. Now introduce the tools you are going to use to understand it.
304+
305+
## Method A
306+
More details on the method, experiment design, etc.
307+
308+
Remember that these are cards, so you can drag and drop them to rearrange if necessary.
309+
310+
# Methods
311+
312+
## Method A
313+
314+
Some other note. For example:
315+
316+
#Xusheng , make sure you include the voltage you used."
317+
318+
(the # syntax makes it easier to search for & filter comments directed at a specific person).
319+
320+
...
321+
322+
...
323+
324+
## Method B
325+
More details on the method, experiment design, etc.
326+
327+
### Method B...
328+
329+
...
330+
331+
...
332+
333+
## Method C
334+
More details on the method, experiment design, etc.
335+
336+
If you need a checklist to make sure you address all points, go ahead:
337+
[ ] e.g. "Mention pH of the setup"
338+
[ ] What temperature?
339+
[ ] For how long?
340+
341+
### Method C
342+
343+
...
344+
345+
...
346+
347+
## Results
348+
What happened (objectively)?
349+
350+
Do not interpret, simply state the facts.
351+
352+
Let's be honest: the first thing most of us do when skimming a paper is look at the figures. If your key results can be presented in figures, then start with that, and structure your paper around that.
353+
354+
## Key Result
355+
You can add figures if you'd like:
356+
357+
![](https://dl.dropboxusercontent.com/s/gieldum0s47m25v/1-plot.jpg)
358+
359+
# Results
360+
361+
Final text for results goes here
362+
363+
...
364+
365+
...
366+
367+
Remember these are **cards** so you can rearrange your results at will.
368+
Any subcards will follow.
369+
370+
Other results
371+
372+
## Discussion
373+
Results are objective, but science isn't about listing data, it's about extracting meaning from what we observe.
374+
375+
What do your results tell you about the core problem you were investigating?
376+
377+
## Conclusion
378+
Bring it back to the big picture. How do your results fit into the current body of knowledge?
379+
380+
Most importantly, how can these results help you [ask better questions](http://www.youtube.com/watch?v=nq0_zGzSc8g#t=493)?
381+
382+
## Conclusion (further detail)
383+
384+
Expand on your conclusion summary, and add more details to it.
385+
386+
# Conclusion
387+
388+
Final text for conclusion goes here
389+
390+
in as many
391+
392+
cards as you like.
393+
394+
## References
395+
We don't have bibliography support yet, but we do have "named links" so you can refer to specific links by name rather than retyping it each time.
396+
397+
"Black holes are cool." [[1]][prl2010], and DNA is cool too [[2]][dnaRef]. But black holes are still cool, though not "absolute zero" cool [[1]][prl2010].
398+
399+
[prl2010]: http://arxiv.org/abs/1311.3007
400+
[dnaRef]: http://biorxiv.org/content/early/2013/11/07/000026
401+
402+
## List
403+
Or you can simply list your references here:
404+
405+
1. some ref
406+
1. some other ref. Numbering fixes itself automatically.
407+
2. A third ref.
408+
409+
# References
410+
411+
Some reference by J. Doe
412+
413+
Notes on this reference.
414+
415+
Some other reference
416+
417+
## How to use this template
418+
The idea here is to start at the far left, and clarify what the core of what you want to say is *first*, and then expand on it by moving to the right, one column at a time.
419+
420+
After a couple of "passes" of expanding, you will end up with your complete, and well structured paper on column 5, which you can export separately.
421+
422+
Here's a (somewhat dated) video which might help.
423+
<iframe width="256" height="144" src="//www.youtube.com/embed/J4prcx0jZ9M?rel=0" frameborder="0" allowfullscreen></iframe>`;
424+
expect(correctHeadings(ginkgo_academic_paper.md)).toBe(output);
425+
});
238426
});

src/lib/data-conversion/helpers/correct-headings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export const correctHeadings = (markdown: string): string => {
4747
correctedLevel = parent.correctedLevel + 1;
4848
}
4949
}
50+
} else if (level === state.previousLevel) {
51+
correctedLevel = state.previousCorrectedLevel;
5052
} else {
5153
correctedLevel = level;
5254
}

src/lib/format-detection/has-n-heading.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,11 @@ Some text.`;
4646
const input = `# Heading 1 ## Heading 2`;
4747
expect(hasNHeadings(input)).toBe(false);
4848
});
49+
50+
it('should return true if the heading is in an outline', () => {
51+
const input = `- # Heading 1
52+
This is some text.
53+
\t- ## Heading 2`;
54+
expect(hasNHeadings(input)).toBe(true);
55+
});
4956
});

src/lib/format-detection/has-n-headings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const hasNHeadings = (input: string, n = 2): boolean => {
22
const lines = input.split('\n');
33
let count = 0;
44
for (const line of lines) {
5-
if (/^#+ +/.test(line)) {
5+
if (/^((\t*)- )?#+ +/.test(line)) {
66
count++;
77
if (count >= n) return true;
88
}

src/obsidian/commands/helpers/export-document/export-document.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
import { TFile } from 'obsidian';
21
import { createNewFile } from 'src/obsidian/events/workspace/effects/create-new-file';
3-
import Lineage from 'src/main';
42
import { openFile } from 'src/obsidian/events/workspace/effects/open-file';
53
import { onPluginError } from 'src/lib/store/on-plugin-error';
64
import { prepareExportedDocument } from 'src/obsidian/commands/helpers/export-document/prepare-exported-document';
5+
import { getDocumentFormat } from 'src/obsidian/events/workspace/helpers/get-document-format';
6+
import { LineageView } from 'src/view/view';
77

8-
export type ExportMode = 'markdown' | 'outline';
9-
export const exportDocument = async (
10-
plugin: Lineage,
11-
file: TFile,
12-
mode: ExportMode,
13-
) => {
8+
export const exportDocument = async (view: LineageView) => {
149
try {
10+
const file = view.file;
11+
if (!file) return;
1512
if (!file.parent) return;
16-
const fileData = await plugin.app.vault.read(file);
17-
const output = prepareExportedDocument(fileData, file.basename, mode);
13+
const fileData = await view.plugin.app.vault.read(file);
14+
const format = getDocumentFormat(view);
15+
const output = prepareExportedDocument(fileData, file.basename, format);
1816
const newFile = await createNewFile(
19-
plugin,
17+
view.plugin,
2018
file.parent,
2119
output,
2220
file.basename,
2321
);
2422
if (newFile) {
25-
await openFile(plugin, newFile, 'split');
23+
await openFile(view.plugin, newFile, 'split');
2624
}
2725
} catch (e) {
2826
onPluginError(e, 'command', { type: 'export-document' });

0 commit comments

Comments
 (0)