From cf9ac4447aee06259acd43786c7f6e20dcd08681 Mon Sep 17 00:00:00 2001 From: William Martin Date: Mon, 31 Mar 2025 14:06:24 +0200 Subject: [PATCH] Acceptance test issue/pr create/edit with project --- .../issue-create-edit-with-project.txtar | 43 ++++++++++++++++ .../pr/pr-create-edit-with-project.txtar | 51 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 acceptance/testdata/issue/issue-create-edit-with-project.txtar create mode 100644 acceptance/testdata/pr/pr-create-edit-with-project.txtar diff --git a/acceptance/testdata/issue/issue-create-edit-with-project.txtar b/acceptance/testdata/issue/issue-create-edit-with-project.txtar new file mode 100644 index 000000000..568530cb9 --- /dev/null +++ b/acceptance/testdata/issue/issue-create-edit-with-project.txtar @@ -0,0 +1,43 @@ +env REPO=${SCRIPT_NAME}-${RANDOM_STRING} + +# Create a repository with a file so it has a default branch +exec gh repo create ${ORG}/${REPO} --add-readme --private + +# Defer repo cleanup +defer gh repo delete --yes ${ORG}/${REPO} + +# Create a project +env PROJECT_TITLE=${REPO}-project +exec gh project create --owner=${ORG} --title=${PROJECT_TITLE} --format='json' --jq='.number' +stdout2env PROJECT_NUMBER + +defer gh project delete --owner=${ORG} ${PROJECT_NUMBER} + +# Clone the repo +exec gh repo clone ${ORG}/${REPO} + +# Create an issue in the repo +cd ${REPO} +exec gh issue create --title 'Feature Request' --body 'Feature Body' --project ${PROJECT_TITLE} +stdout2env ISSUE_URL + +# Check that default issue view is working +exec gh issue view ${ISSUE_URL} + +# Check the issue was added to the project +exec gh issue view ${ISSUE_URL} --json projectItems --jq '.projectItems[0].title' +stdout ${PROJECT_TITLE} + +# Remove the issue from the project +exec gh issue edit ${ISSUE_URL} --remove-project ${PROJECT_TITLE} + +# Check the issue was removed from the project +exec gh issue view ${ISSUE_URL} --json projectItems --jq '.projectItems[0].title' +! stdout ${PROJECT_TITLE} + +# Re add the issue to the project +exec gh issue edit ${ISSUE_URL} --add-project ${PROJECT_TITLE} + +# Check the issue was added to the project +exec gh issue view ${ISSUE_URL} --json projectItems --jq '.projectItems[0].title' +stdout ${PROJECT_TITLE} diff --git a/acceptance/testdata/pr/pr-create-edit-with-project.txtar b/acceptance/testdata/pr/pr-create-edit-with-project.txtar new file mode 100644 index 000000000..9850313f0 --- /dev/null +++ b/acceptance/testdata/pr/pr-create-edit-with-project.txtar @@ -0,0 +1,51 @@ +# Use gh as a credential helper +exec gh auth setup-git + +env REPO=${SCRIPT_NAME}-${RANDOM_STRING} + +# Create a repository with a file so it has a default branch +exec gh repo create ${ORG}/${REPO} --add-readme --private + +# Defer repo cleanup +defer gh repo delete --yes ${ORG}/${REPO} + +# Create a project +env PROJECT_TITLE=${REPO}-project +exec gh project create --owner=${ORG} --title=${PROJECT_TITLE} --format='json' --jq='.number' +stdout2env PROJECT_NUMBER + +defer gh project delete --owner=${ORG} ${PROJECT_NUMBER} + +# Clone the repo +exec gh repo clone ${ORG}/${REPO} + +# Prepare a branch to PR +cd ${REPO} +exec git checkout -b feature-branch +exec git commit --allow-empty -m 'Empty Commit' +exec git push -u origin feature-branch + +# Create the PR +exec gh pr create --title 'Feature Title' --body 'Feature Body' --project ${PROJECT_TITLE} +stdout2env PR_URL + +# Check that default pr view is working +exec gh pr view ${PR_URL} + +# Check the pr was added to the project +exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title' +stdout ${PROJECT_TITLE} + +# Remove the pr from the project +exec gh pr edit ${PR_URL} --remove-project ${PROJECT_TITLE} + +# Check the pr was removed from the project +exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title' +! stdout ${PROJECT_TITLE} + +# Re add the pr to the project +exec gh pr edit ${PR_URL} --add-project ${PROJECT_TITLE} + +# Check the pr was added to the project +exec gh pr view ${PR_URL} --json projectItems --jq '.projectItems[0].title' +stdout ${PROJECT_TITLE}