Skip to content

Commit af9cd45

Browse files
committed
test: update admin panel tests organization, update url to pending items
1 parent aa1d96b commit af9cd45

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

tests/e2e/admin/admin.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
import { createTestSupabaseClient, prepDb } from '../util';
4+
5+
const supabase = createTestSupabaseClient();
6+
7+
test.beforeAll(async () => {
8+
await prepDb(supabase);
9+
});
10+
11+
test.describe('Page Access', () => {
12+
test('should redirect to /login if not logged in', async ({ page }) => {
13+
await page.goto('/admin');
14+
// Not logged in, so redirected.
15+
await page.waitForURL('/login');
16+
expect(page.url().endsWith('/login'));
17+
});
18+
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { test, expect } from '@playwright/test';
22
import { objectToSnake } from 'ts-case-convert';
33

4-
import { createTestSupabaseClient, getTestUsers, login, prepDb } from './util';
4+
import {
5+
createTestSupabaseClient,
6+
getTestUsers,
7+
login,
8+
prepDb,
9+
} from '../util';
510

611
const supabase = createTestSupabaseClient();
712
const testUsers = getTestUsers();
@@ -10,15 +15,6 @@ test.beforeAll(async () => {
1015
await prepDb(supabase);
1116
});
1217

13-
test.describe('Page Access', () => {
14-
test('should redirect to /login if not logged in', async ({ page }) => {
15-
await page.goto('/admin');
16-
// Not logged in, so redirected.
17-
await page.waitForURL('/login');
18-
expect(page.url().endsWith('/login'));
19-
});
20-
});
21-
2218
test.describe('Pending Products', () => {
2319
test('should show table of pending products', async ({ page }) => {
2420
await supabase.from('brands').insert(
@@ -27,7 +23,7 @@ test.describe('Pending Products', () => {
2723
id: 'e4e893b8-9197-4b11-82a9-88456a4c11f3',
2824
name: 'Test Brand',
2925
},
30-
].map(objectToSnake)
26+
].map(objectToSnake),
3127
);
3228

3329
await supabase.from('products').insert(
@@ -44,17 +40,17 @@ test.describe('Pending Products', () => {
4440
brandId: 'e4e893b8-9197-4b11-82a9-88456a4c11f3',
4541
sources: { sources: [{ url: 'https://example.com' }] },
4642
},
47-
].map(objectToSnake)
43+
].map(objectToSnake),
4844
);
4945

5046
await login(page, testUsers.testMaintainer1);
51-
await page.goto('/admin');
47+
await page.goto('/admin/pending');
5248

5349
await expect(
54-
page.getByRole('cell', { name: 'TestProduct1' })
50+
page.getByRole('cell', { name: 'TestProduct1' }),
5551
).toBeVisible();
5652
await expect(
57-
page.getByRole('cell', { name: 'TestProduct2' })
53+
page.getByRole('cell', { name: 'TestProduct2' }),
5854
).toBeVisible();
5955
});
6056
});

0 commit comments

Comments
 (0)