Skip to content

Commit

Permalink
Merge pull request #71 from Opetushallitus/oppimaaran-kielitarkenne
Browse files Browse the repository at this point in the history
OPHLUDOS-93: Oppimäärän kielitarkenteen näyttäminen
  • Loading branch information
ChristianVilen authored Oct 11, 2023
2 parents b755cd8 + 351253d commit 8a02692
Show file tree
Hide file tree
Showing 72 changed files with 3,508 additions and 1,470 deletions.
5 changes: 4 additions & 1 deletion .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/sh
#!/bin/bash

set -euo pipefail

yarn lint
scripts/update_backups.sh --if-stale
23 changes: 14 additions & 9 deletions playwright/all_tests/assignment/assignment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test.describe('Suko assignment form tests', () => {

await expect(page.getByTestId('notification-success')).toBeVisible()
await expect(page.getByTestId('assignment-header')).toHaveText(createContent.nameTextFi)
await expect(page.getByTestId('suko-oppimaara')).toHaveText('Vieraat kielet, A-oppimäärä')
await expect(page.getByTestId('publish-state')).toHaveText('Julkaistu')

await page.getByTestId('return').click()
Expand Down Expand Up @@ -88,19 +89,23 @@ test.describe('Suko assignment form tests', () => {

await expect(updatedAssignmentHeader).toHaveText(updatedFormData.nameTextFi)

const expectedOppimaara = 'Vieraat kielet, A-oppimäärä, saksan kieli'
await expect(page.getByTestId('suko-oppimaara')).toHaveText(expectedOppimaara)
await expect(page.getByTestId('suko-tehtavatyyppi')).toHaveText('Tekstin tiivistäminen')
// await expect(page.getByTestId('suko-tavoitetaso')).toBeVisible()
await expect(page.getByTestId('suko-aihe')).toHaveText('kulttuuri ja luova ilmaisu')
await expect(page.getByTestId('laajaalainenosaaminen')).toHaveText(
'Globaali- ja kulttuuriosaaminen, Hyvinvointiosaaminen, Vuorovaikutusosaaminen'
)

await expect(page.getByTestId('language-dropdown')).toBeHidden()
await expect(page.getByTestId('languageDropdown')).toBeHidden()

await page.getByTestId('return').click()
await expect(page.getByTestId(`assignment-list-item-${createdAssignmentId.toString()}`)).toBeVisible()
const assignmentCard = page.getByTestId(`assignment-list-item-${createdAssignmentId}`)
await expect(assignmentCard).toBeVisible()
await expect(assignmentCard.getByTestId('suko-oppimaara')).toHaveText(expectedOppimaara)

await expect(page.getByTestId('language-dropdown')).toBeHidden()
await expect(page.getByTestId('languageDropdown')).toBeHidden()
})

test('can create draft assignment', async ({ page }) => {
Expand Down Expand Up @@ -160,8 +165,8 @@ test.describe('Ld assignment form tests', () => {
await expect(page.getByTestId(`editor-content-fi-${i}`)).toHaveText(content)
}

await page.getByTestId('language-dropdown').click()
await page.getByTestId('language-dropdown-option-sv').click()
await page.getByTestId('languageDropdown').click()
await page.getByTestId('languageDropdown-option-sv').click()

await expect(page.getByTestId('assignment-header')).toHaveText(formData.nameTextSv)
await expect(page.getByTestId('instruction-sv')).toHaveText(formData.instructionTextSv)
Expand Down Expand Up @@ -199,8 +204,8 @@ test.describe('Ld assignment form tests', () => {
for (const [i, content] of updatedFormData.contentTextFi.entries()) {
await expect(page.getByTestId(`editor-content-fi-${i}`)).toHaveText(content)
}
await page.getByTestId('language-dropdown').click()
await page.getByTestId('language-dropdown-option-sv').click()
await page.getByTestId('languageDropdown').click()
await page.getByTestId('languageDropdown-option-sv').click()

await expect(page.getByTestId('assignment-header')).toHaveText(updatedFormData.nameTextSv)
for (const [i, content] of updatedFormData.contentTextSv.entries()) {
Expand Down Expand Up @@ -293,8 +298,8 @@ test.describe('Puhvi assignment form tests', () => {
await expect(page.getByTestId(`editor-content-fi-${i}`)).toHaveText(content)
}

await page.getByTestId('language-dropdown').click()
await page.getByTestId('language-dropdown-option-sv').click()
await page.getByTestId('languageDropdown').click()
await page.getByTestId('languageDropdown-option-sv').click()

await expect(page.getByTestId('assignment-header')).toHaveText(updatedFormData.nameTextSv)
for (const [i, content] of updatedFormData.contentTextSv.entries()) {
Expand Down
106 changes: 47 additions & 59 deletions playwright/all_tests/assignment/assignmentFilters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
import { expect, test } from '@playwright/test'
import { Exam, loginTestGroup, Role } from '../../helpers'
import { checkListAfterFiltering } from './assignmentHelpers'
import { Exam, Language, loginTestGroup, Role } from '../../helpers'
import { checkListAfterFiltering, filterTestAssignmentName } from './assignmentHelpers'
import { setMultiSelectDropdownOptions } from '../../helpers'

loginTestGroup(test, Role.YLLAPITAJA)

test.describe('Assignment filter tests', () => {
test('suko, ld, puhvi', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto('/api/test/empty')
await page.goto('/api/test/seed')
await page.goto('/api/test/seedAssignmentsForFilterTest')
})

// SUKO
test('suko', async ({ page }) => {
await page.goto('/suko/koetehtavat')

await page.getByTestId('oppimaara').click()
// Suomi-oppimäärä options
await page.getByTestId('oppimaara-option-TKFI').click()
await page.getByTestId('oppimaara-option-TKFIA1').click()
await page.getByTestId('oppimaara-option-TKFIB1').click()
await page.getByTestId('oppimaara-option-TKFIB3').click()
await page.getByTestId('oppimaara-multi-select-ready-button').click()

await page.getByTestId('contentType').click()
// keskustelu
await page.getByTestId('contentType-option-003').click()
await page.getByTestId('contentType-multi-select-ready-button').click()

await page.getByTestId('aihe').click()
await checkListAfterFiltering(page, [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], Exam.Suko)

// Pohjoismaat
await page.getByTestId('aihe-option-013').click()
await page.getByTestId('aihe-multi-select-ready-button').click()

await checkListAfterFiltering(page, [2], Exam.Suko)
await setMultiSelectDropdownOptions(page, 'oppimaaraFilter', ['VKA1', 'TKFIA1', 'TKFIB1', 'TKFIB3'])
await setMultiSelectDropdownOptions(page, 'contentTypeFilter', ['003']) // keskustelu
await setMultiSelectDropdownOptions(page, 'aiheFilter', ['013']) // pohjoismaat
await checkListAfterFiltering(page, [8, 2], Exam.Suko)

// await page.getByTestId('tavoitetaitotaso-input').fill('b1')
// await page.getByTestId('tavoitetaitotaso').click()
Expand All @@ -42,56 +30,56 @@ test.describe('Assignment filter tests', () => {

// refresh page to make sure filters stay
await page.reload()
await checkListAfterFiltering(page, [8, 2], Exam.Suko)

await expect(page.getByRole('link', { name: 'Test name 2 FI SUKO' })).toBeVisible()
await checkListAfterFiltering(page, [2], Exam.Suko)

await page.getByRole('link', { name: 'Test name 2 FI SUKO' }).click()
await expect(page.getByTestId('assignment-header')).toHaveText('Test name 2 FI SUKO')
await page.getByRole('link', { name: filterTestAssignmentName(2, Language.FI, Exam.Suko) }).click()
await expect(page.getByTestId('assignment-header')).toHaveText(filterTestAssignmentName(2, Language.FI, Exam.Suko))
await page.getByTestId('return').click()

// make sure filters stay when returning from an assignment
await expect(page.getByRole('link', { name: 'Test name 2 FI SUKO' })).toBeVisible()
await checkListAfterFiltering(page, [2], Exam.Suko)
await checkListAfterFiltering(page, [8, 2], Exam.Suko)

// remove selections from assignmentType filter
await page.getByTestId('contentType-reset-selected-options').click()
await expect(page.getByRole('link', { name: 'Test name 7 FI SUKO' })).toBeVisible()
await checkListAfterFiltering(page, [7, 2, 1], Exam.Suko)
await page.getByTestId('contentTypeFilter-reset-selected-options').click()
await checkListAfterFiltering(page, [8, 2, 1], Exam.Suko)
})

// LD
await page.goto('/ld/koetehtavat')
test('suko oppimaaras', async ({ page }) => {
await page.goto('/suko/koetehtavat')

await setMultiSelectDropdownOptions(page, 'oppimaaraFilter', ['VKA1'])
await checkListAfterFiltering(page, [10, 9, 8], Exam.Suko)

await page.getByTestId('lukuvuosi').click()
await page.getByTestId('lukuvuosi-option-20202021').click()
await page.getByTestId('lukuvuosi-multi-select-ready-button').click()
await setMultiSelectDropdownOptions(page, 'oppimaaraFilter', ['VKA1.RA'])
await checkListAfterFiltering(page, [8], Exam.Suko)

await page.getByTestId('aine').click()
// musiikki
await page.getByTestId('aine-option-6').click()
await page.getByTestId('aine-multi-select-ready-button').click()
await expect(page.getByRole('link', { name: 'Test name 5 FI LD' })).toBeVisible()
await setMultiSelectDropdownOptions(page, 'oppimaaraFilter', ['VKB1'])
await checkListAfterFiltering(page, [7], Exam.Suko)

await setMultiSelectDropdownOptions(page, 'oppimaaraFilter', ['VKB1.IA'])
await checkListAfterFiltering(page, [7], Exam.Suko)
})

test('ld', async ({ page }) => {
await page.goto('/ld/koetehtavat')

await setMultiSelectDropdownOptions(page, 'lukuvuosiFilter', ['20202021'])
await setMultiSelectDropdownOptions(page, 'aineFilter', ['6']) // musiikki
await checkListAfterFiltering(page, [5], Exam.Ld)
await page.getByRole('link', { name: 'Test name 5 FI LD' }).click()

await expect(page.getByTestId('assignment-header')).toHaveText('Test name 5 FI LD')
await page.getByRole('link', { name: filterTestAssignmentName(5, Language.FI, Exam.Ld) }).click()
await expect(page.getByTestId('assignment-header')).toHaveText(filterTestAssignmentName(5, Language.FI, Exam.Ld))
await page.getByTestId('return').click()
})

// Puhvi
test('puhvi', async ({ page }) => {
await page.goto('/puhvi/koetehtavat')

await page.getByTestId('lukuvuosi').click()
await page.getByTestId('lukuvuosi-option-20242025').click()
await page.getByTestId('lukuvuosi-multi-select-ready-button').click()

await page.getByTestId('tehtavatyyppiPuhvi').click()
// esiintymistaidot
await page.getByTestId('tehtavatyyppiPuhvi-option-002').click()
await page.getByTestId('tehtavatyyppiPuhvi-multi-select-ready-button').click()

await expect(page.getByRole('link', { name: 'Test name 8 FI PUHVI' })).toBeVisible()
await setMultiSelectDropdownOptions(page, 'lukuvuosiFilter', ['20242025'])
await setMultiSelectDropdownOptions(page, 'tehtavatyyppiPuhviFilter', ['002']) // esiintymistaidot
await checkListAfterFiltering(page, [8], Exam.Puhvi)
await page.getByRole('link', { name: 'Test name 8 FI PUHVI' }).click()
await expect(page.getByTestId('assignment-header')).toHaveText('Test name 8 FI PUHVI')

await page.getByRole('link', { name: filterTestAssignmentName(8, Language.FI, Exam.Puhvi) }).click()
await expect(page.getByTestId('assignment-header')).toHaveText(filterTestAssignmentName(8, Language.FI, Exam.Puhvi))
})
})
Loading

0 comments on commit 8a02692

Please sign in to comment.