Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Apr 12, 2024
1 parent e60b7c7 commit 5b75c19
Showing 1 changed file with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,7 @@ test.describe('#chatPanel', () => {
test('should contain the chat panel icon', async ({ page }) => {
const chatIcon = page.getByTitle('Jupyter Chat');
expect(chatIcon).toHaveCount(1);
expect(await chatIcon.screenshot()).toMatchSnapshot(
'chat_icon.png'
);
expect(await chatIcon.screenshot()).toMatchSnapshot('chat_icon.png');
});

test('chat panel should contain a toolbar', async ({ page }) => {
Expand All @@ -376,7 +374,7 @@ test.describe('#chatPanel', () => {
const content = panel.locator('.jp-SidePanel-content');
await expect(content).toBeEmpty();
});
})
});

test.describe('#chatCreation', () => {
const name = 'my-chat';
Expand All @@ -394,7 +392,7 @@ test.describe('#chatPanel', () => {
await dialog.waitFor();
});

test.afterEach(async ({ page })=> {
test.afterEach(async ({ page }) => {
for (let filename of ['untitled.chat', `${name}.chat`]) {
if (await page.filebrowser.contents.fileExists(filename)) {
await page.filebrowser.contents.deleteFile(filename);
Expand All @@ -409,45 +407,57 @@ test.describe('#chatPanel', () => {
async () => await page.filebrowser.contents.fileExists(`${name}.chat`)
);

const chatTitle = panel.locator('.jp-SidePanel-content .jp-AccordionPanel-title');
await expect(chatTitle).toHaveCount(1);
await expect(chatTitle.locator('.lm-AccordionPanel-titleLabel')).toHaveText(
name
const chatTitle = panel.locator(
'.jp-SidePanel-content .jp-AccordionPanel-title'
);
await expect(chatTitle).toHaveCount(1);
await expect(
chatTitle.locator('.lm-AccordionPanel-titleLabel')
).toHaveText(name);
});

test('should create an untitled file if no name is provided', async ({ page }) => {
test('should create an untitled file if no name is provided', async ({
page
}) => {
await dialog.getByRole('button').getByText('Ok').click();
await page.waitForCondition(
async () => await page.filebrowser.contents.fileExists('untitled.chat')
);

const chatTitle = panel.locator('.jp-SidePanel-content .jp-AccordionPanel-title');
await expect(chatTitle).toHaveCount(1);
await expect(chatTitle.locator('.lm-AccordionPanel-titleLabel')).toHaveText(
'untitled'
const chatTitle = panel.locator(
'.jp-SidePanel-content .jp-AccordionPanel-title'
);
await expect(chatTitle).toHaveCount(1);
await expect(
chatTitle.locator('.lm-AccordionPanel-titleLabel')
).toHaveText('untitled');
});

test('should not create a chat if dialog is cancelled', async ({ page }) => {
test('should not create a chat if dialog is cancelled', async ({
page
}) => {
await dialog.getByRole('button').getByText('Cancel').click();

const content = panel.locator('.jp-SidePanel-content');
await expect(content).toBeEmpty();
});
})
});

test.describe('#openingClosing', () => {
const name = 'my-chat';
let panel: Locator;
let select: Locator;

test.beforeEach(async ({ page }) => {
await page.filebrowser.contents.uploadContent('{}', 'text', `${name}.chat`);
await page.filebrowser.contents.uploadContent(
'{}',
'text',
`${name}.chat`
);
});

test.afterEach(async ({ page }) => {
await page.filebrowser.contents.deleteFile( `${name}.chat`);
await page.filebrowser.contents.deleteFile(`${name}.chat`);
});

test('should list existing chat', async ({ page }) => {
Expand All @@ -459,7 +469,7 @@ test.describe('#chatPanel', () => {
'.jp-SidePanel-toolbar .jp-Toolbar-item.jp-collab-chat-open select'
);

for (let i=0; i< await select.locator('option').count(); i++) {
for (let i = 0; i < (await select.locator('option').count()); i++) {
console.log(await select.locator('option').nth(i).textContent());
}
await expect(select.locator('option')).toHaveCount(2);
Expand All @@ -477,11 +487,13 @@ test.describe('#chatPanel', () => {

await select.selectOption(name);

const chatTitle = panel.locator('.jp-SidePanel-content .jp-AccordionPanel-title');
await expect(chatTitle).toHaveCount(1);
await expect(chatTitle.locator('.lm-AccordionPanel-titleLabel')).toHaveText(
name
const chatTitle = panel.locator(
'.jp-SidePanel-content .jp-AccordionPanel-title'
);
await expect(chatTitle).toHaveCount(1);
await expect(
chatTitle.locator('.lm-AccordionPanel-titleLabel')
).toHaveText(name);

await chatTitle.getByRole('button').click();
await expect(chatTitle).toHaveCount(0);
Expand Down

0 comments on commit 5b75c19

Please sign in to comment.