Skip to content

Commit

Permalink
Merge pull request #235 from WycliffeAssociates/fix-next-button-on-mo…
Browse files Browse the repository at this point in the history
…bile-issue

STET: Fix issue with next button on mobile
  • Loading branch information
PurpleGuitar authored Dec 16, 2024
2 parents aee3543 + a700d87 commit 632be94
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 80 deletions.
5 changes: 1 addition & 4 deletions frontend/src/routes/stet/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
// usfmAvailableStore
// } from '$lib/stores/ResourceTypesStore'
import {
lang0CodeAndNameStore,
lang1CodeAndNameStore,
langCodesStore,
langCountStore
} from '$lib/stet/stores/LanguagesStore'
// import { bookCountStore } from '$lib/stores/BooksStore'
Expand Down Expand Up @@ -120,7 +117,7 @@
/>
<rect x="0.5" y="0.5" width="55" height="47" rx="11.5" stroke="#E5E8EB" />
</svg>
{#if $lang0CodeAndNameStore && $lang1CodeAndNameStore}
{#if $langCountStore}
<!-- badge -->
<div
class="text-center absolute -top-0.5 -right-0.5
Expand Down
30 changes: 9 additions & 21 deletions frontend/src/routes/stet/source_languages/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import WizardBasket from '$lib/stet/WizardBasket.svelte'
import {
lang0CodeAndNameStore,
lang1CodeAndNameStore,
langCodesStore,
gatewayCodeAndNamesStore,
heartCodeAndNamesStore,
Expand Down Expand Up @@ -68,42 +69,29 @@
})
.catch((err) => console.log(err))
let nonEmptyGatewayLanguages: boolean
$: nonEmptyGatewayLanguages = $gatewayCodeAndNamesStore.every((item) => item.length > 0)
let nonEmptyHeartLanguages: boolean
$: nonEmptyHeartLanguages = $heartCodeAndNamesStore.every((item) => item.length > 0)
// Set $langCountStore
$: {
if (nonEmptyGatewayLanguages && nonEmptyHeartLanguages) {
if ($lang0CodeAndNameStore && $lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $gatewayCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
for (let stringTuple of $heartCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang0CodeAndNameStore))
codes.push(getCode($lang1CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else if (nonEmptyGatewayLanguages && !nonEmptyHeartLanguages) {
} else if ($lang0CodeAndNameStore && !$lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $gatewayCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang0CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else if (!nonEmptyGatewayLanguages && nonEmptyHeartLanguages) {
} else if (!$lang0CodeAndNameStore && $lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $heartCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang1CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else {
$langCountStore = 0
$langCodesStore = []
$lang0CodeAndNameStore = ''
$lang1CodeAndNameStore = ''
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,36 +74,22 @@
})
.catch((err) => console.log(err)) // FIXME Trigger toast for error
let nonEmptyGatewayLanguages: boolean
$: nonEmptyGatewayLanguages = $gatewayCodeAndNamesStore.every((item) => item.length > 0)
let nonEmptyHeartLanguages: boolean
$: nonEmptyHeartLanguages = $heartCodeAndNamesStore.every((item) => item.length > 0)
// Set langCountStore
// Set $langCountStore
$: {
if (nonEmptyGatewayLanguages && nonEmptyHeartLanguages) {
if ($lang0CodeAndNameStore && $lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $gatewayCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
for (let stringTuple of $heartCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang0CodeAndNameStore))
codes.push(getCode($lang1CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else if (nonEmptyGatewayLanguages && !nonEmptyHeartLanguages) {
} else if ($lang0CodeAndNameStore && !$lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $gatewayCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang0CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else if (!nonEmptyGatewayLanguages && nonEmptyHeartLanguages) {
} else if (!$lang0CodeAndNameStore && $lang1CodeAndNameStore) {
let codes = []
for (let stringTuple of $heartCodeAndNamesStore) {
codes.push(getCode(stringTuple))
}
codes.push(getCode($lang1CodeAndNameStore))
$langCodesStore = codes
$langCountStore = $langCodesStore.length
} else {
Expand Down
68 changes: 68 additions & 0 deletions frontend/tests/e2e/stet_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { expect, test } from '@playwright/test'

// Group tests with specific settings
test.describe('Desktop Tests', () => {
test.use({
viewport: {
height: 700,
width: 1200,
},
})

test('test stet', async ({ page }) => {
await page.goto('http://localhost:8001/stet')
await page.getByLabel('English en').check()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByText('Cebuano').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Generate File' }).click()
})

test('test stet 2', async ({ page }) => {
await page.goto('http://localhost:8001/stet')
await page.getByText('English').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByText('Bichelamar (Bislama)').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('link', { name: 'Target Language' }).click()
await page.getByRole('link', { name: 'Source Language' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Edit' }).click()
await page.getByRole('button', { name: 'Edit' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByLabel('Email me a copy of my').check()
await page.getByPlaceholder('Type email address here (').click()
await page.getByPlaceholder('Type email address here (').fill('[email protected]')
await page.getByRole('button', { name: 'Submit' }).click()
await page.getByRole('button', { name: 'Generate File' }).click()
})
})

// Separate group for mobile tests
test.describe('Mobile Tests', () => {
test.use({
viewport: {
height: 600,
width: 300,
},
})

test('test mobile', async ({ page }) => {
await page.goto('http://localhost:8001/stet')
await page.goto('http://localhost:8001/stet/source_languages')
await page.getByLabel('English en').check()
await page.getByRole('button').nth(1).click()
await page.getByText('Bahasa Indonesia (Indonesian)').click()
await page.getByRole('button').nth(1).click()
await page.getByRole('button', { name: '2' }).click()
await page.getByRole('button', { name: 'Edit' }).nth(1).click()
await page.getByRole('button').nth(1).click()
await page.getByRole('button', { name: 'Generate File' }).click()
})
})
33 changes: 0 additions & 33 deletions frontend/tests/e2e/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,3 @@ test('test es-419 resource types', async ({ page }) => {
await page.getByRole('button', { name: 'Generate File' }).click()
})

test('test stet', async ({ page }) => {
await page.goto('http://localhost:8001/stet')
await page.getByLabel('English en').check()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByText('Cebuano').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Generate File' }).click()
})

test('test stet 2', async ({ page }) => {
await page.goto('http://localhost:8001/stet')
await page.getByText('English').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByText('Bichelamar (Bislama)').click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('link', { name: 'Target Language' }).click()
await page.getByRole('link', { name: 'Source Language' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Back' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByRole('button', { name: 'Edit' }).click()
await page.getByRole('button', { name: 'Edit' }).click()
await page.getByRole('button', { name: 'Next' }).click()
await page.getByLabel('Email me a copy of my').check()
await page.getByPlaceholder('Type email address here (').click()
await page.getByPlaceholder('Type email address here (').fill('[email protected]')
await page.getByRole('button', { name: 'Submit' }).click()
await page.getByRole('button', { name: 'Generate File' }).click()
})

0 comments on commit 632be94

Please sign in to comment.