File tree Expand file tree Collapse file tree 6 files changed +83
-2
lines changed
Expand file tree Collapse file tree 6 files changed +83
-2
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,9 @@ const ActionNameCard = ({
162162 ? { bgColor : "transparent" , size : "lg" }
163163 : { bgColor : "gray.25" , size : "sm" } ) }
164164 _placeholder = { { opacity : 0.8 , color : "gray.900" } }
165+ aria-label = { intl . formatMessage ( {
166+ id : "action-name-placeholder" ,
167+ } ) }
165168 placeholder = { intl . formatMessage ( {
166169 id : "action-name-placeholder" ,
167170 } ) }
Original file line number Diff line number Diff line change @@ -63,6 +63,17 @@ export class DataSamplesPage {
6363 await expect ( this . heading ) . toBeVisible ( { timeout : 10000 } ) ;
6464 }
6565
66+ async expectActions ( expectedActions : string [ ] ) {
67+ const actionInputs = this . page . getByRole ( "textbox" , {
68+ name : "Name of action" ,
69+ } ) ;
70+ await expect ( actionInputs ) . toHaveCount ( expectedActions . length ) ;
71+ let i = 0 ;
72+ for ( const input of await actionInputs . all ( ) ) {
73+ await expect ( input ) . toHaveValue ( expectedActions [ i ++ ] ) ;
74+ }
75+ }
76+
6677 async trainModel ( ) {
6778 await this . page . getByRole ( "button" , { name : "Train model" } ) . click ( ) ;
6879 return new TrainModelDialog ( this . page ) ;
Original file line number Diff line number Diff line change 1+ import { Locator , type Page , expect } from "@playwright/test" ;
2+
3+ export class ImportPage {
4+ private readonly url : string ;
5+ private nameInputField : Locator ;
6+ private startSessionBtn : Locator ;
7+
8+ constructor ( public readonly page : Page ) {
9+ this . url = `http://localhost:5173${
10+ process . env . CI ? process . env . BASE_URL : "/"
11+ } `;
12+
13+ // Why not by role?
14+ this . startSessionBtn = page . getByRole ( "button" , { name : "Start session" } ) ;
15+ this . nameInputField = page . getByRole ( "textbox" , { name : "Name" } ) ;
16+ }
17+
18+ async gotoSimpleAIExerciseTimer ( ) {
19+ const query =
20+ "id=simple-ai-exercise-timer&project=Project%3A%20Simple%20AI%20exercise%20timer&name=Simple%20AI%20exercise%20timer&editors=makecode" ;
21+ const response = await this . page . goto ( `${ this . url } import?${ query } ` ) ;
22+ return response ;
23+ }
24+
25+ expectName ( expected : string ) {
26+ return expect ( this . nameInputField ) . toHaveValue ( expected ) ;
27+ }
28+
29+ startSession ( ) {
30+ return this . startSessionBtn . click ( ) ;
31+ }
32+
33+ async expectOnPage ( ) {
34+ await expect ( this . page . getByText ( "New session setup" ) ) . toBeVisible ( ) ;
35+ await expect ( this . nameInputField ) . toBeVisible ( ) ;
36+ await expect ( this . startSessionBtn ) . toBeVisible ( ) ;
37+ }
38+ }
Original file line number Diff line number Diff line change @@ -9,13 +9,15 @@ import { DataSamplesPage } from "./app/data-samples";
99import { TestModelPage } from "./app/test-model-page" ;
1010import { NewPage } from "./app/new-page" ;
1111import { OpenSharedProjectPage } from "./app/open-shared-project-page" ;
12+ import { ImportPage } from "./app/import-page" ;
1213
1314type MyFixtures = {
1415 homePage : HomePage ;
1516 newPage : NewPage ;
1617 dataSamplesPage : DataSamplesPage ;
1718 testModelPage : TestModelPage ;
1819 openSharedProjectPage : OpenSharedProjectPage ;
20+ importPage : ImportPage ;
1921} ;
2022
2123export const test = base . extend < MyFixtures > ( {
@@ -36,4 +38,7 @@ export const test = base.extend<MyFixtures>({
3638 openSharedProjectPage : async ( { page } , use ) => {
3739 await use ( new OpenSharedProjectPage ( page ) ) ;
3840 } ,
41+ importPage : async ( { page } , use ) => {
42+ await use ( new ImportPage ( page ) ) ;
43+ } ,
3944} ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * (c) 2024, Micro:bit Educational Foundation and contributors
3+ *
4+ * SPDX-License-Identifier: MIT
5+ */
6+ import { test } from "./fixtures" ;
7+
8+ test . describe ( "import project (microbit.org case)" , ( ) => {
9+ test . beforeEach ( async ( { homePage } ) => {
10+ await homePage . setupContext ( ) ;
11+ } ) ;
12+
13+ test ( "confirm and import" , async ( { importPage, dataSamplesPage } ) => {
14+ await importPage . gotoSimpleAIExerciseTimer ( ) ;
15+ await importPage . expectOnPage ( ) ;
16+ await importPage . expectName ( "Simple AI exercise timer" ) ;
17+ await importPage . startSession ( ) ;
18+
19+ await dataSamplesPage . expectOnPage ( ) ;
20+ await dataSamplesPage . expectActions ( [ "exercising" , "not exercising" ] ) ;
21+ // TODO: check actions
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change @@ -141,11 +141,12 @@ const ImportPage = () => {
141141 </ Text >
142142 ) }
143143 < Stack py = { 2 } spacing = { 5 } >
144- < Heading size = "md" as = "h2" >
144+ < Heading size = "md" as = "h2" id = "name-label" >
145145 < FormattedMessage id = "name-text" />
146146 </ Heading >
147147 < Input
148- aria-labelledby = { nameLabel }
148+ type = "text"
149+ aria-labelledby = "name-label"
149150 minW = "25ch"
150151 value = { name }
151152 name = { nameLabel }
You can’t perform that action at this time.
0 commit comments