-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Widget: Create skeleton of graph view (#154)
* Center widget on page * Add widget header, dimensions, and background * Use Playwright component tests instead of E2E tests, so we can pass in custom props to our component per-test. For now we're using the library @sand4rt/experimental-ct-web to get a mount() function for Lit components, because the Playwright team hasn't yet added native support for Lit components.
- Loading branch information
1 parent
67c1cb2
commit 9436112
Showing
16 changed files
with
486 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
semi: false, | ||
semi: true, | ||
trailingComma: 'all', | ||
singleQuote: true, | ||
quoteProps: 'as-needed', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + Lit + TS</title> | ||
<link rel="stylesheet" href="./src/index.css" /> | ||
<script type="module" src="/src/docmaps-widget.ts"></script> | ||
</head> | ||
<body> | ||
<docmaps-widget> | ||
</docmaps-widget> | ||
</body> | ||
<html lang='en'> | ||
<head> | ||
<meta charset='UTF-8' /> | ||
<link rel='icon' type='image/svg+xml' href='/vite.svg' /> | ||
<meta name='viewport' content='width=device-width, initial-scale=1.0' /> | ||
<title>Vite + Lit + TS</title> | ||
<link rel='stylesheet' href='./src/index.css' /> | ||
<script type='module' src='/src/docmaps-widget.ts'></script> | ||
</head> | ||
<body> | ||
<docmaps-widget></docmaps-widget> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Testing Page</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./index.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Import styles, initialize component theme here. | ||
// import '../src/common.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { svg } from 'lit' | ||
|
||
export const logo = svg` | ||
<svg class="docmap-logo" width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'> | ||
<path fill-rule='evenodd' clip-rule='evenodd' d='M3.78445 0.521739H1.28598C0.859842 0.521739 0.514391 0.872125 0.514391 1.30435V3.83851C0.514391 4.27073 0.859842 4.62112 1.28598 4.62112H3.78445C4.21058 4.62112 4.55603 4.27073 4.55603 3.83851V1.30435C4.55603 0.872125 4.21058 0.521739 3.78445 0.521739ZM1.28598 0C0.575752 0 0 0.583976 0 1.30435V3.83851C0 4.55888 0.575751 5.14286 1.28598 5.14286H3.78445C4.49467 5.14286 5.07043 4.55888 5.07043 3.83851V1.30435C5.07043 0.583977 4.49467 0 3.78445 0H1.28598Z' fill='white'/> | ||
<path d='M0 9.42857C0 8.00841 1.13505 6.85714 2.53521 6.85714C3.93537 6.85714 5.07043 8.00841 5.07043 9.42857C5.07043 10.8487 3.93537 12 2.53521 12C1.13505 12 0 10.8487 0 9.42857Z' fill='white'/> | ||
<path d='M6.92957 8.16149C6.92957 7.44112 7.50533 6.85714 8.21555 6.85714H10.714C11.4242 6.85714 12 7.44112 12 8.16149V10.6957C12 11.416 11.4242 12 10.714 12H8.21555C7.50533 12 6.92957 11.416 6.92957 10.6957V8.16149Z' fill='white'/> | ||
<path d='M0 9.42857C0 8.00841 1.13505 6.85714 2.53521 6.85714C3.93537 6.85714 5.07043 8.00841 5.07043 9.42857C5.07043 10.8487 3.93537 12 2.53521 12C1.13505 12 0 10.8487 0 9.42857Z' fill='white'/> | ||
<path d='M6.92957 8.16149C6.92957 7.44112 7.50533 6.85714 8.21555 6.85714H10.714C11.4242 6.85714 12 7.44112 12 8.16149V10.6957C12 11.416 11.4242 12 10.714 12H8.21555C7.50533 12 6.92957 11.416 6.92957 10.6957V8.16149Z' fill='white'/> | ||
</svg> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect, MountOptions, test } from '@sand4rt/experimental-ct-web' | ||
import { DocmapsWidget } from '../src' | ||
import { Locator } from '@playwright/test' | ||
import { JsonObject } from '@playwright/experimental-ct-core/types/component' | ||
|
||
const options: MountOptions<JsonObject, DocmapsWidget> = { | ||
props: { doi: 'test-doi' }, | ||
} | ||
|
||
const dois = ['doi-1', 'doi-2'] | ||
for (const doi of dois) { | ||
test(`It renders the DOI: ${doi}`, async ({ mount }) => { | ||
const widget: Locator = await mount(DocmapsWidget, { props: { doi } }) | ||
await expect(widget).toContainText(doi) | ||
}) | ||
} | ||
|
||
test('The header bar is displayed in the graph view', async ({ mount }) => { | ||
const widget: Locator = await mount(DocmapsWidget, options) | ||
await expect(widget.locator('.widget-header')).toContainText('DOCMAP') | ||
}) | ||
|
||
test('Clicking button increments the count', async ({ mount }) => { | ||
const widget: Locator = await mount(DocmapsWidget, options) | ||
await expect(widget.locator('circle')).toHaveCount(3) | ||
await expect( | ||
widget.getByRole('button', { name: 'Add 4th Node' }), | ||
).toBeVisible() | ||
|
||
await widget.getByRole('button', { name: 'Add 4th Node' }).click() | ||
|
||
await expect( | ||
widget.getByRole('button', { name: 'Add 5th Node' }), | ||
).toBeVisible() | ||
await expect(widget.locator('circle')).toHaveCount(4) | ||
}) |
Oops, something went wrong.