Skip to content

Commit bc73500

Browse files
committed
Fix tests
1 parent eb78ae4 commit bc73500

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

data-browser/tests/e2e.spec.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ const currentDialogOkButton = 'dialog[open] >> footer >> text=Ok';
3838
// Depends on server index throttle time, `commit_monitor.rs`
3939
const REBUILD_INDEX_TIME = 6000;
4040

41+
async function setTitle(page, title: string) {
42+
await page.locator(editableTitle).click();
43+
await page.fill(editableTitle, title);
44+
await page.waitForTimeout(300);
45+
}
46+
4147
test.describe('data-browser', async () => {
4248
test.beforeEach(async ({ page }) => {
4349
if (!serverUrl) {
@@ -125,8 +131,7 @@ test.describe('data-browser', async () => {
125131
// Create folder called 'Not This folder'
126132
await page.locator('[data-test="sidebar-new-resource"]').click();
127133
await page.locator('button:has-text("folder")').click();
128-
await page.locator('[placeholder="New Folder"]').fill('Not This Folder');
129-
await page.locator(currentDialogOkButton).click();
134+
await setTitle(page, 'Not This Folder');
130135

131136
// Create document called 'Avocado Salad'
132137
await page.locator('button:has-text("New Resource")').click();
@@ -140,8 +145,7 @@ test.describe('data-browser', async () => {
140145

141146
// Create folder called 'This folder'
142147
await page.locator('button:has-text("folder")').click();
143-
await page.locator('[placeholder="New Folder"]').fill('This Folder');
144-
await page.locator(currentDialogOkButton).click();
148+
await setTitle(page, 'This Folder');
145149

146150
// Create document called 'Avocado Salad'
147151
await page.locator('button:has-text("New Resource")').click();
@@ -437,7 +441,7 @@ test.describe('data-browser', async () => {
437441
test('configure drive page', async ({ page }) => {
438442
await signIn(page);
439443
await openDriveMenu(page);
440-
await expect(page.locator(currentDriveTitle)).toHaveText('Main drive');
444+
await expect(page.locator(currentDriveTitle)).toHaveText('localhost');
441445

442446
// temp disable this, because of trailing slash in base URL
443447
// await page.click(':text("https://atomicdata.dev") + button:text("Select")');
@@ -494,31 +498,20 @@ test.describe('data-browser', async () => {
494498
await newDrive(page);
495499

496500
// create a resource, make sure its visible in the sidebar (and after refresh)
497-
const klass = 'importer';
501+
const klass = 'folder';
498502
await newResource(klass, page);
499503
await expect(
500-
page.locator('[data-test="sidebar"] >> text=importer'),
504+
page.locator(`[data-test="sidebar"] >> text=${klass}`),
501505
).toBeVisible();
502-
// await page.reload();
503-
// await expect(
504-
// page.locator('[data-test="sidebar"] >> text=importer'),
505-
// ).toBeVisible();
506-
507-
async function setTitle(title: string) {
508-
await page.locator(editableTitle).click();
509-
await page.fill(editableTitle, title);
510-
await page.waitForTimeout(300);
511-
}
512-
513506
const d0 = 'depth0';
514-
await setTitle(d0);
507+
await setTitle(page, d0);
515508

516509
// Create a subresource, and later check it in the sidebar
517510
await page.locator(`[data-test="sidebar"] >> text=${d0}`).hover();
518511
await page.locator(`[title="Create new resource under ${d0}"]`).click();
519512
await page.click(`button:has-text("${klass}")`);
520513
const d1 = 'depth1';
521-
await setTitle(d1);
514+
await setTitle(page, d1);
522515

523516
await expect(
524517
page.locator(`[data-test="sidebar"] >> text=${d1}`),

lib/src/authentication.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ const setCookieExpires = (
9595
const COOKIE_NAME_AUTH = 'atomic_session';
9696

9797
/** Sets a cookie for the current Agent, signing the Authentication. It expires after some default time. */
98-
export const setCookieAuthentication = (store: Store, agent: Agent) => {
99-
const serverURL = store.getServerUrl();
98+
export const setCookieAuthentication = (serverURL: string, agent: Agent) => {
10099
createAuthentication(serverURL, agent).then(auth => {
101100
setCookieExpires(COOKIE_NAME_AUTH, btoa(JSON.stringify(auth)), serverURL);
102101
});

0 commit comments

Comments
 (0)