Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/lib/tutorialPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ const performStepAction = async ({
const textToType = extractTextToType(step);
if (isTextInput && textToType) {
await fillField(page, highlightedElementSelector, textToType);
// Inline rename inputs (tree view items) are only committed with Enter.
if (attempt > 1) await page.keyboard.press('Enter');
return;
}
const sceneCanvas = page
Expand Down
30 changes: 30 additions & 0 deletions scripts/__tests__/check-in-app-tutorial-selectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,36 @@ describe('checkTutorial', () => {
expect(problems[0].reason).toMatch(/UnknownEditor/);
});

it('validates the state selector following a scene in the project manager', () => {
const tutorial = {
id: 'test',
initialProjectData: { gameScene: 'GameScene' },
flow: [
{
elementToHighlightId: 'sceneInProjectManager:gameScene',
nextStepTrigger: {
presenceOfElement:
'sceneInProjectManager:gameScene:[data-state="x"]',
},
},
{
nextStepTrigger: {
presenceOfElement:
'sceneInProjectManager:notDeclared:[data-default="true"]',
},
},
],
};
const problems = checkTutorial(
tutorial,
sourceBlob + '\ndefault: this._isStartScene()'
);
expect(problems.map((problem) => problem.reason)).toEqual([
'attribute "data-state" was not found in the editor sources',
'selector "sceneInProjectManager:notDeclared:[data-default="true"]" references project data key "notDeclared" which is not declared in initialProjectData or any mapProjectData',
]);
});

it('returns no problem for a fully valid tutorial', () => {
const tutorial = {
id: 'test',
Expand Down
23 changes: 22 additions & 1 deletion scripts/lib/InAppTutorialSelectorChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ const DYNAMIC_ID_FAMILIES = [
* be found in the sources.
*/
const KNOWN_CAMEL_CASE_DATASET_KEYS = [
'default',
'effective',
'global',
'groupName',
'hidden',
'isFiltered',
];

Expand Down Expand Up @@ -306,6 +308,17 @@ const extractSelectorUsages = (tutorial) => {
return usages;
};

/**
* `sceneInProjectManager:<sceneKey>` can be followed by a selector checking the
* state of the scene item (e.g. `sceneInProjectManager:startScene:[data-default="true"]`).
* @param {string} selector
* @returns {{ sceneKey: string, stateSelector: string }}
*/
const getSceneInProjectManagerParts = (selector) => {
const [, sceneKey, ...stateSelectorParts] = selector.split(':');
return { sceneKey, stateSelector: stateSelectorParts.join(':') };
};

/**
* Checks a project data accessor selector (e.g. `objectInObjectsList:player`)
* or an `editorIsActive` value against the keys declared by the tutorial.
Expand Down Expand Up @@ -357,7 +370,9 @@ const checkProjectDataAccessor = (selector, field, declaredDataKeys) => {
return reasons;
}

const dataKey = selector.slice(selector.indexOf(':') + 1);
const dataKey = selector.startsWith('sceneInProjectManager:')
? getSceneInProjectManagerParts(selector).sceneKey
: selector.slice(selector.indexOf(':') + 1);
if (!declaredDataKeys.has(dataKey)) {
return [
`selector "${selector}" references project data key "${dataKey}" which is not declared in initialProjectData or any mapProjectData`,
Expand Down Expand Up @@ -429,6 +444,12 @@ const checkTutorial = (tutorial, sourceBlob) => {
const reasons = isProjectDataAccessor
? checkProjectDataAccessor(usage.selector, usage.field, declaredDataKeys)
: checkCssSelector(usage.selector, sourceBlob);
if (usage.selector.startsWith('sceneInProjectManager:')) {
const { stateSelector } = getSceneInProjectManagerParts(usage.selector);
if (stateSelector) {
reasons.push(...checkCssSelector(stateSelector, sourceBlob));
}
}
for (const reason of reasons) {
problems.push({
tutorialId: tutorial.id,
Expand Down
124 changes: 45 additions & 79 deletions tutorials/in-app/flingGame.json
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@
},
{
"elementToHighlightId": "objectInObjectsList:target",
"interactsWithCanvas": true,
"nextStepTrigger": {
"instanceAddedOnScene": "target"
},
Expand Down Expand Up @@ -1111,6 +1112,7 @@
},
{
"elementToHighlightId": "objectInObjectsList:block",
"interactsWithCanvas": true,
"nextStepTrigger": {
"instanceAddedOnScene": "block",
"instancesCount": 2
Expand Down Expand Up @@ -1690,75 +1692,6 @@
"absenceOfElement": "#object-editor-dialog"
}
},
{
"id": "OpenPropertiesManagerForExtension",
"elementToHighlightId": "#main-toolbar-project-manager-button",
"nextStepTrigger": {
"presenceOfElement": "div[role=\"presentation\"]:is([data-open=true], :not([aria-hidden=true])) #project-manager-tab-extensions"
},
"tooltip": {
"title": {
"messageByLocale": {
"en": "Now we'll make it possible for the player to drag the $(projectile).",
"fr": "Maintenant, nous allons faire en sorte que le joueur puisse faire glisser $(projectile) avec sa souris.",
"es": "Ahora vamos a hacer que el jugador pueda arrastrar $(projectile) con el ratón.",
"pt": "Agora vamos fazer com que o jogador possa arrastar $(projectile) com o mouse.",
"th": "ทีนี้เราจะทำให้ผู้เล่นสามารถลาก $(projectile)",
"ar": "الآن هيّا نجعل اللاعبين قادرين على سحب الـ $(projectile)."
}
},
"description": {
"messageByLocale": {
"en": "For this, we will install an **extension**.\n\nOpen the **Project Manager**.",
"fr": "Pour cela, nous allons installer un **extension**.\n\nOuvrez le **Gestionnaire de projet**.",
"es": "Para ello, vamos a instalar una **extensión**.\n\nAbre el **Gestor de proyectos**.",
"pt": "Para isso, vamos instalar uma **extensão**.\n\nAbra o **Gerenciador de projetos**.",
"th": "โดยเราจะติดตั้ง **extension**\n\nเปิด **โปรเจกต์เมเนเจอร์**",
"ar": "للقيام بذلك، سوف نقوم بتثبيت **ملحق**.\n\nفتح **مدير المشروع**."
}
},
"placement": "right"
}
},
{
"elementToHighlightId": "div[role=\"presentation\"]:is([data-open=true], :not([aria-hidden=true])) #project-manager-tab-extensions",
"nextStepTrigger": {
"presenceOfElement": "#project-manager-extension-search-or-create"
},
"tooltip": {
"description": {
"messageByLocale": {
"en": "Open the **Extensions** tab.",
"fr": "Ouvrez l'onglet **Extensions**.",
"es": "Abre la pestaña **Extensiones**.",
"pt": "Abra a guia **Extensões**.",
"th": "เปิดแท็บ **Extensions**",
"ar": "فتح نافذة **الملحقات**."
}
}
},
"isOnClosableDialog": true,
"skippable": true
},
{
"elementToHighlightId": "#project-manager-extension-search-or-create",
"nextStepTrigger": {
"presenceOfElement": "#extension-search-dialog"
},
"tooltip": {
"description": {
"messageByLocale": {
"en": "Open the extension store",
"fr": "Ouvrez le **Magasin d'extension**.",
"es": "Abre la **Tienda de extensiones**.",
"pt": "Abra a **Loja de extensões**.",
"th": "เปิดร้านค้า extension",
"ar": "فتح متجر الملحقات"
}
}
},
"isOnClosableDialog": true
},
{
"elementToHighlightId": "#toolbar-open-objects-panel-button",
"nextStepTrigger": {
Expand Down Expand Up @@ -1796,6 +1729,16 @@
"presenceOfElement": "#object-editor-dialog"
},
"tooltip": {
"title": {
"messageByLocale": {
"en": "Now we'll make it possible for the player to drag the $(projectile).",
"fr": "Maintenant, nous allons faire en sorte que le joueur puisse faire glisser $(projectile) avec sa souris.",
"es": "Ahora vamos a hacer que el jugador pueda arrastrar $(projectile) con el ratón.",
"pt": "Agora vamos fazer com que o jogador possa arrastar $(projectile) com o mouse.",
"th": "ทีนี้เราจะทำให้ผู้เล่นสามารถลาก $(projectile)",
"ar": "الآن هيّا نجعل اللاعبين قادرين على سحب الـ $(projectile)."
}
},
"placement": "left",
"description": {
"messageByLocale": {
Expand Down Expand Up @@ -2185,6 +2128,7 @@
{
"elementToHighlightId": "#toolbar-open-properties-panel-button",
"skippable": true,
"interactsWithCanvas": true,
"nextStepTrigger": {
"presenceOfElement": "#instance-properties-editor"
},
Expand All @@ -2203,6 +2147,7 @@
}
},
{
"interactsWithCanvas": true,
"nextStepTrigger": {
"presenceOfElement": "#instance-properties-editor [id=\"Z Order\"]"
},
Expand All @@ -2224,6 +2169,7 @@
{
"elementToHighlightId": "#toolbar-open-properties-panel-button",
"skippable": true,
"interactsWithCanvas": true,
"nextStepTrigger": {
"presenceOfElement": "#instance-properties-editor"
},
Expand Down Expand Up @@ -2849,9 +2795,9 @@
}
},
{
"elementToHighlightId": "#layer-1 #layer-name",
"elementToHighlightId": "#layer-1",
"nextStepTrigger": {
"valueEquals": "WinLayer"
"presenceOfElement": "#layer-1[data-scene=\"WinLayer\"]"
},
"tooltip": {
"description": {
Expand All @@ -2870,7 +2816,7 @@
{
"elementToHighlightId": "#layer-1 #layer-visibility",
"nextStepTrigger": {
"valueHasChanged": true
"presenceOfElement": "#layer-1[data-hidden=\"true\"]"
},
"tooltip": {
"description": {
Expand Down Expand Up @@ -3959,7 +3905,7 @@
"id": "ClickOnGenerateLink",
"elementToHighlightId": "[id$=online-web-button][id^=launch-export]",
"nextStepTrigger": {
"presenceOfElement": "#open-online-export-button"
"absenceOfElement": "[id$=online-web-button][id^=launch-export]"
},
"tooltip": {
"description": {
Expand Down Expand Up @@ -3987,6 +3933,7 @@
"nextStepTrigger": {
"absenceOfElement": "#export-game-share-dialog"
},
"disableBlockingLayer": true,
"tooltip": {
"description": {
"messageByLocale": {
Expand Down Expand Up @@ -4121,7 +4068,7 @@
{
"elementToHighlightId": "#project-manager #add-new-scene-button",
"nextStepTrigger": {
"presenceOfElement": "#scene-item-1"
"presenceOfElement": "#project-manager [id^=\"scene-item\"][data-scene]:not([data-default=\"true\"])"
},
"tooltip": {
"description": {
Expand All @@ -4142,7 +4089,7 @@
}
},
{
"elementToHighlightId": "#project-manager #scene-item-1",
"elementToHighlightId": "#project-manager [id^=\"scene-item\"][data-scene]:not([data-default=\"true\"])",
"nextStepTrigger": {
"presenceOfElement": "editorTab:startScene:Scene"
},
Expand Down Expand Up @@ -4544,6 +4491,25 @@
},
"skippable": true
},
{
"elementToHighlightId": "objectInObjectsList:startText",
"nextStepTrigger": {
"absenceOfElement": "#scene-editor[data-active] #objects-list input"
},
"tooltip": {
"description": {
"messageByLocale": {
"en": "Press **Enter** to keep the name $(startText) for now.",
"fr": "Appuyez sur **Entrée** pour garder le nom $(startText) pour l'instant.",
"es": "Presione **Enter** para mantener el nombre $(startText) por ahora.",
"pt": "Pressione **Enter** para manter o nome $(startText) por enquanto.",
"th": "กด **Enter** เพื่อใช้ชื่อ $(startText) ไปก่อน",
"ar": "اضغط على **Enter** للاحتفاظ بالاسم $(startText) في الوقت الحالي."
}
},
"placement": "left"
}
},
{
"elementToHighlightId": "objectInObjectsList:startText",
"nextStepTrigger": {
Expand Down Expand Up @@ -4829,7 +4795,7 @@
{
"elementToHighlightId": "#instruction-editor-dialog #search-bar",
"nextStepTrigger": {
"presenceOfElement": "#instruction-item-MouseButtonReleased"
"presenceOfElement": "#instruction-item-MouseButtonFromTextReleased"
},
"tooltip": {
"description": {
Expand All @@ -4846,7 +4812,7 @@
"isOnClosableDialog": true
},
{
"elementToHighlightId": "#instruction-item-MouseButtonReleased",
"elementToHighlightId": "#instruction-item-MouseButtonFromTextReleased",
"nextStepTrigger": {
"presenceOfElement": "#instruction-parameters-container"
},
Expand All @@ -4867,7 +4833,7 @@
{
"elementToHighlightId": "#instruction-parameters-container select",
"nextStepTrigger": {
"valueEquals": "Left"
"valueEquals": "\"Left\""
},
"tooltip": {
"description": {
Expand Down Expand Up @@ -6470,7 +6436,7 @@
{
"elementToHighlightId": "sceneInProjectManager:startScene",
"nextStepTrigger": {
"presenceOfElement": "[id^=\"scene-item\"][data-default=\"true\"]"
"presenceOfElement": "sceneInProjectManager:startScene:[data-default=\"true\"]"
},
"tooltip": {
"description": {
Expand Down
Loading