Skip to content

Commit bdef7cd

Browse files
test: add dataset to dataservice test (#860)
Co-authored-by: Nicolas KEMPF <[email protected]>
1 parent 3f5f0f3 commit bdef7cd

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ jobs:
141141
- name: Run E2E tests
142142
env:
143143
BASE_URL: http://localhost:3000
144+
NUXT_PUBLIC_API_BASE: http://localhost:7000
144145
CI: true
145146
run: pnpm run test:e2e
146147

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { test, expect } from '@playwright/test'
2+
import { clickOutside } from '../helpers'
3+
4+
const API_BASE = process.env.NUXT_PUBLIC_API_BASE || 'http://dev.local:7000'
5+
6+
test('can add a dataset to an existing dataservice', async ({ page }) => {
7+
const uniqueId = Date.now()
8+
9+
// Create a dataservice via API
10+
const dataserviceResponse = await page.request.post(`${API_BASE}/api/1/dataservices/`, {
11+
data: {
12+
title: `Test API ${uniqueId}`,
13+
description: 'Une API de test pour vérifier l\'ajout de datasets',
14+
},
15+
})
16+
const dataservice = await dataserviceResponse.json()
17+
18+
// Create a dataset via API
19+
const datasetResponse = await page.request.post(`${API_BASE}/api/1/datasets/`, {
20+
data: {
21+
title: `Test dataset ${uniqueId}`,
22+
description: 'Un dataset de test à associer à l\'API',
23+
frequency: 'unknown',
24+
},
25+
})
26+
const dataset = await datasetResponse.json()
27+
28+
// Go to the dataservice admin page
29+
await page.goto(`/admin/dataservices/${dataservice.id}/datasets`)
30+
31+
// Click on the dataset select dropdown
32+
await page.getByTestId('searchable-select-rechercherunjeudedonnes').click()
33+
34+
// Type the dataset name to search
35+
await page.getByPlaceholder('Rechercher un jeu de données…').fill(`Test dataset ${uniqueId}`)
36+
await page.waitForTimeout(500)
37+
38+
// Select the dataset from the dropdown
39+
await page.getByRole('option', { name: `Test dataset ${uniqueId}` }).click()
40+
await clickOutside(page)
41+
42+
// Verify the dataset card is displayed (check for the description which is unique to the card)
43+
await expect(page.locator('text=Un dataset de test à associer à l\'API')).toBeVisible()
44+
45+
// Save the changes
46+
await page.getByRole('button', { name: 'Sauvegarder' }).click()
47+
48+
// Verify the dataset card is still visible after save (use the link in the card)
49+
await expect(page.getByRole('link', { name: `Test dataset ${uniqueId}` })).toBeVisible()
50+
51+
// Cleanup: delete the created resources
52+
await page.request.delete(`${API_BASE}/api/1/dataservices/${dataservice.id}/`)
53+
await page.request.delete(`${API_BASE}/api/1/datasets/${dataset.id}/`)
54+
})

0 commit comments

Comments
 (0)