Skip to content

Commit

Permalink
Release Student 7.5.1 (264)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofnemere authored Aug 1, 2024
2 parents 56568ae + 76d7fc4 commit eb4be42
Show file tree
Hide file tree
Showing 264 changed files with 31,508 additions and 4,959 deletions.
2 changes: 2 additions & 0 deletions apps/parent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = Versions.KOTLIN_COMPOSE_COMPILER_VERSION
}

testOptions.animationsDisabled = true
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* Copyright (C) 2024 - present Instructure, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.instructure.parentapp.ui.compose

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasAnyChild
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.pandares.R
import com.instructure.pandautils.utils.ThemedColor
import com.instructure.parentapp.features.managestudents.ColorPickerDialogUiState
import com.instructure.parentapp.features.managestudents.ManageStudentsScreen
import com.instructure.parentapp.features.managestudents.ManageStudentsUiState
import com.instructure.parentapp.features.managestudents.StudentItemUiState
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith


@RunWith(AndroidJUnit4::class)
class ManageStudentsScreenTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun assertEmptyContent() {
composeTestRule.setContent {
ManageStudentsScreen(
uiState = ManageStudentsUiState(
isLoading = false,
studentListItems = emptyList()
),
actionHandler = {},
navigationActionClick = {}
)
}

composeTestRule.onNodeWithText("You are not observing any students.")
.assertIsDisplayed()
composeTestRule.onNodeWithText("Retry")
.assertIsDisplayed()
.assertHasClickAction()
composeTestRule.onNodeWithTag(R.drawable.panda_manage_students.toString())
.assertIsDisplayed()
}

@Test
fun assertErrorContent() {
composeTestRule.setContent {
ManageStudentsScreen(
uiState = ManageStudentsUiState(
isLoadError = true,
studentListItems = emptyList()
),
actionHandler = {},
navigationActionClick = {}
)
}

composeTestRule.onNodeWithText("There was an error loading your students.")
.assertIsDisplayed()
composeTestRule.onNodeWithText("Retry")
.assertIsDisplayed()
.assertHasClickAction()
}

@Test
fun assertStudentListContent() {
composeTestRule.setContent {
ManageStudentsScreen(
uiState = ManageStudentsUiState(
studentListItems = listOf(
StudentItemUiState(
studentId = 1,
studentName = "John Doe",
studentPronouns = "He/Him",
studentColor = ThemedColor(R.color.studentGreen)
),
StudentItemUiState(
studentId = 2,
studentName = "Jane Doe",
studentColor = ThemedColor(R.color.studentPink)
)
)
),
actionHandler = {},
navigationActionClick = {}
)
}

fun studentItemMatcher(name: String) = hasTestTag("studentListItem") and hasAnyChild(hasText(name))
composeTestRule.onNode(studentItemMatcher("John Doe (He/Him)"), true)
.assertIsDisplayed()
composeTestRule.onNode(studentItemMatcher("Jane Doe"), true)
.assertIsDisplayed()
}

@Test
fun assertColorPickerDialogError() {
composeTestRule.setContent {
ManageStudentsScreen(
uiState = ManageStudentsUiState(
studentListItems = listOf(
StudentItemUiState(
studentId = 1,
studentName = "John Doe",
studentColor = ThemedColor(R.color.studentGreen)
)
),
colorPickerDialogUiState = ColorPickerDialogUiState(
showColorPickerDialog = true,
studentId = 1,
initialUserColor = null,
userColors = emptyList(),
isSavingColorError = true
)
),
actionHandler = {},
navigationActionClick = {}
)
}

composeTestRule.onNodeWithText("Select Student Color")
.assertIsDisplayed()
composeTestRule.onNodeWithText("An error occurred while saving your selection. Please try again.")
.assertIsDisplayed()
composeTestRule.onNodeWithText("Cancel")
.assertIsDisplayed()
.assertHasClickAction()
composeTestRule.onNodeWithText("OK")
.assertIsDisplayed()
.assertHasClickAction()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2024 - present Instructure, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.instructure.parentapp.ui.compose

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.parentapp.features.notaparent.NotAParentScreen
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith


@RunWith(AndroidJUnit4::class)
class NotAParentScreenTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun assertContent() {
composeTestRule.setContent {
NotAParentScreen(
returnToLoginClick = {},
onStudentClick = {},
onTeacherClick = {}
)
}

composeTestRule.onNodeWithText("Not a parent?").assertIsDisplayed()
composeTestRule.onNodeWithText("We couldn't find any students associated with your account").assertIsDisplayed()
composeTestRule.onNodeWithText("Return to login")
.assertIsDisplayed()
.assertHasClickAction()
composeTestRule.onNodeWithText("Are you a student or teacher?")
.assertIsDisplayed()
.assertHasClickAction()
composeTestRule.onNodeWithText("STUDENT")
.assertIsNotDisplayed()
}

@Test
fun assertAppOptions() {
composeTestRule.setContent {
NotAParentScreen(
returnToLoginClick = {},
onStudentClick = {},
onTeacherClick = {}
)
}

composeTestRule.onNodeWithText("Are you a student or teacher?").performClick()
composeTestRule.onNodeWithText("STUDENT")
.assertIsDisplayed()
.assertHasClickAction()
composeTestRule.onNodeWithText("TEACHER")
.assertIsDisplayed()
.assertHasClickAction()
}
}
Loading

0 comments on commit eb4be42

Please sign in to comment.