-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create E2E tests for reset-project feature (#550)
This PR creates two tests: - Playwright E2E test that tests the function of the reset project modal, ensuring that it can reset a project to empty, and restore it to a previous state from a downloaded .zip file. - C# integration test that verifies that Send/Receive still works after a project has been reset to empty. (We don't test Send/Receive after a project reset has uploaded a .zip file, because the Playwright test already checks that the uploaded .zip file can bring the project repo back to the exact same state it was in before.)
- Loading branch information
Showing
7 changed files
with
363 additions
and
5 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
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,71 @@ | ||
import { expect, type Download, type Locator, type Page } from '@playwright/test'; | ||
import { BaseComponent } from './baseComponent'; | ||
|
||
const PLEASE_CONFIRM_DOWNLOAD_TEXT = 'Please confirm you have downloaded a backup'; | ||
const PLEASE_CONFIRM_PROJECT_CODE_TEXT = 'Please type the project code to confirm reset'; | ||
const I_CONFIRM_DOWNLOAD_TEXT = 'I confirm that I have downloaded a backup'; | ||
const DOWNLOAD_PROJECT_BACKUP_TEXT = 'Download project backup'; | ||
const ENTER_PROJECT_CODE_TEXT = 'Enter project code to confirm'; | ||
const PROJECT_UPLOAD_CONTROL_LABEL = 'Project zip file'; | ||
const PROJECT_UPLOAD_BUTTON_LABEL = 'Upload Project'; | ||
|
||
export class ResetProjectModal extends BaseComponent { | ||
get downloadProjectBackupButton(): Locator { | ||
return this.componentLocator.getByRole('link').filter({hasText: DOWNLOAD_PROJECT_BACKUP_TEXT}); | ||
} | ||
|
||
get confirmBackupDownloadedCheckbox(): Locator { | ||
return this.componentLocator.locator('form#reset-form').getByRole('checkbox', {name: I_CONFIRM_DOWNLOAD_TEXT}); | ||
} | ||
|
||
get confirmProjectCodeInput(): Locator { | ||
return this.componentLocator.locator('form#reset-form').getByLabel(ENTER_PROJECT_CODE_TEXT); | ||
} | ||
|
||
get projectUploadControl(): Locator { | ||
return this.componentLocator.getByLabel(PROJECT_UPLOAD_CONTROL_LABEL); | ||
} | ||
|
||
get projectUploadButton(): Locator { | ||
return this.componentLocator.getByRole('button', {name: PROJECT_UPLOAD_BUTTON_LABEL}); | ||
} | ||
|
||
get errorNoBackupDownloaded(): Locator { | ||
return this.componentLocator.locator('form#reset-form').getByText(PLEASE_CONFIRM_DOWNLOAD_TEXT); | ||
} | ||
|
||
get errorProjectCodeDoesNotMatch(): Locator { | ||
return this.componentLocator.locator('form#reset-form').getByText(PLEASE_CONFIRM_PROJECT_CODE_TEXT); | ||
} | ||
|
||
// TODO: method that confirms which modal step (by number) is active (1, 2, 3, 4) | ||
|
||
constructor(page: Page) { | ||
super(page, page.locator('.reset-modal dialog.modal')); | ||
} | ||
|
||
async downloadProjectBackup(): Promise<Download> { | ||
const downloadPromise = this.page.waitForEvent('download'); | ||
await this.downloadProjectBackupButton.click(); | ||
return downloadPromise; | ||
} | ||
|
||
async clickNextStepButton(expectedLabel: string): Promise<void> { | ||
await this.componentLocator.getByRole('button', {name: expectedLabel}).click(); | ||
await expect(this.errorNoBackupDownloaded).toBeHidden(); | ||
await expect(this.errorProjectCodeDoesNotMatch).toBeHidden(); | ||
|
||
} | ||
|
||
async confirmProjectBackupReceived(projectCode: string): Promise<void> { | ||
await this.confirmBackupDownloadedCheckbox.check(); | ||
await this.confirmProjectCodeInput.fill(projectCode); | ||
} | ||
|
||
async uploadProjectZipFile(filename: string): Promise<void> { | ||
await this.projectUploadControl.setInputFiles(filename); | ||
await expect(this.projectUploadButton).toBeVisible(); | ||
await expect(this.projectUploadButton).toBeEnabled(); | ||
await this.projectUploadButton.click(); | ||
} | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
import type { Page } from '@playwright/test'; | ||
import type { Locator, Page } from '@playwright/test'; | ||
import { BasePage } from './basePage'; | ||
import { ResetProjectModal } from '../components/resetProjectModal'; | ||
|
||
export class ProjectPage extends BasePage { | ||
get moreSettingsDiv(): Locator { return this.page.locator('.collapse').filter({ hasText: 'More settings' }); } | ||
get deleteProjectButton(): Locator { return this.moreSettingsDiv.getByRole('button', {name: 'Delete project'}); } | ||
get resetProjectButton(): Locator { return this.moreSettingsDiv.getByRole('button', {name: 'Reset project'}); } | ||
get verifyRepoButton(): Locator { return this.moreSettingsDiv.getByRole('button', {name: 'Verify repository'}); } | ||
|
||
constructor(page: Page, name: string, code: string) { | ||
super(page, page.locator(`.breadcrumbs :text('${name}')`), `/project/${code}`); | ||
} | ||
|
||
openMoreSettings(): Promise<void> { | ||
return this.moreSettingsDiv.getByRole('checkbox').check(); | ||
} | ||
|
||
async clickDeleteProject(): Promise<void> { | ||
await this.openMoreSettings(); | ||
await this.deleteProjectButton.click(); | ||
} | ||
|
||
async clickResetProject(): Promise<ResetProjectModal> { | ||
await this.openMoreSettings(); | ||
await this.resetProjectButton.click(); | ||
return new ResetProjectModal(this.page).waitFor() | ||
} | ||
|
||
async clickVerifyRepo(): Promise<void> { | ||
await this.openMoreSettings(); | ||
await this.verifyRepoButton.click(); | ||
} | ||
} |
Oops, something went wrong.