File tree 7 files changed +98
-11
lines changed
7 files changed +98
-11
lines changed Original file line number Diff line number Diff line change
1
+ import { expect , Locator , Page } from "@playwright/test"
2
+ import { BasePom } from "./BasePom"
3
+
4
+ export class CreateTemplatePage extends BasePom {
5
+ readonly createTemplateForm : Locator
6
+ readonly createTemplateButton : Locator
7
+
8
+ constructor ( baseURL : string | undefined , page : Page ) {
9
+ super ( baseURL , `/templates` , page )
10
+
11
+ this . createTemplateForm = page . getByTestId ( "form-create-template" )
12
+ this . createTemplateButton = page . getByTestId ( "button-create-template" )
13
+ }
14
+
15
+ async loaded ( ) {
16
+ await expect ( this . page ) . toHaveTitle ( "Create Template - Coder" )
17
+
18
+ await this . createTemplateForm . waitFor ( { state : "visible" } )
19
+ await this . createTemplateButton . waitFor ( { state : "visible" } )
20
+ }
21
+
22
+ async fillIn ( ) {
23
+ await this . createTemplateForm . getByLabel ( "Name *" ) . fill ( "my-first-template" )
24
+ await this . createTemplateForm
25
+ . getByLabel ( "Display name" )
26
+ . fill ( "My First Template" )
27
+ await this . createTemplateForm
28
+ . getByLabel ( "Description" )
29
+ . fill ( "This is my first template." )
30
+
31
+ await this . createTemplateButton . click ( )
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ import { expect , Locator , Page } from "@playwright/test"
2
+ import { BasePom } from "./BasePom"
3
+
4
+ export class TemplatesPage extends BasePom {
5
+ readonly addTemplateButton : Locator
6
+
7
+ constructor ( baseURL : string | undefined , page : Page ) {
8
+ super ( baseURL , `/templates` , page )
9
+
10
+ this . addTemplateButton = page . getByTestId ( "button-add-template" )
11
+ }
12
+
13
+ async goto ( ) {
14
+ await this . page . goto ( this . url , { waitUntil : "networkidle" } )
15
+ }
16
+
17
+ async loaded ( ) {
18
+ await expect ( this . page ) . toHaveTitle ( "Templates - Coder" )
19
+
20
+ await this . addTemplateButton . waitFor ( { state : "visible" } )
21
+ }
22
+
23
+ async addTemplate ( ) {
24
+ await this . addTemplateButton . click ( )
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ import { test } from "@playwright/test"
2
+ import { getStatePath } from "../helpers"
3
+ import { TemplatesPage } from "../pom/TemplatesPage"
4
+ import { CreateTemplatePage } from "../pom/CreateTemplatePage"
5
+
6
+ test . use ( { storageState : getStatePath ( "authState" ) } )
7
+
8
+ test ( "Basic scenario" , async ( { page, baseURL } ) => {
9
+ const templatesPage = new TemplatesPage ( baseURL , page )
10
+ const createTemplatePage = new CreateTemplatePage ( baseURL , page )
11
+
12
+ await test . step ( "Load empty templates page" , async ( ) => {
13
+ await templatesPage . goto ( )
14
+ await templatesPage . loaded ( )
15
+ } )
16
+
17
+ await test . step ( "Upload a template" , async ( ) => {
18
+ await templatesPage . addTemplate ( )
19
+ await createTemplatePage . loaded ( )
20
+
21
+ await createTemplatePage . fillIn ( )
22
+
23
+ await page . waitForTimeout ( 5 * 60 * 1000 ) // FIXME
24
+ } )
25
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,13 +16,15 @@ export interface FormFooterProps {
16
16
styles ?: FormFooterStyles
17
17
submitLabel ?: string
18
18
submitDisabled ?: boolean
19
+ submitTestId ?: string
19
20
}
20
21
21
22
export const FormFooter : FC < FormFooterProps > = ( {
22
23
onCancel,
23
24
isLoading,
24
25
submitDisabled,
25
26
submitLabel = Language . defaultSubmitLabel ,
27
+ submitTestId,
26
28
styles = defaultStyles ( ) ,
27
29
} ) => {
28
30
return (
@@ -35,6 +37,7 @@ export const FormFooter: FC<FormFooterProps> = ({
35
37
color = "primary"
36
38
type = "submit"
37
39
disabled = { submitDisabled }
40
+ data-testid = { submitTestId }
38
41
>
39
42
{ submitLabel }
40
43
</ LoadingButton >
Original file line number Diff line number Diff line change @@ -225,7 +225,10 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = ({
225
225
const { t : commonT } = useTranslation ( "common" )
226
226
227
227
return (
228
- < HorizontalForm onSubmit = { form . handleSubmit } >
228
+ < HorizontalForm
229
+ onSubmit = { form . handleSubmit }
230
+ data-testid = "form-create-template"
231
+ >
229
232
{ /* General info */ }
230
233
< FormSection
231
234
title = { t ( "form.generalInfo.title" ) }
@@ -505,6 +508,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = ({
505
508
onCancel = { onCancel }
506
509
isLoading = { isSubmitting }
507
510
submitLabel = { jobError ? "Retry" : "Create template" }
511
+ submitTestId = "button-create-template"
508
512
/>
509
513
</ HorizontalForm >
510
514
)
Original file line number Diff line number Diff line change @@ -158,7 +158,12 @@ export const TemplatesPageView: FC<
158
158
>
159
159
Starter templates
160
160
</ Button >
161
- < Button startIcon = { < AddIcon /> } component = { RouterLink } to = "new" >
161
+ < Button
162
+ startIcon = { < AddIcon /> }
163
+ component = { RouterLink }
164
+ to = "new"
165
+ data-testid = "button-add-template"
166
+ >
162
167
Add template
163
168
</ Button >
164
169
</ Maybe >
You can’t perform that action at this time.
0 commit comments