Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Mar 28, 2024
1 parent 466f6fb commit dc5b501
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/servers/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if (rootElement) {
service_prefix,
admin_access
} = jhData;
console.log('USING ###########', xsrf_token);
root.render(
<JupyterhubContext.Provider
value={{
Expand Down
1 change: 1 addition & 0 deletions tljh_repo2docker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async def render_template(self, name: str, **kwargs) -> str:
"""
user = await self.fetch_user()
base_url = self.settings.get("base_url", "/")
print('########## SENDING', self.xsrf_token.decode("ascii"))
template_ns = dict(
service_prefix=self.settings.get("service_prefix", "/"),
hub_prefix=self.settings.get("hub_prefix", "/"),
Expand Down
17 changes: 14 additions & 3 deletions ui-tests/tests/ui.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, Page } from '@playwright/test';
import { expect, test, Page, Cookie } from '@playwright/test';

async function login(page: Page, user: string) {
await page.goto('hub/login');
Expand Down Expand Up @@ -123,9 +123,18 @@ test.describe('tljh_repo2docker UI Tests', () => {
expect(await page.screenshot()).toMatchSnapshot('servers-dialog.png');
});

test('Start server', async ({ page }) => {
test('Start server', async ({ page, context }) => {
console.log('########### BEFORE LOGIN', await context.cookies());
await login(page, 'alice');
const cookies: Cookie[] = (await context.cookies()).filter(cookie => {
return cookie.name !== '_xsrf';
});
await context.clearCookies();
await context.addCookies(cookies);

console.log('########### AFTER LOGIN', await context.cookies());
await page.goto('/services/tljh_repo2docker/servers');
console.log('########### AFTER GOTO PAGE', await context.cookies());
await page.waitForTimeout(500);
await page.waitForSelector('div:has-text("No servers are running")', {
timeout: 1000
Expand All @@ -142,9 +151,11 @@ test.describe('tljh_repo2docker UI Tests', () => {
const createServer = await page.getByRole('button', {
name: 'Create Server'
});

await createServer.click();
await expect(createServer).toHaveCount(0);
// await page.waitForTimeout(1000);
await page.waitForURL('**/servers');
// await expect(createServer).toHaveCount(0);
await page.waitForTimeout(1000);

expect(await page.screenshot()).toMatchSnapshot('running-servers.png');
Expand Down

0 comments on commit dc5b501

Please sign in to comment.