Skip to content
Merged

Sync #413

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
135 changes: 79 additions & 56 deletions materials_devops_pipelines/Materials-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ trigger: none
pr:
branches:
include:
- main
- development

paths:
include:
- terraform/*
Expand Down Expand Up @@ -59,13 +60,34 @@ stages:
pool:
name: $(dev-build-agent)
steps:
- checkout: self
fetchDepth: 0

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
git fetch origin main
$files = $(git diff --name-only origin/main)
$temp=$files -split ' '
$targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH
$targetBranchOverride = $env:TARGETBRANCHOVERRIDE

# Optional override to support manual runs.
if ([string]::IsNullOrWhiteSpace($targetBranch) -and -not [string]::IsNullOrWhiteSpace($targetBranchOverride))
{
$targetBranch = $targetBranchOverride
}

if ([string]::IsNullOrWhiteSpace($targetBranch))
{
# Default for non-PR runs when no override is provided.
$targetBranch = "refs/heads/development"
}

$targetBranchName = $targetBranch -replace '^refs/heads/', ''
echo "Comparing changes against origin/$targetBranchName"

git fetch origin "+refs/heads/${targetBranchName}:refs/remotes/origin/${targetBranchName}" --depth=200

$temp = @(git diff --name-only "origin/$targetBranchName...HEAD" | ForEach-Object { $_.Trim() } | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
$count=$temp.Length
echo "Total changed $count files"

Expand Down Expand Up @@ -211,59 +233,60 @@ stages:

# ---------- E2E TESTS (Playwright) ----------

- script: |
npx playwright install
displayName: 'Install Playwright browsers'
condition: ne(variables['PLAYWRIGHT_CACHE_RESTORED'], 'true')
workingDirectory: '$(workingDir)'
env:
PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'
#temp removal of E2E tests until pipeline issues resolved
# - script: |
# npx playwright install
# displayName: 'Install Playwright browsers'
# condition: ne(variables['PLAYWRIGHT_CACHE_RESTORED'], 'true')
# workingDirectory: '$(workingDir)'
# env:
# PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'

- script: |
npx playwright install-deps
displayName: 'Install Playwright OS dependencies'
condition: and(eq(variables['Agent.OS'], 'Linux'), ne(variables['PLAYWRIGHT_CACHE_RESTORED'], 'true'))
workingDirectory: '$(workingDir)'
env:
PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'
# - script: |
# npx playwright install-deps
# displayName: 'Install Playwright OS dependencies'
# condition: and(eq(variables['Agent.OS'], 'Linux'), ne(variables['PLAYWRIGHT_CACHE_RESTORED'], 'true'))
# workingDirectory: '$(workingDir)'
# env:
# PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'

- task: Npm@1
displayName: 'Run E2E Tests with Coverage'
inputs:
command: 'custom'
customCommand: 'run e2e'
workingDir: '$(workingDir)'
env:
PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'
E2E_TEST_MS_USERNAME: $(e2e_username)
E2E_TEST_MS_PASSWORD: $(e2e_password)
E2E_CIN3_USERNAME: $(e2e_cin3_username)
E2E_CIN3_PASSWORD: $(e2e_cin3_password)
E2E_CMS_COOKIE_URL: $(e2e_cms_cookie_url)
E2E_URN: $(e2e_urn)
E2E_CASE: $(e2e_case)
VITE_MSAL_CLIENT_ID: $(MSAL_CLIENT_ID)
VITE_MSAL_TENANT_ID: $(MSAL_TENANT_ID)
VITE_MSAL_REDIRECT_URI: $(MSAL_REDIRECT_URI_LOCAL)
VITE_POLARIS_GATEWAY_URL: $(POLARIS_GATEWAY_URL)
VITE_POLARIS_GATEWAY_SCOPE: $(POLARIS_GATEWAY_SCOPE)
VITE_GLOBAL_SCRIPT_URL: $(GLOBAL_SCRIPT_URL)
VITE_BASE_URL: $(BASE_URL)
VITE_E2E: True
# - task: Npm@1
# displayName: 'Run E2E Tests with Coverage'
# inputs:
# command: 'custom'
# customCommand: 'run e2e'
# workingDir: '$(workingDir)'
# env:
# PLAYWRIGHT_BROWSERS_PATH: '$(Pipeline.Workspace)/.playwright'
# E2E_TEST_MS_USERNAME: $(e2e_username)
# E2E_TEST_MS_PASSWORD: $(e2e_password)
# E2E_CIN3_USERNAME: $(e2e_cin3_username)
# E2E_CIN3_PASSWORD: $(e2e_cin3_password)
# E2E_CMS_COOKIE_URL: $(e2e_cms_cookie_url)
# E2E_URN: $(e2e_urn)
# E2E_CASE: $(e2e_case)
# VITE_MSAL_CLIENT_ID: $(MSAL_CLIENT_ID)
# VITE_MSAL_TENANT_ID: $(MSAL_TENANT_ID)
# VITE_MSAL_REDIRECT_URI: $(MSAL_REDIRECT_URI_LOCAL)
# VITE_POLARIS_GATEWAY_URL: $(POLARIS_GATEWAY_URL)
# VITE_POLARIS_GATEWAY_SCOPE: $(POLARIS_GATEWAY_SCOPE)
# VITE_GLOBAL_SCRIPT_URL: $(GLOBAL_SCRIPT_URL)
# VITE_BASE_URL: $(BASE_URL)
# VITE_E2E: True

- task: PublishPipelineArtifact@1
displayName: 'Publish E2E Artifact'
inputs:
targetPath: '$(workingDir)/tests/playwright-report'
artifact: 'playwright-report'
publishLocation: 'pipeline'
condition: succeededOrFailed()
# - task: PublishPipelineArtifact@1
# displayName: 'Publish E2E Artifact'
# inputs:
# targetPath: '$(workingDir)/tests/playwright-report'
# artifact: 'playwright-report'
# publishLocation: 'pipeline'
# condition: succeededOrFailed()

- task: PublishTestResults@2
displayName: 'Publish E2E Test Results (JUnit)'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(workingDir)/tests/e2e-test-results.xml'
testRunTitle: 'E2E Tests'
publishRunAttachments: false
condition: always()
# - task: PublishTestResults@2
# displayName: 'Publish E2E Test Results (JUnit)'
# inputs:
# testResultsFormat: 'JUnit'
# testResultsFiles: '$(workingDir)/tests/e2e-test-results.xml'
# testRunTitle: 'E2E Tests'
# publishRunAttachments: false
# condition: always()
2 changes: 1 addition & 1 deletion materials_devops_pipelines/Materials-UI-Build-Prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trigger:
batch: true
branches:
include:
- development ## TBC once branching confirmed
- main
paths:
include:
- materials_ui
Expand Down
2 changes: 1 addition & 1 deletion materials_devops_pipelines/Materials-UI-Build-Staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trigger:
batch: true
branches:
include:
- development ## TBC once branching confirmed
- main
paths:
include:
- materials_ui
Expand Down
2 changes: 1 addition & 1 deletion materials_devops_pipelines/Materials-UI-Release-Prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
trigger:
branches:
include:
- refs/heads/development
- refs/heads/main
stages:
- Publish_Artifacts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
trigger:
branches:
include:
- refs/heads/development
- refs/heads/main
stages:
- Publish_Artifacts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const DropdownButton2 = (p: {
<Button
aria-label={p.ariaLabel}
ref={dropDownBtnRef}
variant="inverse"
onClick={() => p.setIsOpen(!p.isOpen)}
>
<div style={{ display: 'flex', gap: '4px' }}>
Expand Down
42 changes: 29 additions & 13 deletions materials_ui/src/caseWorkApp/components/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useLastFocus } from '../../hooks/useLastFocus';
import { Button } from '../button';
import TabButtons from './TabButtons';
import classes from './Tabs.module.scss';
import { CommonTabsProps } from './types';
Expand All @@ -12,6 +11,7 @@ export type TabsProps = CommonTabsProps & {
onShowHideCategoriesClick: () => void;
isShowCategories: boolean;
onCloseAllClick: () => void;
documentActions?: React.ReactNode;
};

export const Tabs: React.FC<TabsProps> = ({
Expand All @@ -23,6 +23,7 @@ export const Tabs: React.FC<TabsProps> = ({
onShowHideCategoriesClick,
isShowCategories,
onCloseAllClick,
documentActions,
...attributes
}) => {
useLastFocus('#search-within-case');
Expand Down Expand Up @@ -52,18 +53,39 @@ export const Tabs: React.FC<TabsProps> = ({

return (
<>
{items.length !== 1 && (
<div style={{ marginBottom: '24px' }}>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: '24px'
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
{items.length !== 1 && (
<>
<button
type="button"
className="govuk-link button-as-link"
data-testid="btn-close-all-tabs"
onClick={onCloseAllClick}
>
Close all documents
</button>
<span aria-hidden="true">|</span>
</>
)}
<button
type="button"
className="govuk-link button-as-link"
data-testid="btn-close-all-tabs"
onClick={onCloseAllClick}
data-testid="btn-view-full-width"
onClick={onShowHideCategoriesClick}
>
Close all documents
{isShowCategories ? 'View document full width' : 'Exit full width'}
</button>
</div>
)}
{documentActions}
</div>
<div
id="document-tabs"
role="region"
Expand All @@ -77,12 +99,6 @@ export const Tabs: React.FC<TabsProps> = ({
alignItems: 'start'
}}
>
<div style={{ flexShrink: 0, display: 'flex' }}>
<Button size="s" onClick={() => onShowHideCategoriesClick()}>
{isShowCategories ? 'Hide categories' : 'Show categories'}
</Button>
</div>

<div style={{ flex: 1, minWidth: 0 }}>
<TabButtons
items={items.map((item) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DocSearchContext,
DocumentTabPanel
} from '../../../materials_components/DocumentTabPanel/DocumentTabPanel';
import { DocumentActionsDropdown } from '../../../materials_components/documenViewportArea/DocumentActionsDropdown';
import { TRedaction } from '../../../materials_components/PdfRedactor/utils/coordUtils';
import {
isRedactionEnabledMode,
Expand Down Expand Up @@ -87,6 +88,9 @@ export const ReviewAndRedactPage = () => {
const [modeByParentId, setModeByParentId] = useState<Record<string, TMode>>(
{}
);
const [numOfPagesByParentId, setNumOfPagesByParentId] = useState<
Record<string, number>
>({});

const [searchModalOpen, setSearchModalOpen] = useState(false);

Expand Down Expand Up @@ -229,15 +233,12 @@ export const ReviewAndRedactPage = () => {
reloadSidebarTrigger.fire();
}}
initRedactions={redactionsIndexedOnParentId[doc.parentId]}
onViewInNewWindowClick={() => {
if (!urn || !caseId) return;
navigateToViewDocumentPageInNewTab({
urn,
caseId,
materialId: doc.parentId
});
}}
onRedactionLogClick={() => setShowRedactionLogModal(true)}
onNumOfPagesChange={(numOfPages) =>
setNumOfPagesByParentId((prev) => ({
...prev,
[doc.parentId]: numOfPages
}))
}
searchContext={searchContextByParentId[doc.parentId]}
onFocusedSearchIndexChange={(index) =>
setFocusedSearchIndex(doc.parentId, index)
Expand Down Expand Up @@ -290,6 +291,7 @@ export const ReviewAndRedactPage = () => {
setOpenParentIds([]);
setSearchContextByParentId({});
setRedactionsIndexedOnParentId({});
setNumOfPagesByParentId({});

const sidebarFocusTarget =
document.querySelector<HTMLElement>(
Expand Down Expand Up @@ -475,7 +477,9 @@ export const ReviewAndRedactPage = () => {
onSetDocumentOpenIds={setOpenParentIds}
onDocumentClick={requestActiveTabChange}
reloadTriggerData={reloadSidebarTrigger.data}
onDocumentsChange={setDocuments}
onDocumentsChange={(docs) => {
if (docs !== undefined) setDocuments(docs);
}}
/>
</>
) : undefined
Expand All @@ -491,6 +495,24 @@ export const ReviewAndRedactPage = () => {
noMargin
onShowHideCategoriesClick={() => setIsSidebarVisible((v) => !v)}
isShowCategories={isSidebarVisible}
documentActions={
<DocumentActionsDropdown
mode={modeByParentId[activeTabId] ?? 'disabled'}
onModeChange={(newMode) =>
handleModeChange(activeTabId, newMode)
}
onRedactionLogClick={() => setShowRedactionLogModal(true)}
onViewInNewWindowClick={() => {
if (!urn || !caseId) return;
navigateToViewDocumentPageInNewTab({
urn,
caseId,
materialId: activeTabId
});
}}
numOfDocumentPages={numOfPagesByParentId[activeTabId] ?? 0}
/>
}
/>
)}
</TwoCol>
Expand Down
Loading
Loading