skillhub/web/e2e/rejected-version-republish.spec.ts
FenjuFu 4fdc7e3dc5
Some checks are pending
Deploy Docs / build (push) Waiting to run
Deploy Docs / Deploy (push) Blocked by required conditions
Security / Dependency Review (push) Waiting to run
Security / CodeQL (java-kotlin) (push) Waiting to run
Security / CodeQL (javascript-typescript) (push) Waiting to run
Security / CodeQL (python) (push) Waiting to run
fix(publish): delete review tasks of any status when replacing a version (#601)
* fix(publish): delete review tasks of any status when replacing a version

Re-uploading a rejected version under the same version number returned
HTTP 500. deleteReplaceableVersionArtifacts only removed a PENDING review
task, but a rejected version owns a REJECTED one; that row kept a foreign
key on the skill_version, so the subsequent delete hit a constraint
violation that surfaced as a 500.

Delete every review task attached to the version instead.

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>

* test(publish): drop the spring-test dependency from the new test

skillhub-domain has no spring-test on its test classpath, so
ReflectionTestUtils does not resolve there. Use plain JDK reflection for
setting the generated id and invoking the private method.

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>

* fix(publish): constrain rejected version replacement

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* test(publish): verify replaced review is deleted

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* test(e2e): use generated API response types

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-07-28 13:57:35 +08:00

85 lines
3 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { setEnglishLocale } from './helpers/auth-fixtures'
import { loginWithCredentials, registerSession } from './helpers/session'
import { E2eTestDataBuilder } from './helpers/test-data-builder'
function getOptionalEnv(name: string): string | undefined {
const value = process.env[name]?.trim()
return value ? value : undefined
}
function adminCredentials() {
return {
username: getOptionalEnv('E2E_ADMIN_USERNAME') ?? getOptionalEnv('BOOTSTRAP_ADMIN_USERNAME') ?? 'admin',
password: getOptionalEnv('E2E_ADMIN_PASSWORD') ?? getOptionalEnv('BOOTSTRAP_ADMIN_PASSWORD') ?? 'ChangeMe!2026',
}
}
test.describe('Rejected version replacement (Real API)', () => {
test.describe.configure({ timeout: 150_000 })
test.beforeEach(async ({ page }, testInfo) => {
await setEnglishLocale(page)
await registerSession(page, testInfo)
})
test('re-publishes the same version after rejection', async ({ page, browser }, testInfo) => {
const publisherBuilder = new E2eTestDataBuilder(page, testInfo)
await publisherBuilder.init()
const adminContext = await browser.newContext()
const adminPage = await adminContext.newPage()
const adminBuilder = new E2eTestDataBuilder(adminPage, testInfo)
await loginWithCredentials(adminPage, adminCredentials(), testInfo)
await adminBuilder.init()
try {
const namespace = await publisherBuilder.ensureWritableNamespace()
const skillName = `replace-rejected-${Date.now().toString(36)}`
const firstPublish = await publisherBuilder.publishSkill(namespace.slug, {
name: skillName,
version: '1.0.0',
})
const rejectedReviewId = await adminBuilder.waitForPendingReview(
namespace.slug,
firstPublish.slug,
firstPublish.version,
)
await publisherBuilder.waitForVersionStatus(
namespace.slug,
firstPublish.slug,
firstPublish.version,
'PENDING_REVIEW',
)
await adminBuilder.rejectReview(rejectedReviewId)
const replacement = await publisherBuilder.publishSkill(namespace.slug, {
name: skillName,
description: 'Replacement after review rejection',
version: '1.0.0',
})
const replacementReviewId = await adminBuilder.waitForPendingReview(
namespace.slug,
replacement.slug,
replacement.version,
)
await publisherBuilder.waitForVersionStatus(
namespace.slug,
replacement.slug,
replacement.version,
'PENDING_REVIEW',
)
expect(replacement.skillId).toBe(firstPublish.skillId)
expect(replacement.version).toBe(firstPublish.version)
expect(replacementReviewId).not.toBe(rejectedReviewId)
const replacedReviewResponse = await adminPage.request.get(`/api/web/reviews/${rejectedReviewId}`)
expect(replacedReviewResponse.status()).toBe(404)
} finally {
await adminBuilder.cleanup()
await adminContext.close()
await publisherBuilder.cleanup()
}
})
})