|
1 | 1 | import { expect, test } from "@playwright/test";
|
2 | 2 | import { clientUrl, registerNewUser, LOGOUT_BUTTON_TEXT, registerDandiset } from "../utils.ts";
|
3 | 3 | import { faker } from "@faker-js/faker";
|
| 4 | +import { execSync } from "child_process"; |
4 | 5 |
|
5 | 6 | test.describe("dandiset landing page", async () => {
|
6 | 7 | test("add an owner to the dandiset", async ({ page, browser }) => {
|
@@ -40,9 +41,42 @@ test.describe("dandiset landing page", async () => {
|
40 | 41 | await expect(newPage.getByText(otherUserName)).toHaveCount(1);
|
41 | 42 | await context.close();
|
42 | 43 | });
|
| 44 | + |
43 | 45 | test("navigate to an invalid dandiset URL", async ({ page }) => {
|
44 | 46 | await page.goto(`${clientUrl}/dandiset/1`);
|
45 | 47 | await page.waitForLoadState("networkidle");
|
46 | 48 | await expect(page.getByText("Error: Dandiset does not exist")).toHaveCount(1);
|
47 | 49 | });
|
| 50 | + |
| 51 | + test("draft dandiset shows dandiset DOI", async ({ page }) => { |
| 52 | + // Register a new user and create a dandiset |
| 53 | + await registerNewUser(page); |
| 54 | + const dandisetName = faker.lorem.words(); |
| 55 | + const dandisetDescription = faker.lorem.sentences(); |
| 56 | + const dandisetId = await registerDandiset(page, dandisetName, dandisetDescription); |
| 57 | + |
| 58 | + // Inject a DOI directly using Django management command |
| 59 | + const testDoi = `10.80507/dandi.${dandisetId}`; |
| 60 | + |
| 61 | + // Execute the Django management command to inject DOI |
| 62 | + try { |
| 63 | + execSync(`cd .. && python manage.py inject_doi ${dandisetId} --dandiset-version=draft --doi="${testDoi}"`, { |
| 64 | + stdio: 'inherit', |
| 65 | + timeout: 10000 |
| 66 | + }); |
| 67 | + } catch (error) { |
| 68 | + console.error('Failed to inject DOI:', error); |
| 69 | + } |
| 70 | + |
| 71 | + // Refresh the page to see the updated DOI |
| 72 | + await page.reload(); |
| 73 | + await page.waitForLoadState("networkidle"); |
| 74 | + |
| 75 | + // The draft version should show the injected Dandiset DOI |
| 76 | + await expect(page.getByText(testDoi)).toHaveCount(1); |
| 77 | + |
| 78 | + // Should not show a version DOI (since it's a draft) |
| 79 | + const versionDoiPattern = new RegExp(`10\\.(48324|80507)/dandi\\.${dandisetId}/`); |
| 80 | + await expect(page.getByText(versionDoiPattern)).toHaveCount(0); |
| 81 | + }); |
48 | 82 | });
|
0 commit comments