Skip to content

Commit

Permalink
TSK-1047: Fix showing requests after moving staff to another departme…
Browse files Browse the repository at this point in the history
…nt (#3029)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
  • Loading branch information
ThetaDR authored Apr 21, 2023
1 parent 76e7171 commit 67d361d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugins/hr-resources/src/components/ScheduleView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
: getEndDate(currentDate.getFullYear(), currentDate.getMonth())
$: departments = [department, ...getDescendants(department, descendants)]
$: staffIdsForOpenedDepartments = staff.filter((p) => departments.includes(p.department)).map((p) => p._id)
const lq = createQuery()
const typeQuery = createQuery()
Expand Down Expand Up @@ -90,24 +91,24 @@
let departmentStaff: Staff[]
let editableList: Ref<Employee>[] = []
function update (departments: Ref<Department>[], startDate: Date, endDate: Date) {
function update (staffIdsForOpenedDepartments: Ref<Staff>[], startDate: Date, endDate: Date) {
lq.query(
hr.class.Request,
{
'tzDueDate.year': { $gte: startDate.getFullYear() },
'tzDate.year': { $lte: endDate.getFullYear() },
space: { $in: departments }
attachedTo: { $in: staffIdsForOpenedDepartments }
},
(res) => {
requests = res
}
)
}
$: update(departments, startDate, endDate)
$: update(staffIdsForOpenedDepartments, startDate, endDate)
function updateRequest (reqests: Request[], startDate: Date, endDate: Date) {
const res = reqests.filter(
function updateRequest (requests: Request[], startDate: Date, endDate: Date) {
const res = requests.filter(
(r) => fromTzDate(r.tzDueDate) >= startDate.getTime() && fromTzDate(r.tzDate) <= endDate.getTime()
)
employeeRequests.clear()
Expand Down
76 changes: 76 additions & 0 deletions tests/sanity/tests/hr.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { expect, Page, test } from '@playwright/test'
import { PlatformSetting, PlatformURI } from './utils'

test.use({
storageState: PlatformSetting
})

export async function createDepartment (page: Page, departmentName: string): Promise<void> {
await page.click('text=Structure Department Organization no employees >> button >> nth=1')
const departmentNameField = page.locator('[placeholder="Department"]')
await departmentNameField.click()
await departmentNameField.fill(departmentName)
await page.locator('.antiCard button:has-text("Create")').click()
await page.waitForSelector('form.antiCard', { state: 'detached' })
}

test.describe('hr tests', () => {
test.beforeEach(async ({ page }) => {
// Create user and workspace
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
})

test('test-pto-after-department-change', async ({ page, context }) => {
await page.locator('[id="app-hr\\:string\\:HRApplication"]').click()
await page.click('text="Structure"')
const department1 = 'dep1'
const department2 = 'dep2'
await createDepartment(page, department1)
await createDepartment(page, department2)

// Click .ml-8 > div > div > .flex-between >> nth=0
await page.locator('.ml-8 > div > div > .flex-between').first().click()

// Click [id="hr\:string\:AddEmployee"]
await page.locator('[id="hr\\:string\\:AddEmployee"]').click()

// Click button:has-text("Appleseed John")
await page.locator('button:has-text("Appleseed John")').click()

// Click text=Schedule
await page.locator('text=Schedule').click()

// Click td:nth-child(15) > .h-full
await page.locator('td:nth-child(15) > .h-full').click()

// Click button:has-text("Vacation")
await page.locator('button:has-text("Vacation")').click()

// Click button:has-text("PTO") >> nth=0
await page.locator('button:has-text("Remote")').first().click()

// Click button:has-text("Create")
await page.locator('button:has-text("Create")').click()
await page.waitForSelector('form.antiCard', { state: 'detached' })

// Click text=Structure
await page.locator('text=Structure').click()

// Click div:nth-child(3) > div > .flex-between
await page.locator('div:nth-child(3) > div > .flex-between').click()

// Click [id="hr\:string\:AddEmployee"]
await page.locator('[id="hr\\:string\\:AddEmployee"]').click()

// Click button:has-text("Appleseed John")
await page.locator('button:has-text("Appleseed John")').click()

// Click button:has-text("Ok")
await page.locator('button:has-text("Ok")').click()
await page.waitForSelector('form.antiCard', { state: 'detached' })

// Click text=Schedule
await page.locator('text=Schedule').click()
await expect(await page.locator('td:nth-child(15) > .h-full .request')).toHaveCSS('opacity', '0.5')
})
})

0 comments on commit 67d361d

Please sign in to comment.