Skip to content

Commit

Permalink
Merge pull request #21 from praekeltfoundation/test-related-pages
Browse files Browse the repository at this point in the history
Test related pages
  • Loading branch information
HawkiesZA authored Sep 27, 2024
2 parents a7fa968 + eeef576 commit fcdf359
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: praekeltfoundation/flow_tester
ref: v0.3.1
ref: v0.3.2
path: flow_tester
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Check formatting
Expand Down
128 changes: 128 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Django #
*.log
*.pot
*.pyc
__pycache__
*.__pycache__
db.sqlite3
media
static

# Backup files #
*.bak

# If you are using PyCharm #
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
*.iws /out/

# Python #
*.py[cod]
*$py.class

# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
*__pycache__/*
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery
celerybeat-schedule.*

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
ve/

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings

# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history

.DS_Store

/flow_tester

.cookie

/_build
12 changes: 2 additions & 10 deletions Browsable FAQs/QA/flows/Browsable FAQs.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,7 @@ card DisplayContent when content_data.body.has_children do
end
card DisplayContent when count(content_data.body.related_pages) > 0 do
related_data =
get(
"https://content-repo-api-qa.prk-k8s.prd-p6t.org/api/v2/pages/@selected_content_id/",
headers: [
["Authorization", "Token @global.config.contentrepo_token"]
]
)
related_pages = map(related_data.body.related_pages, &[&1.title, &1.title])
related_pages = map(content_data.body.related_pages, &[&1.title, &1.title])
selected_content_name =
list("Select related page", SelectRelatedPage, related_pages) do
Expand Down Expand Up @@ -324,7 +316,7 @@ end
card SelectRelatedPage, then: GetVariation do
selected_content_id =
find(related_data.body.related_pages, &(&1.title == selected_content_name)).value
find(content_data.body.related_pages, &(&1.title == selected_content_name)).value
message = 1
Expand Down
2 changes: 1 addition & 1 deletion Browsable FAQs/QA/flows_json/Browsable FAQs.json

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions Browsable FAQs/QA/tests/browsable_faqs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ defmodule BrowsableFAQsTest do
]
}

related_page_leaf = %ContentPage{
parent: "topic-1",
slug: "related-page-leaf",
title: "Related Page Leaf",
related_pages: ["multiple-messages-leaf"],
wa_messages: [
%WAMsg{
message: "Test related page leaf"
}
]
}

variations_page = %ContentPage{
parent: "topic-1",
slug: "variations-page",
Expand Down Expand Up @@ -101,8 +113,6 @@ defmodule BrowsableFAQsTest do
]
}

# TODO: FakeCMS support for related_pages

media_index = %Index{slug: "media-topic", title: "Media Topic"}
image = %Image{id: 1, title: "Test image", download_url: "https://example.org/image.jpeg"}

Expand Down Expand Up @@ -140,6 +150,7 @@ defmodule BrowsableFAQsTest do
parent_page,
nested_leaf_page,
multiple_messages_leaf,
related_page_leaf,
media_index,
image_page,
variations_page
Expand Down Expand Up @@ -187,6 +198,7 @@ defmodule BrowsableFAQsTest do
{"Leaf Page 1", "Leaf Page 1"},
{"Parent Page 1", "Parent Page 1"},
{"Multiple Messages Leaf", "Multiple Messages Leaf"},
{"Related Page Leaf", "Related Page Leaf"},
{"Variations test", "Variations test"}
]}
})
Expand Down Expand Up @@ -308,6 +320,25 @@ defmodule BrowsableFAQsTest do
])
end

test "display related pages" do
setup_flow()
|> FlowTester.set_contact_properties(%{"gender" => ""})
|> FlowTester.start()
|> receive_message(%{})
|> FlowTester.send("Topic 1")
|> receive_message(%{})
|> FlowTester.send("Related Page Leaf")
|> receive_message(%{
text: "Related Page Leaf\nTest related page leaf\n",
list: {"Select related page", [{"Multiple Messages Leaf", "Multiple Messages Leaf"}]}
})
|> FlowTester.send("Multiple Messages Leaf")
|> receive_message(%{
text: "Multiple Messages Leaf\nFirst message\n",
buttons: [{"Next", "Next"}]
})
end

test "variation no gender" do
setup_flow()
|> FlowTester.set_contact_properties(%{"gender" => ""})
Expand Down
7 changes: 5 additions & 2 deletions Browsable FAQs/stacks_config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
base_url: https://whatsapp.turn.io/
qa_dir: QA
urls:
- name: contentrepo
qa_url: https://content-repo-api-qa.prk-k8s.prd-p6t.org
prod_url: https://platform-mnch-contentrepo.prk-k8s.prd-p6t.org
stack_uuids:
- name: Browsable FAQs
qa_uuid: 8ab45813-2c9c-4ea6-bed1-10ad091d85e8
prod_uuid: todo

0 comments on commit fcdf359

Please sign in to comment.