Skip to content

Commit 1baf07a

Browse files
Pollepsjoepio
authored andcommitted
#288 Add folder test
1 parent 05153ca commit 1baf07a

File tree

8 files changed

+40
-12
lines changed

8 files changed

+40
-12
lines changed

data-browser/src/components/EditableTitle.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ export function EditableTitle({
5757
onChange={e => setText(e.target.value)}
5858
value={text || ''}
5959
onBlur={() => setIsEditing(false)}
60-
style={{ visibility: isEditing ? 'visible' : 'hidden' }}
6160
/>
6261
) : (
6362
<Title
6463
canEdit={!!canEdit}
6564
title={canEdit ? 'Edit title' : 'View title'}
6665
data-test='editable-title'
6766
onClick={handleClick}
68-
style={{ display: isEditing ? 'hidden' : 'visible' }}
6967
subtle={!!canEdit && !text}
7068
>
7169
<>

data-browser/src/components/NewInstanceButton/useDefaultNewInstanceHandler.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function useDefaultNewInstanceHandler(klass: string, parent?: string) {
3434
case classes.document: {
3535
createResourceAndNavigate('documents', {
3636
[properties.isA]: [classes.document],
37+
[properties.name]: 'Untitled Document',
3738
});
3839
break;
3940
}

data-browser/src/views/BookmarkPage/BookmarkPage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export function BookmarkPage({ resource }: ResourcePageProps): JSX.Element {
3232
<>
3333
<Wrapper>
3434
<ContainerFull>
35-
<EditableTitle
36-
resource={resource}
37-
propertyURL={urls.properties.name}
38-
/>
35+
<EditableTitle resource={resource} />
3936
</ContainerFull>
4037
<ControlWrapper>
4138
<ContainerFull>

data-browser/src/views/FolderPage/ListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function ListView({
2121
}: ViewProps): JSX.Element {
2222
return (
2323
<Wrapper>
24-
<StyledTable>
24+
<StyledTable data-test='folder-list'>
2525
<>
2626
<thead>
2727
<tr>

data-browser/tests/e2e.spec.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,39 @@ test.describe('data-browser', async () => {
327327
const input = page.locator('[placeholder="https\\:\\/\\/example\\.com"]');
328328
await input.click();
329329
await input.fill('https://example.com');
330-
await page.locator('footer >> text=Ok').click();
330+
await page.locator('dialog[open] >> footer >> text=Ok').click();
331331

332332
await expect(page.locator('text=This domain is ')).toBeVisible();
333333
});
334334

335+
test('folder', async ({ page }) => {
336+
await signIn(page);
337+
await newDrive(page);
338+
339+
// Create a new folder
340+
await newResource('folder', page);
341+
342+
// Fetch `example.com
343+
const input = page.locator('[placeholder="New Folder"]');
344+
await input.click();
345+
await input.fill('RAM Downloads');
346+
await page.locator('dialog[open] >> footer >> text=Ok').click();
347+
348+
await expect(page.locator('h1:text("Ram Downloads")')).toBeVisible();
349+
350+
await page.click('text=New Resource');
351+
await page.click('button:has-text("Document")');
352+
await page.locator(editableTitle).click();
353+
await page.keyboard.type('RAM Downloading Strategies');
354+
await page.keyboard.press('Enter');
355+
await page.click('[data-test="sidebar"] >> text=RAM Downloads');
356+
await expect(
357+
page.locator(
358+
'[data-test="folder-list"] >> text=RAM Downloading Strategies',
359+
),
360+
).toBeVisible();
361+
});
362+
335363
test('drive switcher', async ({ page }) => {
336364
await signIn(page);
337365
await page.locator(`${currentDriveTitle} > text=localhost`);

lib/src/value.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function valToNumber(val?: JSONValue): number {
6363
/** Returns a default string representation of the value. */
6464
export function valToString(val: JSONValue): string {
6565
// val && val.toString();
66-
return val?.toString() || 'undefined';
66+
return val?.toString() ?? 'undefined';
6767
}
6868

6969
/** Returns either the URL of the resource, or the NestedResource itself. */

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"data-browser"
5252
]
5353
},
54-
"packageManager": "pnpm@7.11.0",
54+
"packageManager": "pnpm@7.13.3",
5555
"dependencies": {
5656
"eslint-plugin-import": "^2.26.0"
5757
}

react/src/hooks.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export function useValue(
275275
async function setAsync() {
276276
try {
277277
await resource.set(propertyURL, newVal, store, validate);
278-
handleValidationError && handleValidationError(undefined);
278+
handleValidationError?.(undefined);
279279
// Clone resource to force hooks to re-evaluate due to shallow comparison.
280280
store.notify(resource.clone());
281281
} catch (e) {
@@ -330,7 +330,11 @@ export function useString(
330330
): [string | undefined, (string: string | undefined) => Promise<void>] {
331331
const [val, setVal] = useValue(resource, propertyURL, opts);
332332

333-
if (!val) {
333+
if (typeof val === 'string') {
334+
return [val, setVal];
335+
}
336+
337+
if (val === undefined) {
334338
return [undefined, setVal];
335339
}
336340

0 commit comments

Comments
 (0)