From 686027ba81e74f2b3ee4a3a11a71fa39f6bd60b5 Mon Sep 17 00:00:00 2001 From: Rayson Yeap <88478542+Respirayson@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:52:14 +0800 Subject: [PATCH] [#13147] Didn't Account for the Timezone in Session Edit Form component tests (#13148) Update pr.yml Update pr.yml Update pr.yml --- .github/workflows/pr.yml | 64 +++++++++---------- .../session-edit-form.component.spec.ts | 6 +- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 75f339878d8..fefaf83e31c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,6 +1,6 @@ name: Pull Request Checker on: - pull_request_target: + pull_request: types: - opened - reopened @@ -10,38 +10,32 @@ on: jobs: check-pr: runs-on: ubuntu-latest - permissions: - pull-requests: write steps: - - uses: actions/github-script@v7 - with: - script: | - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number - }) - const isIssueOpen = pr.data.state.description === 'open'; - const isTitleValid = /^\[#\d+\] /.test(pr.data.title) - const isDescriptionValid = /([Ff]ix(es|ed)?|[Cc]lose(s|d)?|[Rr]esolve(s|d)?|[Pp]art [Oo]f) #\d+/.test(pr.data.body) - if (isTitleValid && isDescriptionValid && isIssueOpen) { - return - } - let body = `Hi @${pr.data.user.login}, thank you for your interest in contributing to TEAMMATES! - However, your PR does not appear to follow our [contribution guidelines](https://teammates.github.io/teammates/process.html#step-4-submit-a-pr):\n\n` - if (!isTitleValid) { - body += "- Title must start with the issue number the PR is fixing in square brackets, e.g. `[#]`\n" - } - if (!isDescriptionValid) { - body += "- Description must reference the issue number the PR is fixing, e.g. `Fixes #` (or `Part of #` if the PR does not address the issue fully)\n" - } - if (!isIssueOpen) { - body += "- The issue this PR is addressing is not open.\n" - } - body += "\nPlease address the above before we proceed to review your PR." - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body, - }) + - uses: actions/github-script@v6 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }) + const isTitleValid = /^\[#\d+\] /.test(pr.data.title) + const isDescriptionValid = /([Ff]ix(es|ed)?|[Cc]lose(s|d)?|[Rr]esolve(s|d)?|[Pp]art [Oo]f) #\d+/.test(pr.data.body) + if (isTitleValid && isDescriptionValid) { + return + } + let body = `Hi @${pr.data.user.login}, thank you for your interest in contributing to TEAMMATES! + However, your PR does not appear to follow our [contribution guidelines](https://teammates.github.io/teammates/process.html#step-4-submit-a-pr):\n\n` + if (!isTitleValid) { + body += "- Title must start with the issue number the PR is fixing in square brackets, e.g. `[#]`\n" + } + if (!isDescriptionValid) { + body += "- Description must reference the issue number the PR is fixing, e.g. `Fixes #` (or `Part of #` if the PR does not address the issue fully)\n" + } + body += "\nPlease address the above before we proceed to review your PR." + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body, + }) diff --git a/src/web/app/components/session-edit-form/session-edit-form.component.spec.ts b/src/web/app/components/session-edit-form/session-edit-form.component.spec.ts index 4be00441ab6..ab567d31db0 100644 --- a/src/web/app/components/session-edit-form/session-edit-form.component.spec.ts +++ b/src/web/app/components/session-edit-form/session-edit-form.component.spec.ts @@ -123,8 +123,10 @@ describe('SessionEditFormComponent', () => { it('should not adjust the session visibility date and time if submission opening date and time are later', () => { const date: DateFormat = component.minDateForSubmissionStart; const time: TimeFormat = component.minTimeForSubmissionStart; - component.model.customSessionVisibleDate = dateTimeService.getDateInstance(moment().subtract(1, 'days')); - component.model.customSessionVisibleTime = dateTimeService.getTimeInstance(moment().subtract(1, 'hours')); + component.model.customSessionVisibleDate = dateTimeService + .getDateInstance(moment().tz(component.model.timeZone).subtract(1, 'days')); + component.model.customSessionVisibleTime = dateTimeService + .getTimeInstance(moment().tz(component.model.timeZone).subtract(1, 'hours')); component.configureSessionVisibleDateTime(date, time); expect(component.model.customSessionVisibleDate).not.toEqual(date); expect(component.model.customSessionVisibleTime).not.toEqual(time);