-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MBL-17621][Parent] Course details - Grades
refs: MBL-17621 affects: Parent release note: none
- Loading branch information
1 parent
e9f26a0
commit 7cbf649
Showing
82 changed files
with
5,916 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
...Test/java/com/instructure/parentapp/ui/compose/courses/details/CourseDetailsScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
* 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.courses.details | ||
|
||
import androidx.compose.ui.test.assertHasClickAction | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsNotDisplayed | ||
import androidx.compose.ui.test.hasContentDescription | ||
import androidx.compose.ui.test.hasParent | ||
import androidx.compose.ui.test.hasTestTag | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.instructure.parentapp.features.courses.details.CourseDetailsScreen | ||
import com.instructure.parentapp.features.courses.details.CourseDetailsUiState | ||
import com.instructure.parentapp.features.courses.details.TabType | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class CourseDetailsScreenTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun assertLoadingContent() { | ||
composeTestRule.setContent { | ||
CourseDetailsScreen( | ||
uiState = CourseDetailsUiState( | ||
isLoading = true | ||
), | ||
actionHandler = {}, | ||
navigationActionClick = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("loading") | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun assertErrorContent() { | ||
composeTestRule.setContent { | ||
CourseDetailsScreen( | ||
uiState = CourseDetailsUiState( | ||
isLoading = false, | ||
isError = true | ||
), | ||
actionHandler = {}, | ||
navigationActionClick = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithText("We're having trouble loading your student's course details. Please try reloading the page or check back later.") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Retry") | ||
.assertIsDisplayed() | ||
.assertHasClickAction() | ||
} | ||
|
||
@Test | ||
fun assertCourseDetailsContent() { | ||
composeTestRule.setContent { | ||
CourseDetailsScreen( | ||
uiState = CourseDetailsUiState( | ||
isLoading = false, | ||
isError = false, | ||
courseName = "Course 1", | ||
tabs = listOf(TabType.SYLLABUS, TabType.SUMMARY) | ||
), | ||
actionHandler = {}, | ||
navigationActionClick = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("toolbar") | ||
.assertIsDisplayed() | ||
composeTestRule.onNode(hasParent(hasTestTag("toolbar")).and(hasContentDescription("Back"))) | ||
.assertIsDisplayed() | ||
.assertHasClickAction() | ||
composeTestRule.onNodeWithText("Course 1") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("SYLLABUS") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("SUMMARY") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("courseDetailsTabRow") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("courseDetailsPager") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithContentDescription("Send a message about this course") | ||
.assertIsDisplayed() | ||
.assertHasClickAction() | ||
} | ||
|
||
@Test | ||
fun assertCourseDetailsContentWithJustOnTab() { | ||
composeTestRule.setContent { | ||
CourseDetailsScreen( | ||
uiState = CourseDetailsUiState( | ||
isLoading = false, | ||
isError = false, | ||
courseName = "Course 1", | ||
tabs = listOf(TabType.SYLLABUS) | ||
), | ||
actionHandler = {}, | ||
navigationActionClick = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithText("Course 1") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithTag("courseDetailsTabRow") | ||
.assertIsNotDisplayed() | ||
composeTestRule.onNodeWithTag("courseDetailsPager") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithContentDescription("Send a message about this course") | ||
.assertIsDisplayed() | ||
.assertHasClickAction() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...androidTest/java/com/instructure/parentapp/ui/interaction/CourseDetailsInteractionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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.interaction | ||
|
||
import com.instructure.canvas.espresso.mockCanvas.MockCanvas | ||
import com.instructure.canvas.espresso.mockCanvas.init | ||
import com.instructure.canvasapi2.models.Course | ||
import com.instructure.canvasapi2.models.CourseSettings | ||
import com.instructure.canvasapi2.models.Tab | ||
import com.instructure.parentapp.utils.ParentComposeTest | ||
import com.instructure.parentapp.utils.tokenLogin | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Test | ||
|
||
|
||
@HiltAndroidTest | ||
class CourseDetailsInteractionTest : ParentComposeTest() { | ||
|
||
@Test | ||
fun courseDetailsDisplayed() { | ||
val data = initData() | ||
val course = data.courses.values.first() | ||
setupTabs(data, course) | ||
|
||
goToCourseDetails(data, course.name) | ||
|
||
composeTestRule.waitForIdle() | ||
courseDetailsPage.assertCourseDetailsDisplayed(course) | ||
} | ||
|
||
@Test | ||
fun changeTab() { | ||
val data = initData() | ||
val course = data.courses.values.first() | ||
setupTabs(data, course) | ||
|
||
goToCourseDetails(data, course.name) | ||
|
||
composeTestRule.waitForIdle() | ||
courseDetailsPage.selectTab("SYLLABUS") | ||
courseDetailsPage.assertTabSelected("SYLLABUS") | ||
} | ||
|
||
private fun initData(): MockCanvas { | ||
return MockCanvas.init( | ||
parentCount = 1, | ||
studentCount = 1, | ||
courseCount = 1 | ||
) | ||
} | ||
|
||
private fun setupTabs(data: MockCanvas, course: Course) { | ||
course.homePage = Course.HomePage.HOME_SYLLABUS | ||
course.syllabusBody = "This is the syllabus" | ||
data.courseTabs[course.id]?.add(Tab(tabId = Tab.SYLLABUS_ID)) | ||
data.courseSettings[course.id] = CourseSettings( | ||
courseSummary = true | ||
) | ||
} | ||
|
||
private fun goToCourseDetails(data: MockCanvas, courseName: String) { | ||
val parent = data.parents.first() | ||
val token = data.tokenFor(parent)!! | ||
tokenLogin(data.domain, token, parent) | ||
coursesPage.tapCurseItem(courseName) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../androidTest/java/com/instructure/parentapp/ui/interaction/ParentGradesInteractionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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.interaction | ||
|
||
import com.instructure.canvas.espresso.common.interaction.GradesInteractionTest | ||
import com.instructure.canvas.espresso.mockCanvas.MockCanvas | ||
import com.instructure.canvas.espresso.mockCanvas.addAssignmentsToGroups | ||
import com.instructure.canvas.espresso.mockCanvas.init | ||
import com.instructure.parentapp.BuildConfig | ||
import com.instructure.parentapp.features.login.LoginActivity | ||
import com.instructure.parentapp.ui.pages.CoursesPage | ||
import com.instructure.parentapp.utils.ParentActivityTestRule | ||
import com.instructure.parentapp.utils.tokenLogin | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
|
||
|
||
@HiltAndroidTest | ||
class ParentGradesInteractionTest : GradesInteractionTest() { | ||
|
||
private val coursesPage = CoursesPage(composeTestRule) | ||
|
||
override val isTesting = BuildConfig.IS_TESTING | ||
|
||
override val activityRule = ParentActivityTestRule(LoginActivity::class.java) | ||
|
||
override fun initData(addAssignmentGroups: Boolean): MockCanvas { | ||
return MockCanvas.init( | ||
parentCount = 1, | ||
studentCount = 1, | ||
courseCount = 1, | ||
withGradingPeriods = true | ||
).apply { | ||
if (addAssignmentGroups) { | ||
addAssignmentsToGroups(this.courses.values.first(), 3) | ||
} | ||
} | ||
} | ||
|
||
override fun goToGrades(data: MockCanvas, courseName: String) { | ||
val parent = data.parents.first() | ||
val token = data.tokenFor(parent)!! | ||
tokenLogin(data.domain, token, parent) | ||
coursesPage.tapCurseItem(courseName) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
apps/parent/src/androidTest/java/com/instructure/parentapp/ui/pages/CourseDetailsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.pages | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsSelected | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.instructure.canvasapi2.models.Course | ||
|
||
|
||
class CourseDetailsPage(private val composeTestRule: ComposeTestRule) { | ||
|
||
fun assertCourseDetailsDisplayed(course: Course) { | ||
composeTestRule.onNodeWithText(course.name).assertIsDisplayed() | ||
composeTestRule.onNodeWithText("GRADES") | ||
.assertIsDisplayed() | ||
.assertIsSelected() | ||
composeTestRule.onNodeWithText("SYLLABUS").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("SUMMARY").assertIsDisplayed() | ||
} | ||
|
||
fun selectTab(tabName: String) { | ||
composeTestRule.onNodeWithText(tabName).performClick() | ||
} | ||
|
||
fun assertTabSelected(tabName: String) { | ||
composeTestRule.onNodeWithText(tabName).assertIsSelected() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.